You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/opentelemetry-enable.md
+31-34Lines changed: 31 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -171,19 +171,8 @@ const appInsights = new ApplicationInsightsClient(config);
171
171
172
172
```python
173
173
from azure.monitor.opentelemetry import configure_azure_monitor
174
-
from opentelemetry import trace
175
-
176
-
configure_azure_monitor(
177
-
connection_string="<Your Connection String>",
178
-
)
179
-
180
-
tracer = trace.get_tracer(__name__)
181
-
182
-
with tracer.start_as_current_span("hello"):
183
-
print("Hello, World!")
184
-
185
-
input()
186
174
175
+
configure_azure_monitor()
187
176
```
188
177
189
178
---
@@ -463,7 +452,29 @@ Other OpenTelemetry Instrumentations are available [here](https://github.com/ope
463
452
```
464
453
465
454
### [Python](#tab/python)
466
-
Currently unavailable.
455
+
456
+
Other OpenTelemetry Instrumentations are available [here](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation) and can be used in addition to `configure_azure_monitor`. Here is an example for adding the SQLAlchemy Instrumentation.
457
+
458
+
```python
459
+
from azure.monitor.opentelemetry import configure_azure_monitor
460
+
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
461
+
from sqlalchemy import create_engine, text
462
+
463
+
configure_azure_monitor()
464
+
465
+
engine = create_engine("sqlite:///:memory:")
466
+
# SQLAlchemy instrumentation is not officially supported by this package
467
+
# However, you can use the OpenTelemetry instument method manually in
468
+
# conjunction with configure_azure_monitor
469
+
SQLAlchemyInstrumentor().instrument(
470
+
engine=engine,
471
+
)
472
+
473
+
# Database calls using the SqlAlchemy library will be automatically captured
474
+
with engine.connect() as conn:
475
+
result = conn.execute(text("select 'hello world'"))
476
+
print(result.all())
477
+
```
467
478
468
479
---
469
480
@@ -603,9 +614,7 @@ public class Program {
603
614
from azure.monitor.opentelemetry import configure_azure_monitor
604
615
from opentelemetry import metrics
605
616
606
-
configure_azure_monitor(
607
-
connection_string="<your-connection-string>",
608
-
)
617
+
configure_azure_monitor()
609
618
meter = metrics.get_meter_provider().get_meter("otel_azure_monitor_histogram_demo")
610
619
611
620
histogram = meter.create_histogram("histogram")
@@ -696,9 +705,7 @@ public class Program {
696
705
from azure.monitor.opentelemetry import configure_azure_monitor
697
706
from opentelemetry import metrics
698
707
699
-
configure_azure_monitor(
700
-
connection_string="<your-connection-string>",
701
-
)
708
+
configure_azure_monitor()
702
709
meter = metrics.get_meter_provider().get_meter("otel_azure_monitor_counter_demo")
703
710
704
711
counter = meter.create_counter("counter")
@@ -791,9 +798,7 @@ from azure.monitor.opentelemetry import configure_azure_monitor
791
798
from opentelemetry import metrics
792
799
from opentelemetry.metrics import CallbackOptions, Observation
793
800
794
-
configure_azure_monitor(
795
-
connection_string="<your-connection-string>",
796
-
)
801
+
configure_azure_monitor()
797
802
meter = metrics.get_meter_provider().get_meter("otel_azure_monitor_gauge_demo")
0 commit comments