Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too much traces in AppInsights #32503

Closed
jeremydvoss opened this issue Oct 13, 2023 · 1 comment
Closed

Too much traces in AppInsights #32503

jeremydvoss opened this issue Oct 13, 2023 · 1 comment
Labels
Monitor - Distro Monitor OpenTelemetry Distro OpenTelemetry OpenTelemetry instrumentation (not Monitor-specific)

Comments

@jeremydvoss
Copy link
Member

Migrated from microsoft/ApplicationInsights-Python#317

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.

But i don't know which library you use for http requests, probably this one:

.

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

Current status:
User wanted more control over which logs are sent to the traces table.
@WaterKnight1998

These additional logs are appearing in the "traces" table in your Application Insights resource correct? We have recently implemented a #32192 to define the specific logger that you want to collect traces telemetry. This should allow you to define the logger to your application logger instead of the default which is the root logger. This is why you are seeing logs collected from the SDK itself. This feature should be available soon in the next release.

@github-actions github-actions bot added the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Oct 13, 2023
@jeremydvoss jeremydvoss added OpenTelemetry OpenTelemetry instrumentation (not Monitor-specific) Monitor - Distro Monitor OpenTelemetry Distro labels Oct 13, 2023
@github-actions github-actions bot removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Oct 13, 2023
@lzchen
Copy link
Member

lzchen commented Jun 5, 2024

Fixed with this for duplicate logs in functions environment and this for specifying root logger to trace.

@lzchen lzchen closed this as completed Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Monitor - Distro Monitor OpenTelemetry Distro OpenTelemetry OpenTelemetry instrumentation (not Monitor-specific)
Projects
None yet
Development

No branches or pull requests

2 participants