diff --git a/azure_monitor/examples/requests.py b/azure_monitor/examples/requests.py new file mode 100644 index 0000000..c59663b --- /dev/null +++ b/azure_monitor/examples/requests.py @@ -0,0 +1,21 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +import requests + +from azure_monitor import AzureMonitorSpanExporter +from opentelemetry import trace +from opentelemetry.ext import http_requests +from opentelemetry.sdk.trace import Tracer +from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor + +trace.set_preferred_tracer_implementation(Tracer) + +http_requests.enable(trace.tracer()) +span_processor = SimpleExportSpanProcessor( + AzureMonitorSpanExporter(instrumentation_key="") +) +trace.tracer().add_span_processor(span_processor) + +with trace.tracer().start_as_current_span("parent"): + response = requests.get("", timeout=5) +