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

error.type Reports Overly Detailed Information #4945

Open
huapeng-zhang opened this issue Jan 2, 2025 · 0 comments
Open

error.type Reports Overly Detailed Information #4945

huapeng-zhang opened this issue Jan 2, 2025 · 0 comments
Assignees

Comments

@huapeng-zhang
Copy link
Contributor

We are continuously addressing and improving the SDK, if possible, make sure the problem persist in the latest SDK version.

Describe the bug
I am testing the unreleased client metric for the Cosmos DB client. After enabling client metric telemetry with IsClientMetricsEnabled = true and making a few requests, it emits some metrics. However, for the metrics with errors, the error.type contains too much information, which differs from the OpenTelemetry standard. The error.type should contain the type of the error or another concise message that indicates the type of the error.

Example of error.type dimension:

Response status code does not indicate success: NotFound (404); Substatus: 0; ActivityId: f832ed08-dd41-4f89-92ab-05a0befd6371; Reason: (
Errors : [
  "Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found"
]
);

OpenTelemetry standard:

According to the OpenTelemetry standard, the error.type should be more concise and only contain the type of the error. For reference, please see the OpenTelemetry specification: An external link was removed to protect your privacy.

To Reproduce

  1. Installing the the "Microsoft.Azure.Cosmos" package with client metrcy.
  2. Enable OpenTelemetry metrics and add meter "Azure.Cosmos.Client.Operation" & "Azure.Cosmos.Client.Request"
builder.Services.AddOpenTelemetry()
    .WithTracing(tracing => tracing
        .AddSource("Azure.Cosmos.Operation")
        .AddConsoleExporter()
    )
    .WithMetrics(metrics => metrics
        //.AddAspNetCoreInstrumentation()
        .AddMeter("Azure.Cosmos.Client.Operation")
        .AddMeter("Azure.Cosmos.Client.Request")
        .AddConsoleExporter()
    );
  1. Enable cosmos client metric.
CosmosClientTelemetryOptions telemetryOptions = new CosmosClientTelemetryOptions();
telemetryOptions.DisableDistributedTracing = false;
telemetryOptions.IsClientMetricsEnabled = true;
  1. Query an item that doesn't exist.
await this.container.ReadItemAsync<Family>("NotExistIdentify", new PartitionKey(wakefieldFamily.PartitionKey));
  1. Check error.type dimension of the related metric.

Expected behavior
error.type should be "NotFound (404)" or similar.

Actual behavior
error.type contains overly detailed information like description above.

Environment summary
SDK Version: internal tested SDK (or build from master with hash: 80d9e2e)
OS Version (e.g. Windows, Linux, MacOSX)
Windows

Additional context
Add any other context about the problem here (for example, complete stack traces or logs).

@microsoft-github-policy-service microsoft-github-policy-service bot added the customer-reported Issue created by a customer label Jan 2, 2025
microsoft-github-policy-service bot pushed a commit that referenced this issue Jan 8, 2025
…compliant with open telemetry standard (#4948)

# Pull Request Template

## Description

Address issue #4945 
Previous error.type contained detailed error message which wasn't
compliant with OpenTelemetry standard
[error.type](https://opentelemetry.io/docs/specs/semconv/attributes-registry/error/).

This PR generates the error type based on the exception type, status
code and sub status code.
An example of error.type value:
```"CosmosException_NotFound_ResourceNotFound"```

## Type of change

Please delete options that are not relevant.

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

## Closing issues
#4945 

To automatically close an issue: closes #IssueNumber

---------

Co-authored-by: Sourabh Jain <sourabhjain@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants