Skip to content

Commit

Permalink
Disable distributed tracing for live metrics calls (Azure#35822)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen authored May 30, 2024
1 parent 719362c commit 64b9434
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Handle invalid status codes in std metric payload
([#35762](https://github.com/Azure/azure-sdk-for-python/pull/35762))
- Disable distributed tracing for live metrics client calls
([#35822](https://github.com/Azure/azure-sdk-for-python/pull/35822))

### Other Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
)

from azure.core.exceptions import HttpResponseError
from azure.core.pipeline.policies import ContentDecodePolicy
from azure.monitor.opentelemetry.exporter._quickpulse._constants import (
_LONG_PING_INTERVAL_SECONDS,
_POST_CANCEL_INTERVAL_SECONDS,
_POST_INTERVAL_SECONDS,
)
from azure.monitor.opentelemetry.exporter._quickpulse._generated._configuration import QuickpulseClientConfiguration
from azure.monitor.opentelemetry.exporter._quickpulse._generated._client import QuickpulseClient
from azure.monitor.opentelemetry.exporter._quickpulse._generated.models import MonitoringDataPoint
from azure.monitor.opentelemetry.exporter._quickpulse._state import (
Expand Down Expand Up @@ -82,8 +84,24 @@ def __init__(self, connection_string: Optional[str]) -> None:
self._instrumentation_key = parsed_connection_string.instrumentation_key
# TODO: Support AADaudience (scope)/credentials
# Pass `None` for now until swagger definition is fixed
self._client = QuickpulseClient(credential=None, endpoint=self._live_endpoint) # type: ignore
# TODO: Support redirect
config = QuickpulseClientConfiguration(credential=None) # type: ignore
policies = [
# TODO: Support redirect
config.redirect_policy,
# Needed for serialization
ContentDecodePolicy(),
# Logging for client calls
config.http_logging_policy,
# TODO: Support AADaudience (scope)/credentials
config.authentication_policy,
# Explicitly disabling to avoid tracing live metrics calls
# DistributedTracingPolicy(),
]
self._client = QuickpulseClient(
credential=None, # type: ignore
endpoint=self._live_endpoint,
policies=policies
)

MetricExporter.__init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def is_subscribed(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace
# @distributed_trace
def is_subscribed(
self,
endpoint: str = "https://global.livediagnostics.monitor.azure.com",
Expand Down Expand Up @@ -440,7 +440,7 @@ def publish(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace
# @distributed_trace
def publish(
self,
endpoint: str = "https://global.livediagnostics.monitor.azure.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async def is_subscribed(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace_async
# @distributed_trace_async
async def is_subscribed(
self,
endpoint: str = "https://global.livediagnostics.monitor.azure.com",
Expand Down Expand Up @@ -360,7 +360,7 @@ async def publish(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace_async
# @distributed_trace_async
async def publish(
self,
endpoint: str = "https://global.livediagnostics.monitor.azure.com",
Expand Down

0 comments on commit 64b9434

Please sign in to comment.