Skip to content

azure-monitor-opentelemetry-exporter: drops input attributes when sampling-percentage reaches 100% - causes corrupt telemetry #47567

@josteink

Description

@josteink
  • Package Name: azure-monitor-opentelemetry-exporter
  • Package Version: v1.0.0b48
  • Operating System: Not relevant
  • Python Version: 3.14

Describe the bug
When using azure-monitor-opentelemetry-exporter to export telemetry, and especially when instrumenting HTTP dependencies with httpx, together with sampling, one will encounter that some of the telemetry ends up without any attributes all, marking them in App Insights/Azure Monitor as HTTP POST N/A, HTTP GET N/A, etc.

To Reproduce

Setup Azure Monitor using the default configure_azure_monitor() without any arguments, leaving the default at RateLimitedSampler(5.0).

This triggers a bug in _rate_limited_sampler.py, line 133:

  # current (buggy)
  if sampling_percentage == 100.0:
      new_attributes = {}         # drops all input attributes

Expected behavior
When sampling creates a net set of attributes, it should not throw away the attributes already populated for the span:

  # correct
  if sampling_percentage == 100.0:
      new_attributes = {} if attributes is None else dict(attributes)
      # intentionally no _SAMPLE_RATE_KEY at 100% — that part is correct

Screenshots

Image Image

Additional context
Especially prevalent with Async python code, but it may not be a requirement to trigger the condition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions