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
我正试图应用opentelemetry来监控Azure Function应用程序。我发现有两种方法可以配置导出:AzureMonitorTraceExporter和AzureMonitorSpanExporter。它们之间有什么区别?
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
app_insights_key = os.getenv('APPINSIGHTS_INSTRUMENTATIONKEY_String')
exporter = AzureMonitorTraceExporter.from_connection_string(app_insights_key)
和
from azure_monitor import AzureMonitorSpanExporter
app_insights_key = os.getenv('APPINSIGHTS_INSTRUMENTATIONKEY')
exporter = AzureMonitorSpanExporter(instrumentation_key=app_insights_key)
对于Azure功能应用程序,哪种方式更好?谢谢
AzureMonitorSpanExporter
是旧版本,现在不支持/开发。它是从https://github.com/microsoft/opentelemetry-azure-monitor-python到https://github.com/Azure/azure-sdk-for-python.您应该使用AzureMonitorTraceExporter
。