From 938d38728cde29f51b31517ae13a4c3753ebefdf Mon Sep 17 00:00:00 2001 From: jerevoss Date: Fri, 19 Jan 2024 18:17:08 -0800 Subject: [PATCH 1/4] Update Django samples and configure_azure_monitor method signature --- .../CHANGELOG.md | 2 ++ .../samples/traces/django/sample/db.sqlite3 | Bin 0 -> 131072 bytes .../traces/django/sample/example/views.py | 19 ------------------ .../samples/traces/django/sample/manage.py | 15 ++++++++++++++ .../traces/django/sample/sample/asgi.py | 19 ++++++++++++++++++ .../traces/django/sample/sample/wsgi.py | 19 ++++++++++++++++++ .../azure-monitor-opentelemetry/CHANGELOG.md | 13 ++++++++++++ .../azure/monitor/opentelemetry/_configure.py | 7 ++++++- .../azure/monitor/opentelemetry/_version.py | 2 +- .../tracing/django/sample/example/views.py | 4 ---- .../samples/tracing/django/sample/manage.py | 7 +++++++ .../tracing/django/sample/sample/asgi.py | 7 +++++++ .../tracing/django/sample/sample/wsgi.py | 7 +++++++ 13 files changed, 96 insertions(+), 25 deletions(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md index e2e72e8c3358..b69d28a6944c 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md @@ -16,6 +16,8 @@ - Update to OTel SKD/API 1.21 ([#33864](https://github.com/Azure/azure-sdk-for-python/pull/33864)) +- Update Django sample + ([#33834](https://github.com/Azure/azure-sdk-for-python/pull/33834)) ## 1.0.0b20 (2024-01-04) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/db.sqlite3 b/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/db.sqlite3 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..38f06d086022d37731ba46e226bc376ba0c8ee07 100644 GIT binary patch literal 131072 zcmeI5Yiu0X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gl&&|MCyIRXL_oSmy=B@FIDau|nA3l= zi|KSWol2Q4Nw+xJtA=_xaO&0VSbO4YyeVP){|KctAO!?K00ck)1V8`;KmY_l00ck) z1RfIsy#GHYuy6|kAOHd&00JNY0w4eaAOHd&00Kvd0N($PP-Q?02!H?xfB*=900@8p z2!H?xfB*e@tNE76d>51V8`;KmY_l00ck)1V8`;jt~L7{~w{sfD{k_0T2KI z5C8!X009sH0T2KI5O_=kLgd#kzUL9YE&ikUSK^n&_h|z^AOHd&00JNY0w4eaAOHd& z00JNY0*{Hnq~GT`{gm;S*c!&aPYwD!vuBLI%+b8Rqctq+qduQ!YKr}t0QM&hLSEXE z*cSio{u2YVIm0&1ze6xC_&m~S{%1_+PsV7~X8k^U|M!eNrjXzk1V8`;KmY_l00ck) z1V8`;KmY_l;7Aa#%>NgUgdm6j0T2KI5C8!X009sH0T2KI5C8!Xc;o~u@Bfe7HynZh b2!H?xfB*=900@8p2!H?xfB*;_4FdlM)_0+O literal 0 HcmV?d00001 diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/example/views.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/example/views.py index f12ad9e1d83f..da16e5ee393e 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/example/views.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/example/views.py @@ -1,27 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # mypy: disable-error-code="attr-defined" -import os from django.http import HttpResponse -from opentelemetry import trace -from opentelemetry.instrumentation.django import DjangoInstrumentor -from opentelemetry.sdk.trace import TracerProvider -from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter - -from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter - -# Enable instrumentation in the django library. -DjangoInstrumentor().instrument() - -trace.set_tracer_provider(TracerProvider()) -span_processor = BatchSpanProcessor( - AzureMonitorTraceExporter.from_connection_string( - os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] - ) -) -trace.get_tracer_provider().add_span_processor(span_processor) - def index(request): return HttpResponse("Hello, world.") diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/manage.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/manage.py index 849b87a1ca8a..af5923b7667f 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/manage.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/manage.py @@ -5,15 +5,30 @@ import os import sys +from opentelemetry import trace from opentelemetry.instrumentation.django import DjangoInstrumentor +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import BatchSpanProcessor + +from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sample.settings') + # Azure Monitor OpenTelemetry Exporters and Django Instrumentation should only be set up once in either asgi.py, wsgi.py, or manage.py, depending on startup method. + # If using manage.py, please remove setup from asgi.py and wsgi.py # Enable instrumentation in the django library. DjangoInstrumentor().instrument() + # Set up Azure Monitor OpenTelemetry Exporter + trace.set_tracer_provider(TracerProvider()) + span_processor = BatchSpanProcessor( + AzureMonitorTraceExporter.from_connection_string( + os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] + ) + ) + trace.get_tracer_provider().add_span_processor(span_processor) try: from django.core.management import execute_from_command_line diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/sample/asgi.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/sample/asgi.py index 7caf941a34d7..a78e7cdaa690 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/sample/asgi.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/sample/asgi.py @@ -13,9 +13,28 @@ import os from django.core.asgi import get_asgi_application +from opentelemetry import trace +from opentelemetry.instrumentation.django import DjangoInstrumentor +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import BatchSpanProcessor + +from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sample.settings') +# Azure Monitor OpenTelemetry Exporters and Django Instrumentation should only be set up once in either asgi.py, wsgi.py, or manage.py, depending on startup method. +# If using manage.py, please remove setup from asgi.py and wsgi.py +# Enable instrumentation in the django library. +DjangoInstrumentor().instrument() +# Set up Azure Monitor OpenTelemetry Exporter +trace.set_tracer_provider(TracerProvider()) +span_processor = BatchSpanProcessor( + AzureMonitorTraceExporter.from_connection_string( + os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] + ) +) +trace.get_tracer_provider().add_span_processor(span_processor) + application = get_asgi_application() # cSpell:enable diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/sample/wsgi.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/sample/wsgi.py index 34f760be44e7..a079ddc2c133 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/sample/wsgi.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/sample/wsgi.py @@ -12,7 +12,26 @@ import os from django.core.wsgi import get_wsgi_application +from opentelemetry import trace +from opentelemetry.instrumentation.django import DjangoInstrumentor +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import BatchSpanProcessor + +from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sample.settings') +# Azure Monitor OpenTelemetry Exporters and Django Instrumentation should only be set up once in either asgi.py, wsgi.py, or manage.py, depending on startup method. +# If using manage.py, please remove setup from asgi.py and wsgi.py +# Enable instrumentation in the django library. +DjangoInstrumentor().instrument() +# Set up Azure Monitor OpenTelemetry Exporter +trace.set_tracer_provider(TracerProvider()) +span_processor = BatchSpanProcessor( + AzureMonitorTraceExporter.from_connection_string( + os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] + ) +) +trace.get_tracer_provider().add_span_processor(span_processor) + application = get_wsgi_application() diff --git a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md index 927a02767312..d734885c1e39 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md @@ -1,5 +1,16 @@ # Release History +## 1.2.1 (Unreleased) + +### Features Added + +### Bugs Fixed + +### Other Changes + +- Update configure_azure_monitor signature and Django sample + ([#33834](https://github.com/Azure/azure-sdk-for-python/pull/33834)) + ## 1.2.0 (2024-01-18) ### Other Changes @@ -10,6 +21,8 @@ ([#33808](https://github.com/Azure/azure-sdk-for-python/pull/33808)) - Update min dependency versions opentelemetry-resource-detector-azure~=0.1.1, exporter~=1.0.0b21, OTel SDK/API~= 1.21 ([#33866](https://github.com/Azure/azure-sdk-for-python/pull/33866)) +- Update configure_azure_monitor signature and Django sample + ([#33834](https://github.com/Azure/azure-sdk-for-python/pull/33834)) ## 1.1.1 (2023-12-04) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py index d814c845e560..f36e68126318 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py @@ -62,9 +62,14 @@ def configure_azure_monitor(**kwargs) -> None: :paramtype credential: ~azure.core.credentials.TokenCredential or None :keyword bool disable_offline_storage: Boolean value to determine whether to disable storing failed telemetry records for retry. Defaults to `False`. + :keyword str logger_name: The name of the Python logger that telemetry will be collected. + :keyword dict instrumentation_options: A nested dictionary that determines which instrumentations + to enable or disable. Instrumentations are referred to by their Library Names. For example, + `{"azure_sdk": {"enabled": False}, "flask": {"enabled": False}, "django": {"enabled": True}}` + will disable Azure Core Tracing and the Flask instrumentation but leave Django and the other default + instrumentations enabled. :keyword str storage_directory: Storage directory in which to store retry files. Defaults to `/Microsoft/AzureMonitor/opentelemetry-python-`. - :keyword str logger_name: The name of the Python logger that telemetry will be collected. :rtype: None """ diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_version.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_version.py index cfd8fd9078a5..c719acea2c1c 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_version.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_version.py @@ -4,4 +4,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "1.2.0" +VERSION = "1.2.1" diff --git a/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py index 02c2c9f0e1e9..37961b951f3c 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py +++ b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/example/views.py @@ -4,12 +4,8 @@ # license information. # -------------------------------------------------------------------------- -from azure.monitor.opentelemetry import configure_azure_monitor from django.http import HttpResponse -# Configure Azure monitor collection telemetry pipeline -configure_azure_monitor() - # Requests sent to the django application will be automatically captured def index(request): diff --git a/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/manage.py b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/manage.py index 5d854eb0e5f2..222c1993146e 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/manage.py +++ b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/manage.py @@ -5,11 +5,18 @@ import os import sys +from azure.monitor.opentelemetry import configure_azure_monitor + def main(): """Run administrative tasks.""" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sample.settings") + # Configure Azure monitor collection telemetry pipeline + # configure_azure_monitor should only be called once in either asgi.py, wsgi.py, or manage.py, depending on startup method. + # If using manage.py, please remove configure_azure_monitor from asgi.py and wsgi.py + configure_azure_monitor() + try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/sample/asgi.py b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/sample/asgi.py index 900201111e28..a299d1a45763 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/sample/asgi.py +++ b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/sample/asgi.py @@ -12,10 +12,17 @@ import os +from azure.monitor.opentelemetry import configure_azure_monitor from django.core.asgi import get_asgi_application + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sample.settings") +# Configure Azure monitor collection telemetry pipeline +# configure_azure_monitor should only be called once in etiher asgi.py, wsgi.py, or manage.py, depending on startup method. +# If using asgi, please remove configure_azure_monitor from wsgi.py and manage.py +configure_azure_monitor() + application = get_asgi_application() # cSpell:enable diff --git a/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/sample/wsgi.py b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/sample/wsgi.py index 1d4733978242..28fbcdcc2cd7 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/sample/wsgi.py +++ b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/sample/wsgi.py @@ -11,8 +11,15 @@ import os +from azure.monitor.opentelemetry import configure_azure_monitor from django.core.wsgi import get_wsgi_application + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sample.settings") +# Configure Azure monitor collection telemetry pipeline +# configure_azure_monitor should only be called once in either asgi.py, wsgi.py, or manage.py, depending on startup method. +# If using wsgi, please remove configure_azure_monitor from asgi.py and manage.py +configure_azure_monitor() + application = get_wsgi_application() From f814628b34cf4ca6b5d7ac177dd94dcc90ccfd88 Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 22 Jan 2024 10:34:46 -0800 Subject: [PATCH 2/4] Ignore spelling in django binary file --- .vscode/cspell.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 3622910b7fd7..596405305989 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -98,6 +98,8 @@ "sdk/ml/azure-ai-ml/swagger/**", "sdk/ml/azure-ai-ml/NOTICE.txt", "sdk/ml/azure-ai-ml/.pre-commit-config.yaml", + "sdk/monitor/azure-monitor-opentelemetry/samples/traces/django/sample/db.sqlite3", + "sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/db.sqlite3", "sdk/loadtestservice/azure-developer-loadtesting/**", "sdk/translation/azure-ai-translation-text/azure/ai/translation/text/_serialization.py", "sdk/translation/azure-ai-translation-text/tests/test_break_sentence.py", From 19266b0c5f2ad3e5be7724c8e66f3cff4a5bbdfe Mon Sep 17 00:00:00 2001 From: jerevoss Date: Mon, 22 Jan 2024 10:40:35 -0800 Subject: [PATCH 3/4] Add distro sqlite to match exporter --- .../samples/tracing/django/sample/db.sqlite3 | Bin 0 -> 131072 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/db.sqlite3 diff --git a/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/db.sqlite3 b/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..ca9793b0a54b180fe5bf88b0061ed64328c45bfd GIT binary patch literal 131072 zcmeI5Yiu0Xb;ozO%Uv$X-Qh#jsIg@ZSEj8EMRVWe%1vWhT1%`c%A%;+1ZqrYcZbx< z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LVrB^AHyFG|7h^H zhrT&9;r|xR1E>uAp?A~!rvpDLyf<)x%#P5H_mc2sDH;{to#$DZs&-c~v*GqFdv3OM zA|8;gM}=0Fr_hb;Ohe-%>xy=7r&QMzo|IS9g-jxoN!m?hBfDeFTCg8SUh{rTeD1tEPGkU@QnQ+bKDN*E$zOUGfG*r$d&;c%F4CvDQYz$H?@0B z>i~;Yrpo}ui!r}+HQFl^Z5OA+?b{>q7an$WW2iMg7vRbG3I}DT;LWx6D7AHv&pM{? za06KOD31nEjnT1(8OC!XO>X#T;XZXjCXP|ML^}1jhw12~ZsUu#5NHZU zpHZbr&FuM)&)DDV+hFoh0Vj3Un+HuZw>F$H9 zX)R=&_26j(otVu5_n4*6A}aQ)$2MFLZC#!YNVTNU`jqwdXceN+c!E+^^IBP{P~Df6 z#Z11KEGF~3;$4*cTr1zjaDUIX+o)9#Bh%3oq4>Bgx}~l>6OfWgVJ~aFrCLk6XgF=J zdKZgBRlljPXRYX}-491wW2dbnwuUUVSSeN6)QQeq$wE4l((-D?Y4EfWmi?)vcX=D^ zju{KRJv10?oqakWDKyvenzf~LY`d@KRKB1sX?dr#rw)*2tuQt5*KD}UV2_30UMbEglfsXm18bB?7ODi<_3LPt>7IQ+-#t+%(KV_s+5v*m8)Du^{UQy*(T(bm$*fK;Gh zHV+Dhd!$Q7&89WA7`M#8cE(n4-+U|Z#GX9`Q(X!bd7q;v?Fl-V$v|D|7I7{>1;Zc zGFy^vak5tp^>X0UtJ|^m#MgLJ!ubCYN@+j}2!H?xfB*=900@8p2!H?xfB* ze@tNE76d>51V8`;KmY_l00ck)1V8`;jt~L7{~w{sfD{k_0T2KI5C8!X009sH0T2KI z5O_=k@c#dpz``vEfB*=900@8p2!H?xfB*=900 Date: Mon, 22 Jan 2024 12:04:30 -0800 Subject: [PATCH 4/4] cspell --- .vscode/cspell.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 596405305989..392322d5edb1 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -98,7 +98,7 @@ "sdk/ml/azure-ai-ml/swagger/**", "sdk/ml/azure-ai-ml/NOTICE.txt", "sdk/ml/azure-ai-ml/.pre-commit-config.yaml", - "sdk/monitor/azure-monitor-opentelemetry/samples/traces/django/sample/db.sqlite3", + "sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/db.sqlite3", "sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/db.sqlite3", "sdk/loadtestservice/azure-developer-loadtesting/**", "sdk/translation/azure-ai-translation-text/azure/ai/translation/text/_serialization.py",