Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monitor Opentelemetry] Question about ensuring trace correlation in Azure Functions #32896

Open
gunzip opened this issue Feb 6, 2025 · 1 comment
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@gunzip
Copy link

gunzip commented Feb 6, 2025

I'm trying to achieve proper trace correlation in an Azure Function using the NodeJS worker.

The Azure Function runtime (host) logs the incoming HTTP request, while the NodeJS worker uses the Application Insights SDK (v3.x), which in turn leverages useAzureMonitor configured with the ApplicationInsightsSampler.

It appears that this sampler may drop traces related to the Span Context opened by the Azure host (root HTTP request), as it does not retain samples based on parent spans. This could result in incomplete end-to-end traces when using Azure Functions even with the same sampleRatio configured for both host and worker.

Would it be possible to use a ParentBasedSampler instead, to retain the full chain when the host sample the original request?

@gunzip gunzip changed the title [Monitor Opentelemetry] Question abou ensuring trace correlation in Azure Functions [Monitor Opentelemetry] Question about ensuring trace correlation in Azure Functions Feb 6, 2025
@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Feb 6, 2025
@jeremymeng jeremymeng added Client This issue points to a problem in the data-plane of the library. Monitor - Exporter Monitor OpenTelemetry Exporter labels Feb 6, 2025
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 6, 2025
@gunzip
Copy link
Author

gunzip commented Feb 8, 2025

Update: I’ve reviewed the sampling algorithm used in donet (Azure Function Host), and it invokes the DJB2 hashing function as follows:

https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/ApplicationInsightsSampler.cs#L57

while in the JS implementation it looks like it's applied directly to the plain (lowercase) traceId value:

https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/monitor/monitor-opentelemetry/src/traces/sampler.ts#L71

Could this be the reason?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants