Skip to content

Document handling of empty OperationId in logs#128629

Open
syukumoto wants to merge 1 commit into
MicrosoftDocs:mainfrom
syukumoto:patch-2
Open

Document handling of empty OperationId in logs#128629
syukumoto wants to merge 1 commit into
MicrosoftDocs:mainfrom
syukumoto:patch-2

Conversation

@syukumoto

Copy link
Copy Markdown

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.

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.
@prmerger-automator

Copy link
Copy Markdown
Contributor

@syukumoto : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 3f265a4:

⚠️ Validation status: warnings

File Status Preview URL Details
articles/azure-functions/opentelemetry-howto.md ⚠️Warning 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@v-regandowner v-regandowner requested a review from Copilot July 13, 2026 14:40
@v-regandowner

Copy link
Copy Markdown
Contributor

@ggailey777

Can you review the proposed changes?

IMPORTANT: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator Bot added the aq-pr-triaged tracking label for the PR review team label Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_Id for application logs forwarded by the Functions host.
  • Provides mitigation guidance: instrument logging via the Application Insights agent and remove telemetryMode: "OpenTelemetry" from host.json.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +622 to +626
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants