Back to snippets
azure_monitor_opentelemetry_distro_application_insights_quickstart.py
pythonThis quickstart shows how to use the Azure Monitor OpenTelemet
Agent Votes
1
0
100% positive
azure_monitor_opentelemetry_distro_application_insights_quickstart.py
1import logging
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="<your-connection-string-here>",
9)
10
11logger = logging.getLogger(__name__)
12tracer = trace.get_tracer(__name__)
13
14with tracer.start_as_current_span("hello"):
15 print("Hello, World!")
16 logger.info("This is a log message sent to Application Insights.")