azure.monitor.opentelemetry.exporter package

class azure.monitor.opentelemetry.exporter.ApplicationInsightsSampler(sampling_ratio: float = 1.0)[source]

Sampler that implements the same probability sampling algorithm as the ApplicationInsights SDKs.

get_description() str[source]
should_sample(parent_context: Context | None, trace_id: int, name: str, kind: SpanKind | None = None, attributes: Mapping[str, str | bool | int | float | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float]] | None = None, links: Sequence[Link] | None = None, trace_state: TraceState | None = None) SamplingResult[source]
class azure.monitor.opentelemetry.exporter.AzureMonitorLogExporter(**kwargs: Any)[source]

Azure Monitor Log exporter for OpenTelemetry.

Azure Monitor base exporter for OpenTelemetry.

Keyword Arguments:
  • api_version (str) – The service API version used. Defaults to latest.

  • connection_string (str) – The connection string used for your Application Insights resource.

  • credential (ManagedIdentityCredential/ClientSecretCredential) – Token credential, such as ManagedIdentityCredential or ClientSecretCredential, used for Azure Active Directory (AAD) authentication. Defaults to None.

  • disable_offline_storage (bool) – Determines whether to disable storing failed telemetry records for retry. Defaults to False.

  • storage_directory (str) – Storage path in which to store retry files. Defaults to <tempfile.gettempdir()>/opentelemetry-python-<your-instrumentation-key>.

Return type:

None

classmethod from_connection_string(conn_str: str, **kwargs: Any) AzureMonitorLogExporter[source]

Create an AzureMonitorLogExporter from a connection string. This is the recommended way of instantiation if a connection string is passed in explicitly. If a user wants to use a connection string provided by environment variable, the constructor of the exporter can be called directly.

Parameters:

conn_str (str) – The connection string to be used for authentication.

Keyword Arguments:

api_version (str) – The service API version used. Defaults to latest.

Returns:

an instance of ~AzureMonitorLogExporter

Return type:

AzureMonitorLogExporter

export(batch: Sequence[LogData], **kwargs: Any) LogExportResult[source]

Export log data.

Parameters:

batch (Sequence[LogData]) – OpenTelemetry LogData(s) to export.

Returns:

The result of the export.

Return type:

LogData

shutdown() None[source]

Shuts down the exporter.

Called when the SDK is shut down.

class azure.monitor.opentelemetry.exporter.AzureMonitorMetricExporter(**kwargs: Any)[source]

Azure Monitor Metric exporter for OpenTelemetry.

Azure Monitor base exporter for OpenTelemetry.

Keyword Arguments:
  • api_version (str) – The service API version used. Defaults to latest.

  • connection_string (str) – The connection string used for your Application Insights resource.

  • credential (ManagedIdentityCredential/ClientSecretCredential) – Token credential, such as ManagedIdentityCredential or ClientSecretCredential, used for Azure Active Directory (AAD) authentication. Defaults to None.

  • disable_offline_storage (bool) – Determines whether to disable storing failed telemetry records for retry. Defaults to False.

  • storage_directory (str) – Storage path in which to store retry files. Defaults to <tempfile.gettempdir()>/opentelemetry-python-<your-instrumentation-key>.

Return type:

None

classmethod from_connection_string(conn_str: str, **kwargs: Any) AzureMonitorMetricExporter[source]

Create an AzureMonitorMetricExporter from a connection string. This is the recommended way of instantiation if a connection string is passed in explicitly. If a user wants to use a connection string provided by environment variable, the constructor of the exporter can be called directly.

Parameters:

conn_str (str) – The connection string to be used for authentication.

Keyword Arguments:

api_version (str) – The service API version used. Defaults to latest.

Returns:

An instance of ~AzureMonitorMetricExporter

Return type:

AzureMonitorMetricExporter

export(metrics_data: MetricsData, timeout_millis: float = 10000, **kwargs: Any) MetricExportResult[source]

Exports a batch of metric data

Parameters:
  • metrics_data (Sequence[MetricsData]) – OpenTelemetry Metric(s) to export.

  • timeout_millis (float) – The maximum amount of time to wait for each export. Not currently used.

Returns:

The result of the export.

Return type:

MetricExportResult

force_flush(timeout_millis: float = 10000) bool[source]

Ensure that export of any metrics currently received by the exporter are completed as soon as possible.

shutdown(timeout_millis: float = 30000, **kwargs: Any) None[source]

Shuts down the exporter.

Called when the SDK is shut down.

Parameters:

timeout_millis (float) – The maximum amount of time to wait for shutdown. Not currently used.

class azure.monitor.opentelemetry.exporter.AzureMonitorTraceExporter(**kwargs: Any)[source]

Azure Monitor Trace exporter for OpenTelemetry.

Azure Monitor base exporter for OpenTelemetry.

Keyword Arguments:
  • api_version (str) – The service API version used. Defaults to latest.

  • connection_string (str) – The connection string used for your Application Insights resource.

  • credential (ManagedIdentityCredential/ClientSecretCredential) – Token credential, such as ManagedIdentityCredential or ClientSecretCredential, used for Azure Active Directory (AAD) authentication. Defaults to None.

  • disable_offline_storage (bool) – Determines whether to disable storing failed telemetry records for retry. Defaults to False.

  • storage_directory (str) – Storage path in which to store retry files. Defaults to <tempfile.gettempdir()>/opentelemetry-python-<your-instrumentation-key>.

Return type:

None

classmethod from_connection_string(conn_str: str, **kwargs: Any) AzureMonitorTraceExporter[source]

Create an AzureMonitorTraceExporter from a connection string. This is the recommended way of instantiation if a connection string is passed in explicitly. If a user wants to use a connection string provided by environment variable, the constructor of the exporter can be called directly.

Parameters:

conn_str (str) – The connection string to be used for authentication.

Keyword Arguments:

api_version (str) – The service API version used. Defaults to latest.

Returns:

an instance of ~AzureMonitorTraceExporter

Return type:

AzureMonitorTraceExporter

export(spans: Sequence[ReadableSpan], **kwargs: Any) SpanExportResult[source]

Export span data.

Parameters:

spans (Sequence[Span]) – Open Telemetry Spans to export.

Returns:

The result of the export.

Return type:

SpanExportResult

force_flush(timeout_millis: int = 30000) bool

Hint to ensure that the export of any spans the exporter has received prior to the call to ForceFlush SHOULD be completed as soon as possible, preferably before returning from this method.

shutdown() None[source]

Shuts down the exporter.

Called when the SDK is shut down.

Subpackages