Open
Description
openedon Nov 8, 2024
- Package Name: @azure/monitor-opentelemetry
- Package Version: 1.8.0
- Operating system: MacOS + Windows
- nodejs
- version: 18.20.4 + 20.17.0 + 22.9.0
- browser
- name/version:
- typescript
- version:
- Is the bug related to documentation in
- README.md
- source code documentation
- SDK API docs on https://learn.microsoft.com
Describe the bug
Since the migration to OpenTelemetry with @azure/opentelemetry-instrumentation-azure-sdk
+ @opentelemetry/instrumentation-http
we are seing duplicated span when an HTTP call is emitted from an azure SDK libraries :
- First one is created from the tracingPolicy of the package
@azure/core-rest-pipeline
- Second one is created from the
@opentelemetry/instrumentation-http
which offer better customisation for outgoing request (ignore or not, custom attributes from headers, .......)
To Reproduce
Steps to reproduce the behavior:
- Run the below code
const { useAzureMonitor } = require('@azure/monitor-opentelemetry')
useAzureMonitor({
instrumentationOptions: {
http: { enabled: true },
azureSdk: { enabled: true },
mongoDb: { enabled: false },
redis4: { enabled: false },
mySql: { enabled: false },
redis: { enabled: false },
bunyan: { enabled: false },
winston: { enabled: false },
postgreSql: { enabled: false }
},
browserSdkLoaderOptions: { enabled: false }
})
const { DefaultAzureCredential } = require('@azure/identity')
const { SecretClient } = require('@azure/keyvault-secrets')
const { trace } = require('@opentelemetry/api')
const client = new SecretClient(`https://${process.env.KEYVAULT_NAME}.vault.azure.net`, new DefaultAzureCredential())
trace.getTracer('name', 'version').startActiveSpan('test_duplicated_span', async (span) => {
console.warn('Getting secret key...', span.spanContext().traceId)
const key = 'StorageConfName'
const result = await client.getSecret(key)
console.log(result)
})
setTimeout(() => {
console.log('Waiting for everything to be sent to Application Insights...')
}, 100_000)
Expected behavior
Only one span should be created for an HTTP call even if he the request goes through the tracing policy. For that there is different possibilities :
- Azure tracing policy should not generate a span for HTTP calls when
@opentelemetry/instrumentation-http
is enabled - Azure Monitor +
@azure/opentelemetry-instrumentation-azure-sdk
should expose options to indicate if HTTP calls should be tracked or not - Azure tracing policy should be compliant with
@opentelemetry/instrumentation-http
in terms of property/status/... If that's the case we can easily ignore request emitted from Azure SDK libraries while being able to keep all features (custom span attributes, ignore some requests, ....)
Additional context
Add any other context about the problem here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment