Skip to content

Too much traces in AppInsights #317

@WaterKnight1998

Description

@WaterKnight1998

I have the following function code:

from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace

logging.getLogger().handlers = []

configure_azure_monitor(connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"])
tracer = trace.get_tracer(__name__)

app = fastapi.FastAPI()

@app.get("/x")
async def x():
   with tracer.start_as_current_span("aaaaa"):
      logging.info("a",extras={"b":1})

def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:
    return func.AsgiMiddleware(app).handle(req, context)

With this code I removed the duplicated logs and I can see custom dimensions. However I am seeing 3 taces each 5s creating too much logs:

Request URL: 'https://westeurope-5.in.applicationinsights.azure.com//v2.1/track' Request method: 'POST' Request header
Response status: 200 Response headers: 'Transfer-Encoding': 'chunked' 'Content-Type': 'application/json; charset=utf-8
Transmission succeeded: Item received: 3. Items accepted: 3

I tried the following env vars:

OTEL_PYTHON_EXCLUDED_URLS=.*applicationinsights\.azure\.com/.*
OTEL_PYTHON_REQUESTS_EXCLUDED_URLS=.*applicationinsights\.azure\.com/.*
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=django,asgi,wsgi,fastapi,flask,requests,urllib,urllib3
OTEL_TRACES_EXPORTER=none

However, I am still seeing this. I have seen that your sdk calls this endpoint. https://github.com/Azure/azure-sdk-for-python/blob/11437bbf7be952401581641f556ac8c897667e59/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/operations/_azure_monitor_client_operations.py#L39

But i don't know which library you use for http requests, probably this one: https://github.com/Azure/azure-sdk-for-python/blob/11437bbf7be952401581641f556ac8c897667e59/sdk/core/azure-core/azure/core/utils/_pipeline_transport_rest_shared.py#L27.

Any idea on how to disable this logs being sent to AI?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions