2
from azure.core.settings import settings
from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
settings.tracing_implementation = OpenTelemetrySpan

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor

I was trying to apply opentelemetry to monitor a Azure Function App. And I found there are two ways to configure export: AzureMonitorTraceExporter and AzureMonitorSpanExporter. What is the difference between them?

from  azure.monitor.opentelemetry.exporter  import  AzureMonitorTraceExporter
app_insights_key = os.getenv('APPINSIGHTS_INSTRUMENTATIONKEY_String')
exporter = AzureMonitorTraceExporter.from_connection_string(app_insights_key)

and

from azure_monitor import AzureMonitorSpanExporter
app_insights_key = os.getenv('APPINSIGHTS_INSTRUMENTATIONKEY')
exporter = AzureMonitorSpanExporter(instrumentation_key=app_insights_key)

And which way is better for a Azure Function App? Thanks.

Nick Meng
  • 65
  • 6

1 Answers1

3

AzureMonitorSpanExporter is old one and not supported/developed now. It is moved from https://github.com/microsoft/opentelemetry-azure-monitor-python to https://github.com/Azure/azure-sdk-for-python. You should be using AzureMonitorTraceExporter.

Srikanth Chekuri
  • 1,944
  • 1
  • 9
  • 19
  • No wonder I got error when used AzureMonitorSpanExporter. But the AzureMonitorTraceExporter works fine for me. Thank you! – Nick Meng Mar 27 '22 at 03:49