Description
openedon Nov 8, 2024
- Package Name: @azure/core-rest-pipeline
- Package Version: 1.17.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
Despite the fact that enabling tracing of azure-sdk + http leads to duplicated span, the span generated by @azure/core-rest-pipeline is misconfigured and consider an http response code of 401 as a success call while it should not be the case ...
To Reproduce
- Configure OpenTelemetry instrumentation with instrumentation of azureSdk enabled
- Try to download a file through storage-blob (or any other libraries that use @azure/core-rest-pipeline with tracingPolicy) with an invalid configuration (leading to a status code of 401, 403, ...)
- Go in Application Insights services et you will see the span in "success" with the right status code
const { useAzureMonitor } = require('eliot-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 { BlobServiceClient } = require('@azure/storage-blob')
const { trace } = require('@opentelemetry/api')
trace.getTracer('name', 'version').startActiveSpan('test_span', async (span) => {
console.warn('Downloading file...', span.spanContext().traceId)
const storageName = 'my-storage'
const containerName = 'my-container'
const blobName = 'my-file.json'
const credentials = new DefaultAzureCredential()
const storageService = new BlobServiceClient(`https://${storageName}.blob.core.windows.net`, credentials)
// I do not have permission to download the file and therefore the call should return 4xx
const container = storageService.getContainerClient(containerName)
const blobClient = container.getBlobClient(blobName)
await blobClient.download(undefined, undefined, { })
.then( () => {
console.log('Downloaded')
})
.catch( (err) => {
console.error(err)
})
})
Expected behavior
An HTTP call returning 4xx, 5xx, ... should consider the call as failed and therefore set the span status to "failed"
Screenshots
Here is a screen from my IDE while using the debugger inside the file policies/tracingPolicy
. As you can see the response code is 401 but the span status is set to "success"
Here is a screen showing an HTTP call resulting in a 401 but showing the status as "true" in Application Insights Service
Additional context
Add any other context about the problem here.