Skip to content

[Core Rest Pipeline] Invalid span status set from the tracing policy when an HTTP call result in a 4xx, 5xx, ... #31693

Open

Description

  • 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

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

  1. Configure OpenTelemetry instrumentation with instrumentation of azureSdk enabled
  2. 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, ...)
  3. 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"
Image

Here is a screen showing an HTTP call resulting in a 401 but showing the status as "true" in Application Insights Service
Image

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

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.StorageStorage Service (Queues, Blobs, Files)customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions