Skip to content

Commit c6f192e

Browse files
Merge pull request #268831 from KennedyDenMSFT/US212418
Updated Python example to remove manual span
2 parents 4d03a5a + f17d374 commit c6f192e

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

articles/azure-monitor/app/opentelemetry-enable.md

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ ms.custom: devx-track-dotnet, devx-track-extended-java, devx-track-python
99
ms.reviewer: mmcc
1010
---
1111

12-
# Enable Azure Monitor OpenTelemetry for .NET, Node.js, Python and Java applications
12+
# Enable Azure Monitor OpenTelemetry for .NET, Node.js, Python, and Java applications
1313

1414
This article describes how to enable and configure OpenTelemetry-based data collection to power the experiences within [Azure Monitor Application Insights](app-insights-overview.md#application-insights-overview). We walk through how to install the "Azure Monitor OpenTelemetry Distro." The Distro [automatically collects](opentelemetry-add-modify.md#automatic-data-collection) traces, metrics, logs, and exceptions across your application and its dependencies. To learn more about collecting data using OpenTelemetry, see [Data Collection Basics](opentelemetry-overview.md) or [OpenTelemetry FAQ](#frequently-asked-questions).
1515

1616
## OpenTelemetry Release Status
1717

18-
OpenTelemetry offerings are available for .NET, Node.js, Python and Java applications.
18+
OpenTelemetry offerings are available for .NET, Node.js, Python, and Java applications.
1919

2020
> [!NOTE]
2121
> For a feature-by-feature release status, see the [FAQ](#whats-the-current-release-state-of-features-within-the-azure-monitor-opentelemetry-distro).
@@ -133,7 +133,7 @@ To enable Azure Monitor Application Insights, you make a minor modification to y
133133

134134
##### [ASP.NET Core](#tab/aspnetcore)
135135

136-
Add `UseAzureMonitor()` to your application startup. This is in your `program.cs` class.
136+
Add `UseAzureMonitor()` to your application startup, located in your `program.cs` class.
137137

138138
```csharp
139139
// Import the Azure.Monitor.OpenTelemetry.AspNetCore namespace.
@@ -188,7 +188,7 @@ var loggerFactory = LoggerFactory.Create(builder =>
188188

189189
Java autoinstrumentation is enabled through configuration changes; no code changes are required.
190190

191-
Point the JVM to the jar file by adding `-javaagent:"path/to/applicationinsights-agent-3.5.0.jar"` to your application's JVM args.
191+
Point the Java virtual machine (JVM) to the jar file by adding `-javaagent:"path/to/applicationinsights-agent-3.5.0.jar"` to your application's JVM args.
192192

193193
> [!TIP]
194194
> Sampling is enabled by default at a rate of 5 requests per second, aiding in cost management. Telemetry data may be missing in scenarios exceeding this rate. For more information on modifying sampling configuration, see [sampling overrides](./java-standalone-sampling-overrides.md).
@@ -219,21 +219,9 @@ from azure.monitor.opentelemetry import configure_azure_monitor
219219
# Import the tracing api from the `opentelemetry` package.
220220
from opentelemetry import trace
221221

222-
# Configure OpenTelemetry to use Azure Monitor with the specified connection
223-
# string.
224-
configure_azure_monitor(
225-
connection_string="<Your Connection String>",
226-
)
227-
228-
# Get a tracer for the current module.
229-
tracer = trace.get_tracer(__name__)
230-
231-
# Start a new span with the name "hello". This also sets this created span as the current span in this context. This span will be exported to Azure Monitor as part of the trace.
232-
with tracer.start_as_current_span("hello"):
233-
print("Hello, World!")
234-
235-
# Wait for export to take place in the background.
236-
input()
222+
# Configure OpenTelemetry to use Azure Monitor with the 
223+
# APPLICATIONINSIGHTS_CONNECTION_STRING environment variable.
224+
configure_azure_monitor()
237225

238226
```
239227

@@ -304,8 +292,8 @@ As part of using Application Insights instrumentation, we collect and send diagn
304292

305293
### [ASP.NET Core](#tab/aspnetcore)
306294

307-
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md)
308-
- To further configure the OpenTelemetry distro, see [Azure Monitor OpenTelemetry configuration](opentelemetry-configuration.md)
295+
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md).
296+
- To further configure the OpenTelemetry distro, see [Azure Monitor OpenTelemetry configuration](opentelemetry-configuration.md).
309297
- To review the source code, see the [Azure Monitor AspNetCore GitHub repository](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore).
310298
- To install the NuGet package, check for updates, or view release notes, see the [Azure Monitor AspNetCore NuGet Package](https://www.nuget.org/packages/Azure.Monitor.OpenTelemetry.AspNetCore) page.
311299
- To become more familiar with Azure Monitor and OpenTelemetry, see the [Azure Monitor Example Application](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Demo).
@@ -314,8 +302,8 @@ As part of using Application Insights instrumentation, we collect and send diagn
314302

315303
#### [.NET](#tab/net)
316304

317-
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md)
318-
- To further configure the OpenTelemetry distro, see [Azure Monitor OpenTelemetry configuration](opentelemetry-configuration.md)
305+
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md).
306+
- To further configure the OpenTelemetry distro, see [Azure Monitor OpenTelemetry configuration](opentelemetry-configuration.md).
319307
- To review the source code, see the [Azure Monitor Exporter GitHub repository](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter).
320308
- To install the NuGet package, check for updates, or view release notes, see the [Azure Monitor Exporter NuGet Package](https://www.nuget.org/packages/Azure.Monitor.OpenTelemetry.Exporter) page.
321309
- To become more familiar with Azure Monitor and OpenTelemetry, see the [Azure Monitor Example Application](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Demo).
@@ -324,7 +312,7 @@ As part of using Application Insights instrumentation, we collect and send diagn
324312

325313
### [Java](#tab/java)
326314

327-
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md)
315+
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md).
328316
- Review [Java autoinstrumentation configuration options](java-standalone-config.md).
329317
- To review the source code, see the [Azure Monitor Java autoinstrumentation GitHub repository](https://github.com/Microsoft/ApplicationInsights-Java).
330318
- To learn more about OpenTelemetry and its community, see the [OpenTelemetry Java GitHub repository](https://github.com/open-telemetry/opentelemetry-java-instrumentation).
@@ -333,7 +321,7 @@ As part of using Application Insights instrumentation, we collect and send diagn
333321

334322
### [Node.js](#tab/nodejs)
335323

336-
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md)
324+
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md).
337325
- To review the source code, see the [Azure Monitor OpenTelemetry GitHub repository](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/monitor/monitor-opentelemetry).
338326
- To install the npm package and check for updates, see the [`@azure/monitor-opentelemetry` npm Package](https://www.npmjs.com/package/@azure/monitor-opentelemetry) page.
339327
- To become more familiar with Azure Monitor Application Insights and OpenTelemetry, see the [Azure Monitor Example Application](https://github.com/Azure-Samples/azure-monitor-opentelemetry-node.js).
@@ -342,7 +330,7 @@ As part of using Application Insights instrumentation, we collect and send diagn
342330

343331
### [Python](#tab/python)
344332

345-
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md)
333+
- For details on adding and modifying Azure Monitor OpenTelemetry, see [Add and modify Azure Monitor OpenTelemetry](opentelemetry-add-modify.md).
346334
- To review the source code and extra documentation, see the [Azure Monitor Distro GitHub repository](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-opentelemetry/README.md).
347335
- To see extra samples and use cases, see [Azure Monitor Distro samples](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/monitor/azure-monitor-opentelemetry/samples).
348336
- See the [changelog](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md) on GitHub.

0 commit comments

Comments
 (0)