Document handling of empty OperationId in logs#128629
Conversation
Added information about empty OperationId in application logs and how to instrument logging with Application Insights agent. Background When a Java Azure Functions app enables the OpenTelemetry integration (`telemetryMode: "OpenTelemetry"` in host.json), application logs written by the function code can be ingested into Application Insights with an empty `operation_Id`. As already noted in the "Duplicate OperationId" entry, `operation_Id` is derived from the incoming `traceparent` and is applied only to telemetry emitted within the invocation context. Application logs that are forwarded by the Functions host (rather than emitted within the invocation context) are therefore recorded without an `operation_Id`, so they don't correlate with the invocation's request and trace in the end-to-end transaction view.
|
@syukumoto : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. |
|
Learn Build status updates of commit 3f265a4:
|
| File | Status | Preview URL | Details |
|---|---|---|---|
| articles/azure-functions/opentelemetry-howto.md | Details |
articles/azure-functions/opentelemetry-howto.md
- Line 626, Column 191: [Warning: hard-coded-locale - See documentation]
Link 'https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=java' contains locale code 'en-us'. For localizability, remove 'en-us' from links to most Microsoft sites. - Line 626, Column 191: [Suggestion: docs-link-absolute - See documentation]
Absolute link 'https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=java' will be broken in isolated environments. Replace with a relative link.
For more details, please refer to the build report.
Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.
|
|
||
| As described in Duplicate OperationId, the operation_Id is applied to telemetry that is emitted within the invocation context. Application logs emitted outside that context—for example, logs that the Functions host forwards—are recorded without an operation_Id. | ||
|
|
||
| If you need OperationId in your application logs, use the Application Insights agent to instrument your logging framework instead of the OpenTelemetry mode: enable the agent as described in [Enable Azure Monitor OpenTelemetry for .NET, Node.js, Python, and Java applications](https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=java). The agent stamps the trace context (operation_Id = trace ID) on the logs it emits within the invocation context. |
There was a problem hiding this comment.
| If you need OperationId in your application logs, use the Application Insights agent to instrument your logging framework instead of the OpenTelemetry mode: enable the agent as described in [Enable Azure Monitor OpenTelemetry for .NET, Node.js, Python, and Java applications](https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=java). The agent stamps the trace context (operation_Id = trace ID) on the logs it emits within the invocation context. | |
| If you need OperationId in your application logs, use the Application Insights agent to instrument your logging framework instead of the OpenTelemetry mode: enable the agent as described in [Enable Azure Monitor OpenTelemetry for .NET, Node.js, Python, and Java applications](/azure/azure-monitor/app/opentelemetry-enable?tabs=java). The agent stamps the trace context (operation_Id = trace ID) on the logs it emits within the invocation context. |
|
Can you review the proposed changes? IMPORTANT: When the changes are ready for publication, adding a #label:"aq-pr-triaged" |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Documents why Java Azure Functions logs can show an empty operation_Id when telemetryMode: "OpenTelemetry" is enabled, and provides guidance on using the Application Insights agent to get correlated log context.
Changes:
- Adds a new troubleshooting section explaining empty
operation_Idfor application logs forwarded by the Functions host. - Provides mitigation guidance: instrument logging via the Application Insights agent and remove
telemetryMode: "OpenTelemetry"fromhost.json.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Application logs written by your function code can appear in the traces table with an empty operation_Id. As a result, they don't correlate with the invocation's request and trace in the end-to-end transaction view. | ||
|
|
||
| As described in Duplicate OperationId, the operation_Id is applied to telemetry that is emitted within the invocation context. Application logs emitted outside that context—for example, logs that the Functions host forwards—are recorded without an operation_Id. | ||
|
|
||
| If you need OperationId in your application logs, use the Application Insights agent to instrument your logging framework instead of the OpenTelemetry mode: enable the agent as described in [Enable Azure Monitor OpenTelemetry for .NET, Node.js, Python, and Java applications](https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=java). The agent stamps the trace context (operation_Id = trace ID) on the logs it emits within the invocation context. |
|
|
||
| Application logs written by your function code can appear in the traces table with an empty operation_Id. As a result, they don't correlate with the invocation's request and trace in the end-to-end transaction view. | ||
|
|
||
| As described in Duplicate OperationId, the operation_Id is applied to telemetry that is emitted within the invocation context. Application logs emitted outside that context—for example, logs that the Functions host forwards—are recorded without an operation_Id. |
|
|
||
| If you need OperationId in your application logs, use the Application Insights agent to instrument your logging framework instead of the OpenTelemetry mode: enable the agent as described in [Enable Azure Monitor OpenTelemetry for .NET, Node.js, Python, and Java applications](https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=java). The agent stamps the trace context (operation_Id = trace ID) on the logs it emits within the invocation context. | ||
|
|
||
| Make sure telemetryMode isn't set to OpenTelemetry in your `host.json`. If you added `"telemetryMode": "OpenTelemetry"`, remove it. |
Added information about empty OperationId in application logs and how to instrument logging with Application Insights agent.
Background
When a Java Azure Functions app enables the OpenTelemetry integration (
telemetryMode: "OpenTelemetry"in host.json), application logs written by the function code can be ingested into Application Insights with an emptyoperation_Id. As already noted in the "Duplicate OperationId" entry,operation_Idis derived from the incomingtraceparentand is applied only to telemetry emitted within the invocation context. Application logs that are forwarded by the Functions host (rather than emitted within the invocation context) are therefore recorded without anoperation_Id, so they don't correlate with the invocation's request and trace in the end-to-end transaction view.