Skip to content

Commit 0e838db

Browse files
Updated Python example to remove manual span
1 parent d10d77d commit 0e838db

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

articles/azure-monitor/app/opentelemetry-enable.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,9 @@ from azure.monitor.opentelemetry import configure_azure_monitor
219219
# Import the tracing api from the `opentelemetry` package.
220220
from opentelemetry import trace
221221

222-
# Configure OpenTelemetry to use Azure Monitor with the specified connection
223-
# string.
224-
configure_azure_monitor(
225-
connection_string="<Your Connection String>",
226-
)
227-
228-
# Get a tracer for the current module.
229-
tracer = trace.get_tracer(__name__)
230-
231-
# Start a new span with the name "hello". This also sets this created span as the current span in this context. This span will be exported to Azure Monitor as part of the trace.
232-
with tracer.start_as_current_span("hello"):
233-
print("Hello, World!")
234-
235-
# Wait for export to take place in the background.
236-
input()
222+
# Configure OpenTelemetry to use Azure Monitor with the 
223+
# APPLICATIONINSIGHTS_CONNECTION_STRING environment variable.
224+
configure_azure_monitor()
237225

238226
```
239227

0 commit comments

Comments
 (0)