From 689ff20b3d7795e9f995b082cb80a45464627acd Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 1 Aug 2022 17:48:04 -0700 Subject: [PATCH 01/11] Added OT Distro and Configurator --- setup.cfg | 6 ++++++ setup.py | 1 - .../monitor/opentelemetry/distro/configurator.py | 10 ++++++++++ src/azure/monitor/opentelemetry/distro/distro.py | 15 +++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/azure/monitor/opentelemetry/distro/configurator.py create mode 100644 src/azure/monitor/opentelemetry/distro/distro.py diff --git a/setup.cfg b/setup.cfg index 22d26402..2570988d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,3 +36,9 @@ install_requires = [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/setup.py b/setup.py index f730dd77..891c6034 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,6 @@ # -------------------------------------------------------------------------- import os - import setuptools BASE_DIR = os.path.dirname(__file__) diff --git a/src/azure/monitor/opentelemetry/distro/configurator.py b/src/azure/monitor/opentelemetry/distro/configurator.py new file mode 100644 index 00000000..055b18e0 --- /dev/null +++ b/src/azure/monitor/opentelemetry/distro/configurator.py @@ -0,0 +1,10 @@ +# ------------------------------------------------------------------------- +# 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..69efd288 --- /dev/null +++ b/src/azure/monitor/opentelemetry/distro/distro.py @@ -0,0 +1,15 @@ +# ------------------------------------------------------------------------- +# 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.instrumentation.distro import BaseDistro +from opentelemetry.environment_variables import OTEL_LOGS_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_TRACES_EXPORTER + +class AzureMonitorDistro(BaseDistro): + def _configure(self, **kwargs): + environ.setdefault(OTEL_LOGS_EXPORTER, "otlp_proto_grpc") + environ.setdefault(OTEL_METRICS_EXPORTER, "otlp_proto_grpc") + environ.setdefault(OTEL_TRACES_EXPORTER, "otlp_proto_grpc") From 4f83c3a82dda03aa257303c29efc580c02c7b4bf Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 1 Aug 2022 17:57:03 -0700 Subject: [PATCH 02/11] Removed accidental import reformat --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 891c6034..f730dd77 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- import os + import setuptools BASE_DIR = os.path.dirname(__file__) From 262e423f0387b613c258051f138042b0ac2f9534 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 1 Aug 2022 18:06:00 -0700 Subject: [PATCH 03/11] Updated CHANGELOG --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From f5e1013fc73c88a4f5ffe1ba8069f93625ccac73 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 1 Aug 2022 18:37:10 -0700 Subject: [PATCH 04/11] Added OpenTelemetry dependencies --- setup.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.cfg b/setup.cfg index 2570988d..9e0813ce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,6 +33,9 @@ zip_safe = False include_package_data = True install_requires = azure-monitor-opentelemetry-exporter == 1.0.0b6 + opentelemetry-instrumentation == 0.32b0 + opentelemetry-sdk == 1.12.0rc2 + opentelemetry-api == 1.12.0rc2 [options.packages.find] where = src From 0fb900bf5092b5c352c6bb22952067d81d3c1bd3 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Thu, 4 Aug 2022 17:08:38 -0700 Subject: [PATCH 05/11] Fixed exporter entry points --- src/azure/monitor/opentelemetry/distro/distro.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/azure/monitor/opentelemetry/distro/distro.py b/src/azure/monitor/opentelemetry/distro/distro.py index 69efd288..9d0ee9d9 100644 --- a/src/azure/monitor/opentelemetry/distro/distro.py +++ b/src/azure/monitor/opentelemetry/distro/distro.py @@ -10,6 +10,6 @@ class AzureMonitorDistro(BaseDistro): def _configure(self, **kwargs): - environ.setdefault(OTEL_LOGS_EXPORTER, "otlp_proto_grpc") - environ.setdefault(OTEL_METRICS_EXPORTER, "otlp_proto_grpc") - environ.setdefault(OTEL_TRACES_EXPORTER, "otlp_proto_grpc") + 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") From eb33d24c00397f938388ea685da94b620b840de9 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 8 Aug 2022 13:53:01 -0700 Subject: [PATCH 06/11] Set dependency versions to current pypi standard --- setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 9e0813ce..5a40f057 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,8 +34,8 @@ include_package_data = True install_requires = azure-monitor-opentelemetry-exporter == 1.0.0b6 opentelemetry-instrumentation == 0.32b0 - opentelemetry-sdk == 1.12.0rc2 - opentelemetry-api == 1.12.0rc2 + opentelemetry-sdk == 1.11.1 + opentelemetry-api == 1.11.1 [options.packages.find] where = src From e5e40aac98e47990cac555e6ac5677d245ca1225 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 8 Aug 2022 14:09:52 -0700 Subject: [PATCH 07/11] Added test requirements and reformatted with tox -e lint --- setup.cfg | 2 +- .../monitor/opentelemetry/distro/configurator.py | 1 + src/azure/monitor/opentelemetry/distro/distro.py | 11 +++++++++-- test-requirements.txt | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 5a40f057..a3723db5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,9 +33,9 @@ zip_safe = False include_package_data = True install_requires = azure-monitor-opentelemetry-exporter == 1.0.0b6 + opentelemetry-api == 1.11.1 opentelemetry-instrumentation == 0.32b0 opentelemetry-sdk == 1.11.1 - opentelemetry-api == 1.11.1 [options.packages.find] where = src diff --git a/src/azure/monitor/opentelemetry/distro/configurator.py b/src/azure/monitor/opentelemetry/distro/configurator.py index 055b18e0..1cc545f4 100644 --- a/src/azure/monitor/opentelemetry/distro/configurator.py +++ b/src/azure/monitor/opentelemetry/distro/configurator.py @@ -6,5 +6,6 @@ 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 index 9d0ee9d9..feff824d 100644 --- a/src/azure/monitor/opentelemetry/distro/distro.py +++ b/src/azure/monitor/opentelemetry/distro/distro.py @@ -6,10 +6,17 @@ from os import environ from opentelemetry.instrumentation.distro import BaseDistro -from opentelemetry.environment_variables import OTEL_LOGS_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_TRACES_EXPORTER +from opentelemetry.environment_variables import ( + OTEL_LOGS_EXPORTER, + OTEL_METRICS_EXPORTER, + OTEL_TRACES_EXPORTER, +) + class AzureMonitorDistro(BaseDistro): def _configure(self, **kwargs): environ.setdefault(OTEL_LOGS_EXPORTER, "azure_monitor_opentelemetry_exporter") - environ.setdefault(OTEL_METRICS_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..4a707281 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1,5 @@ pytest azure-monitor-opentelemetry-exporter +opentelemetry-api +opentelemetry-instrumentation +opentelemetry-sdk From 98fc7604b074cfe02c1a4c9ccd8d864b554a2ec2 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Tue, 9 Aug 2022 15:31:23 -0700 Subject: [PATCH 08/11] Adding package installation as prerequisite for tox -e lint --- setup.cfg | 2 -- src/azure/monitor/opentelemetry/distro/distro.py | 9 ++++----- test-requirements.txt | 3 --- tox.ini | 3 +++ 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/setup.cfg b/setup.cfg index a3723db5..f03b94bc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,9 +33,7 @@ zip_safe = False include_package_data = True install_requires = azure-monitor-opentelemetry-exporter == 1.0.0b6 - opentelemetry-api == 1.11.1 opentelemetry-instrumentation == 0.32b0 - opentelemetry-sdk == 1.11.1 [options.packages.find] where = src diff --git a/src/azure/monitor/opentelemetry/distro/distro.py b/src/azure/monitor/opentelemetry/distro/distro.py index feff824d..7f4d7267 100644 --- a/src/azure/monitor/opentelemetry/distro/distro.py +++ b/src/azure/monitor/opentelemetry/distro/distro.py @@ -5,12 +5,11 @@ # -------------------------------------------------------------------------- from os import environ + +from opentelemetry.environment_variables import (OTEL_LOGS_EXPORTER, + OTEL_METRICS_EXPORTER, + OTEL_TRACES_EXPORTER) from opentelemetry.instrumentation.distro import BaseDistro -from opentelemetry.environment_variables import ( - OTEL_LOGS_EXPORTER, - OTEL_METRICS_EXPORTER, - OTEL_TRACES_EXPORTER, -) class AzureMonitorDistro(BaseDistro): diff --git a/test-requirements.txt b/test-requirements.txt index 4a707281..31db64ad 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,2 @@ pytest azure-monitor-opentelemetry-exporter -opentelemetry-api -opentelemetry-instrumentation -opentelemetry-sdk 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 From 0f15764b9092a9783df92683f1e903d4e436d009 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Thu, 11 Aug 2022 11:44:11 -0700 Subject: [PATCH 09/11] Using exporter vesrion 1.0.0b7 --- setup.cfg | 2 +- test-requirements.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index f03b94bc..2f07471b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,7 +32,7 @@ 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] 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 From d19f24314b5ef9897fe8290f499f36dfca45de62 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 15 Aug 2022 17:10:43 -0700 Subject: [PATCH 10/11] Commenting out logging --- src/azure/monitor/opentelemetry/distro/distro.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/azure/monitor/opentelemetry/distro/distro.py b/src/azure/monitor/opentelemetry/distro/distro.py index 7f4d7267..3ad181c8 100644 --- a/src/azure/monitor/opentelemetry/distro/distro.py +++ b/src/azure/monitor/opentelemetry/distro/distro.py @@ -14,7 +14,8 @@ class AzureMonitorDistro(BaseDistro): def _configure(self, **kwargs): - environ.setdefault(OTEL_LOGS_EXPORTER, "azure_monitor_opentelemetry_exporter") + # 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" ) From 32742d92d916b231bef60b4eea7901f8df961811 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 15 Aug 2022 17:17:45 -0700 Subject: [PATCH 11/11] Deleted unused import --- src/azure/monitor/opentelemetry/distro/distro.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/azure/monitor/opentelemetry/distro/distro.py b/src/azure/monitor/opentelemetry/distro/distro.py index 3ad181c8..dddc3518 100644 --- a/src/azure/monitor/opentelemetry/distro/distro.py +++ b/src/azure/monitor/opentelemetry/distro/distro.py @@ -6,8 +6,7 @@ from os import environ -from opentelemetry.environment_variables import (OTEL_LOGS_EXPORTER, - OTEL_METRICS_EXPORTER, +from opentelemetry.environment_variables import (OTEL_METRICS_EXPORTER, OTEL_TRACES_EXPORTER) from opentelemetry.instrumentation.distro import BaseDistro