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
+29-28Lines changed: 29 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -176,19 +176,8 @@ const appInsights = new ApplicationInsightsClient(config);
176
176
177
177
```python
178
178
from azure.monitor.opentelemetry import configure_azure_monitor
179
-
from opentelemetry import trace
180
-
181
-
configure_azure_monitor(
182
-
connection_string="<Your Connection String>",
183
-
)
184
-
185
-
tracer = trace.get_tracer(__name__)
186
-
187
-
with tracer.start_as_current_span("hello"):
188
-
print("Hello, World!")
189
-
190
-
input()
191
179
180
+
configure_azure_monitor()
192
181
```
193
182
194
183
---
@@ -468,7 +457,29 @@ Other OpenTelemetry Instrumentations are available [here](https://github.com/ope
468
457
```
469
458
470
459
### [Python](#tab/python)
471
-
Currently unavailable.
460
+
461
+
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.
462
+
463
+
```python
464
+
from azure.monitor.opentelemetry import configure_azure_monitor
465
+
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
466
+
from sqlalchemy import create_engine, text
467
+
468
+
configure_azure_monitor()
469
+
470
+
engine = create_engine("sqlite:///:memory:")
471
+
# SQLAlchemy instrumentation is not officially supported by this package
472
+
# However, you can use the OpenTelemetry instument method manually in
473
+
# conjunction with configure_azure_monitor
474
+
SQLAlchemyInstrumentor().instrument(
475
+
engine=engine,
476
+
)
477
+
478
+
# Database calls using the SqlAlchemy library will be automatically captured
479
+
with engine.connect() as conn:
480
+
result = conn.execute(text("select 'hello world'"))
481
+
print(result.all())
482
+
```
472
483
473
484
---
474
485
@@ -608,9 +619,7 @@ public class Program {
608
619
from azure.monitor.opentelemetry import configure_azure_monitor
609
620
from opentelemetry import metrics
610
621
611
-
configure_azure_monitor(
612
-
connection_string="<your-connection-string>",
613
-
)
622
+
configure_azure_monitor()
614
623
meter = metrics.get_meter_provider().get_meter("otel_azure_monitor_histogram_demo")
615
624
616
625
histogram = meter.create_histogram("histogram")
@@ -701,9 +710,7 @@ public class Program {
701
710
from azure.monitor.opentelemetry import configure_azure_monitor
702
711
from opentelemetry import metrics
703
712
704
-
configure_azure_monitor(
705
-
connection_string="<your-connection-string>",
706
-
)
713
+
configure_azure_monitor()
707
714
meter = metrics.get_meter_provider().get_meter("otel_azure_monitor_counter_demo")
708
715
709
716
counter = meter.create_counter("counter")
@@ -835,9 +842,7 @@ from azure.monitor.opentelemetry import configure_azure_monitor
835
842
from opentelemetry import metrics
836
843
from opentelemetry.metrics import CallbackOptions, Observation
837
844
838
-
configure_azure_monitor(
839
-
connection_string="<your-connection-string>",
840
-
)
845
+
configure_azure_monitor()
841
846
meter = metrics.get_meter_provider().get_meter("otel_azure_monitor_gauge_demo")
0 commit comments