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
@@ -18,35 +18,33 @@ This article shows you how to configure your function app to export log and trac
18
18
19
19
> [!TIP]
20
20
> Because this article is targeted at your development language of choice, remember to choose the correct language at the top of the article.
21
-
::: zone pivot="programming-language-java"
22
-
> Currently, there's no client optimized OpenTelemetry support for Java apps.
23
-
:::zone-end
24
21
::: zone pivot="programming-language-csharp"
25
-
> OpenTelemetry currently isn't supported for C# in-process apps.
22
+
> OpenTelemetry currently isn't supported for [C# in-process apps](./functions-dotnet-class-library.md).
26
23
:::zone-end
27
24
28
25
You can obtain these benefits by enabling OpenTelemetry in your function app:
29
26
30
-
+Correlation across traces and logs being generated both at the host and in your application code.
31
-
+Consistent, standards-based generation of exportable telemetry data.
27
+
+Correlates data across traces and logs being generated both at the host and in your application code.
28
+
+Enables consistent, standards-based generation of exportable telemetry data.
32
29
+ Integrates with other providers that can consume OpenTelemetry-compliant data.
33
30
34
31
OpenTelemetry is enabled at the function app level, both in host configuration (`host.json`) and in your code project. Functions also provides a client optimized experience for exporting OpenTelemetry data from your function code that's running in a language-specific worker process.
35
32
36
-
## 1. Enable OpenTelemetry in the Functions host
33
+
## Enable OpenTelemetry in the Functions host
37
34
38
35
When you enable OpenTelemetry output in the function app's host.json file, your host exports OpenTelemetry output regardless of the language stack used by your app.
39
36
40
-
To enable OpenTelemetry output from the Functions host, update the [host.json file](./functions-host-json.md) in your code project to add a `"telemetryMode": "openTelemetry"` element to the root collection. With OpenTelemetry enabled, your host.json file might look like this:
37
+
To enable OpenTelemetry output from the Functions host, update the [host.json file](./functions-host-json.md) in your code project to add a `"telemetryMode": "OpenTelemetry"` element to the root collection. With OpenTelemetry enabled, your host.json file might look like this:
41
38
42
39
```json
43
40
{
44
41
"version": "2.0",
45
-
"telemetryMode": "openTelemetry"
42
+
"telemetryMode": "OpenTelemetry",
43
+
...
46
44
}
47
45
```
48
46
49
-
## 2. Configure application settings
47
+
## Configure application settings
50
48
51
49
When OpenTelemetry is enabled in the host.json file, the endpoints to which data is sent is determined based on which OpenTelemetry-supported application settings are available in your app's environment variables.
52
50
@@ -60,15 +58,22 @@ Create specific application settings in your function app based on the OpenTelem
60
58
61
59
**`OTEL_EXPORTER_OTLP_ENDPOINT`**: an OTLP exporter endpoint URL.
62
60
63
-
**`OTEL_EXPORTER_OTLP_HEADERS`**: (Optional) list of headers to apply to all outgoing data. This is used by many endpoints to pass an API key.
61
+
**`OTEL_EXPORTER_OTLP_HEADERS`**: (Optional) list of headers to apply to all outgoing data. This setting is used by many endpoints to pass an API key.
64
62
65
63
If your endpoint requires you to set other environment variables, you need to also add them to your application settings. For more information, see the [OTLP Exporter Configuration documentation](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/).
66
64
67
65
You should remove the `APPLICATIONINSIGHTS_CONNECTION_STRING` setting, unless you also want OpenTelemetry output from the host sent to Application Insights.
68
66
69
67
---
70
68
71
-
## 3. Enable OpenTelemetry in your app
69
+
::: zone pivot="programming-language-java"
70
+
You must also add `JAVA_APPLICATIONINSIGHTS_ENABLE_TELEMETRY=true` to your application settings. Setting this flag tells the Functions host to let the Java worker process stream OpenTelemetry logs directly, which prevents duplicate host-level entries.
71
+
72
+
> [!NOTE]
73
+
> When both Application Insights and OTLP exporter settings are present, telemetry flows to both backends.
74
+
::: zone-end
75
+
76
+
## Enable OpenTelemetry in your app
72
77
73
78
With the Functions host configured to use OpenTelemetry, you should also update your application code to output OpenTelemetry data. Enabling OpenTelemetry in both the host and your application code enables better correlation between traces and logs emitted both by the Functions host process and from your language worker process.
74
79
@@ -128,107 +133,70 @@ The way that you instrument your application to use OpenTelemetry depends on you
128
133
To export to both OpenTelemetry endpoints, call both `UseAzureMonitor` and `UseOtlpExporter`.
129
134
::: zone-end
130
135
::: zone pivot="programming-language-java"
136
+
1. Add the required libraries to your app. The way you add libraries depends on whether you deploy using Maven or Kotlin and if you want to also send data to Application Insights.
::: zone pivot="programming-language-javascript,programming-language-typescript"
233
201
1. Install these npm packages in your project:
234
202
@@ -328,7 +296,7 @@ These instructions only apply for an OTLP exporter:
328
296
```
329
297
---
330
298
331
-
1. Make sure the below library isin your `requirements.txt` file, whether from uncommenting or adding yourself:
299
+
1. Make sure these libraries are in your `requirements.txt` file, whether from uncommenting or adding yourself:
332
300
333
301
### [Application Insights](#tab/app-insights)
334
302
@@ -349,7 +317,7 @@ These instructions only apply for an OTLP exporter:
349
317
350
318
### [Application Insights](#tab/app-insights)
351
319
352
-
If you followed the above steps by setting the `PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY`, you don't need to add any additional code and skip the below.
320
+
If you followed the above steps by setting the `PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY`, you don't need to add any other code and skip the below.
353
321
354
322
If you would like to enable Application Insights collection manually without automatic instrumentation, add the following code:
355
323
@@ -390,22 +358,34 @@ These instructions only apply for an OTLP exporter:
390
358
391
359
---
392
360
393
-
1. Refer to [Azure monitor Distro usage]https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/monitor/azure-monitor-opentelemetry#usage) documentation for how to configure the SDK.
361
+
1. Refer to [Azure monitor Distro usage](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/monitor/azure-monitor-opentelemetry#usage) documentation for how to configure the SDK.
394
362
395
363
::: zone-end
396
364
## Considerations for OpenTelemetry
397
365
398
366
When you export your data using OpenTelemetry, keep these current considerations in mind.
399
367
400
-
+ At this time, only HTTP, Service Bus and Event Hub triggers are supported with OpenTelemetry outputs.
368
+
+ At this time, only HTTP, Service Bus and Event Hubs triggers are supported with OpenTelemetry outputs.
401
369
402
370
+ When the host is configured to use OpenTelemetry, the Azure portal doesn't support log streaming or recent function invocation traces.
371
+
::: zone pivot="programming-language-java"
372
+
+ Custom spans automatically include all resource attributes and use the exporters configured in your app.
373
+
374
+
+ When your app runs outside Azure, including during local development, the resource detector sets the `service.name` attribute to `java-function-app` by default.
403
375
376
+
+ Use these Java Virtual Machine (JVM) flags to silence telemetry when running locally during unit tests:
377
+
378
+
+ `-Dotel.traces.exporter=none`
379
+
+ `-Dotel.metrics.exporter=none`
380
+
+ `-Dotel.logs.exporter=none`
381
+
382
+
* You aren't required to manually register middleware; the Java worker autodiscovers `OpenTelemetryInvocationMiddleware`.
383
+
::: zone-end
404
384
+ [Azure Functions diagnostics](functions-diagnostics.md) in the Azure portal is a useful resource for detecting and diagnosing potential monitoring-related issues.
405
385
406
386
To access diagnostics in your app:
407
387
408
-
1. In the [Azure portal](https://portal.azure.com) navigate to your functionapp resource.
388
+
1. In the [Azure portal](https://portal.azure.com), navigate to your function app resource.
409
389
410
390
1. In the left pane, select **Diagnose and solve problems** and search for the *Function App missing telemetry Application Insights or OpenTelemetry* workflow.
0 commit comments