diff --git a/ext/opentelemetry-ext-azure-monitor/examples/azure_requests.py b/ext/opentelemetry-ext-azure-monitor/examples/azure_requests.py new file mode 100644 index 00000000000..4a5758f5d78 --- /dev/null +++ b/ext/opentelemetry-ext-azure-monitor/examples/azure_requests.py @@ -0,0 +1,31 @@ +# Copyright 2019, OpenCensus Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the 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) diff --git a/tox.ini b/tox.ini index 600d6b86c5f..a5db546b047 100644 --- a/tox.ini +++ b/tox.ini @@ -93,6 +93,7 @@ deps = commands_pre = pip install -e {toxinidir}/opentelemetry-api pip install -e {toxinidir}/opentelemetry-sdk + pip install -e {toxinidir}/opentelemetry-azure-monitor-exporter pip install -e {toxinidir}/ext/opentelemetry-ext-azure-monitor pip install -e {toxinidir}/ext/opentelemetry-ext-http-requests pip install -e {toxinidir}/ext/opentelemetry-ext-jaeger