diff --git a/CHANGELOG.md b/CHANGELOG.md index 63dc0302..c9395915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog ## Unreleased - +- Added OpenTelemetry Distro and Configurator + ([#187](https://github.com/microsoft/ApplicationInsights-Python/pull/187)) - Initial commit \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 22d26402..2f07471b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,7 +32,14 @@ packages=find_namespace: zip_safe = False include_package_data = True install_requires = - azure-monitor-opentelemetry-exporter == 1.0.0b6 + azure-monitor-opentelemetry-exporter == 1.0.0b7 + opentelemetry-instrumentation == 0.32b0 [options.packages.find] where = src + +[options.entry_points] +opentelemetry_distro = + azure_monitor_opentelemetry_distro = azure.monitor.opentelemetry.distro.distro:AzureMonitorDistro +opentelemetry_configurator = + azure_monitor_opentelemetry_configurator = azure.monitor.opentelemetry.distro.configurator:AzureMonitorConfigurator diff --git a/src/azure/monitor/opentelemetry/distro/configurator.py b/src/azure/monitor/opentelemetry/distro/configurator.py new file mode 100644 index 00000000..1cc545f4 --- /dev/null +++ b/src/azure/monitor/opentelemetry/distro/configurator.py @@ -0,0 +1,11 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License in the project root for +# license information. +# -------------------------------------------------------------------------- + +from opentelemetry.sdk._configuration import _OTelSDKConfigurator + + +class AzureMonitorConfigurator(_OTelSDKConfigurator): + pass diff --git a/src/azure/monitor/opentelemetry/distro/distro.py b/src/azure/monitor/opentelemetry/distro/distro.py new file mode 100644 index 00000000..dddc3518 --- /dev/null +++ b/src/azure/monitor/opentelemetry/distro/distro.py @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License in the project root for +# license information. +# -------------------------------------------------------------------------- + +from os import environ + +from opentelemetry.environment_variables import (OTEL_METRICS_EXPORTER, + OTEL_TRACES_EXPORTER) +from opentelemetry.instrumentation.distro import BaseDistro + + +class AzureMonitorDistro(BaseDistro): + def _configure(self, **kwargs): + # TODO: Uncomment when logging is out of preview + # environ.setdefault(OTEL_LOGS_EXPORTER, "azure_monitor_opentelemetry_exporter") + environ.setdefault( + OTEL_METRICS_EXPORTER, "azure_monitor_opentelemetry_exporter" + ) + environ.setdefault(OTEL_TRACES_EXPORTER, "azure_monitor_opentelemetry_exporter") diff --git a/test-requirements.txt b/test-requirements.txt index 31db64ad..e079f8a6 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1 @@ pytest -azure-monitor-opentelemetry-exporter diff --git a/tox.ini b/tox.ini index 52f99c31..473372d0 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,9 @@ recreate = True deps = -r lint-requirements.txt +commands_pre = + python -m pip install -e {toxinidir} + commands = black src isort --recursive src