Skip to content

Commit fd8013a

Browse files
Merge pull request #308107 from anthonychu/func-otel-troubleshooting
[Functions] Add OTel troubleshooting section
2 parents 68a87a7 + 45c9cbb commit fd8013a

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

articles/azure-functions/opentelemetry-howto.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,105 @@ When you export your data using OpenTelemetry, keep these current considerations
407407
::: zone-end
408408
+ [Azure Functions diagnostics](functions-diagnostics.md) in the Azure portal is a useful resource for detecting and diagnosing potential monitoring-related issues.
409409
410+
## Troubleshooting
411+
412+
When you export your data using OpenTelemetry, keep these common issues and solutions in mind.
413+
414+
### Log filtering
415+
416+
Understanding the difference between the host process and worker process is important for correctly configuring log filtering in your function app.
417+
418+
The *host process* is the Azure Functions runtime that manages triggers, scaling, and emits system-level telemetry such as initialization logs, request traces, and runtime health information.
419+
420+
The *worker process* is language specific, executes your function code, and produces application logs and telemetry independently.
421+
422+
> [!IMPORTANT]
423+
> Filters defined in host.json apply only to logs generated by the host process. Logs from the worker process must be filtered using language-specific OpenTelemetry settings.
424+
425+
**Example: Filter host logs for all providers in host.json**
426+
427+
Use this approach to set a global log level across all providers managed by the host:
428+
429+
```json
430+
{
431+
"version": "2.0",
432+
"telemetryMode": "OpenTelemetry",
433+
"logging": {
434+
"logLevel": {
435+
"default": "Warning"
436+
}
437+
}
438+
}
439+
```
440+
441+
**Example: Filter logs only for the OpenTelemetry logger provider**
442+
443+
Use this approach to target only the OpenTelemetry logger provider while leaving other providers (such as console or file logging) unaffected:
444+
445+
```json
446+
{
447+
"version": "2.0",
448+
"telemetryMode": "OpenTelemetry",
449+
"logging": {
450+
"OpenTelemetry": {
451+
"logLevel": {
452+
"default": "Warning"
453+
}
454+
}
455+
}
456+
}
457+
```
458+
459+
### Console logging
460+
461+
The Functions host automatically captures anything written to stdout or stderr and forwards it to the telemetry pipeline. If you also use a ConsoleExporter or write directly to console in your code, duplicate logs can occur in your telemetry data.
462+
463+
> [!NOTE]
464+
> Don't add ConsoleExporter or write to console in production code to avoid duplicate telemetry entries.
465+
466+
### Microsoft Entra authentication
467+
468+
When using Microsoft Entra authentication with OpenTelemetry, you must configure authentication separately for both the host process and the worker process.
469+
470+
To configure authentication for the host process, see [Require Microsoft Entra authentication](configure-monitoring.md#require-microsoft-entra-authentication).
471+
472+
To configure authentication for the worker process, see [Enable Microsoft Entra authentication](/azure/azure-monitor/app/azure-ad-authentication).
473+
474+
### Resource attributes support
475+
476+
Resource attributes support in Azure Monitor is currently in preview. To enable this feature, set the `OTEL_DOTNET_AZURE_MONITOR_ENABLE_RESOURCE_METRICS` environment variable to `true`. This setting ingests resource attributes into the custom metrics table.
477+
478+
### Duplicate request telemetry
479+
480+
The host process automatically emits request telemetry. If the worker process is also instrumented with request tracking libraries (for example, AspNetCoreInstrumentation in .NET), the same request is reported twice.
481+
482+
> [!NOTE]
483+
> Since the Azure Monitor Distro typically includes AspNetCoreInstrumentation in .NET and similar instrumentation in other languages, avoid using the Azure Monitor distro in the worker process to prevent duplicate telemetry.
484+
485+
### Logging scopes not included
486+
487+
By default, the worker process doesn't include scopes in its logs. To enable scopes, you must configure this setting explicitly in the worker. The following example shows how to enable scopes in .NET Isolated:
488+
489+
```csharp
490+
builder.Logging.AddOpenTelemetry(b => b.IncludeScopes = true);
491+
```
492+
493+
### Missing request telemetry
494+
495+
Triggers such as HTTP, Service Bus, and Event Hubs depend on context propagation for distributed tracing. With parent-based sampling as the default behavior, request telemetry isn't generated when the incoming request or message isn't sampled.
496+
497+
### Duplicate OperationId
498+
499+
In Azure Functions, the `OperationId` used for correlating telemetry is derived directly from the `traceparent` value in the incoming request or message. If multiple calls reuse the same `traceparent` value, they're all assigned the same `OperationId`.
500+
501+
### Configuring OpenTelemetry with environment variables
502+
503+
You can configure OpenTelemetry behavior using its standard environment variables, which provide a consistent way to control behavior across different languages and runtimes. These variables allow you to adjust sampling strategies, exporter settings, and resource attributes. For more information about supported environment variables, see the [OpenTelemetry documentation](https://opentelemetry.io/docs/languages/sdk-configuration/).
504+
505+
### Use diagnostics to troubleshoot monitoring issues
506+
507+
[Azure Functions diagnostics](functions-diagnostics.md) in the Azure portal is a useful resource for detecting and diagnosing potential monitoring-related issues.
508+
410509
To access diagnostics in your app:
411510

412511
1. In the [Azure portal](https://portal.azure.com), navigate to your function app resource.

0 commit comments

Comments
 (0)