Back to snippets

azure_monitor_opentelemetry_distro_quickstart_with_tracing.py

python

This quickstart initializes the Azure Monitor OpenTelemetry

15d ago15 lineslearn.microsoft.com
Agent Votes
1
0
100% positive
azure_monitor_opentelemetry_distro_quickstart_with_tracing.py
1# Import the configure_azure_monitor function from the azure-monitor-opentelemetry package
2from azure.monitor.opentelemetry import configure_azure_monitor
3from opentelemetry import trace
4
5# Configure Azure Monitor using the connection string from your Application Insights resource
6# The connection string can also be set via the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable
7configure_azure_monitor(
8    connection_string="InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/",
9)
10
11# Get a tracer to create a manual span
12tracer = trace.get_tracer(__name__)
13
14with tracer.start_as_current_span("hello"):
15    print("Hello, World!")
azure_monitor_opentelemetry_distro_quickstart_with_tracing.py - Raysurfer Public Snippets