def handle_azurequeue()

in elasticapm/instrumentation/packages/azure.py [0:0]


def handle_azurequeue(request, hostname, path, query_params, service, service_type, context):
    """
    Returns the HandlerInfo for Azure Queue operations
    """
    account_name = hostname.split(".")[0]
    method = request.method
    resource_name = path.split("/")[1] if "/" in path else account_name  # /queuename/messages
    context["destination"]["service"] = {
        "name": service,
        "resource": "{}/{}".format(service, resource_name),
        "type": service_type,
    }

    operation_name = "UNKNOWN"
    preposition = "to "
    if method.lower() == "delete":
        operation_name = "DELETE"
        preposition = ""
        if path.endswith("/messages") and "popreceipt" not in query_params:
            operation_name = "CLEAR"
        elif query_params.get("popreceipt", []):
            # Redundant, but included in case the table at
            # https://github.com/elastic/apm/blob/main/specs/agents/tracing-instrumentation-azure.md
            # changes in the future
            operation_name = "DELETE"
            preposition = "from "
    elif method.lower() == "get":
        operation_name = "RECEIVE"
        preposition = "from "
        if "list" in query_params.get("comp", []):
            operation_name = "LISTQUEUES"
        elif "properties" in query_params.get("comp", []):
            operation_name = "GETPROPERTIES"
        elif "stats" in query_params.get("comp", []):
            operation_name = "STATS"
        elif "metadata" in query_params.get("comp", []):
            operation_name = "GETMETADATA"
        elif "acl" in query_params.get("comp", []):
            operation_name = "GETACL"
        elif "true" in query_params.get("peekonly", []):
            operation_name = "PEEK"
    elif method.lower() == "head":
        operation_name = "RECEIVE"
        preposition = "from "
        if "metadata" in query_params.get("comp", []):
            operation_name = "GETMETADATA"
        elif "acl" in query_params.get("comp", []):
            operation_name = "GETACL"
    elif method.lower() == "options":
        operation_name = "PREFLIGHT"
        preposition = "from "
    elif method.lower() == "post":
        operation_name = "SEND"
        preposition = "to "
    elif method.lower() == "put":
        operation_name = "CREATE"
        preposition = ""
        if "metadata" in query_params.get("comp", []):
            operation_name = "SETMETADATA"
            preposition = "for "
        elif "acl" in query_params.get("comp", []):
            operation_name = "SETACL"
            preposition = "for "
        elif "properties" in query_params.get("comp", []):
            operation_name = "SETPROPERTIES"
            preposition = "for "
        elif query_params.get("popreceipt", []):
            operation_name = "UPDATE"
            preposition = ""

    # If `preposition` is included, it should have a trailing space
    signature = "AzureQueue {} {}{}".format(operation_name, preposition, resource_name)

    return HandlerInfo(signature, service_type, service, operation_name.lower(), context)