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

opentelemetry-instrumentation-asgi: always set status code on duration attributes #2627

Conversation

danielhochman
Copy link
Contributor

Description

Bug: OpenTelemetryMiddleware records histograms with no status code if the span is non-recording. The decision to include status code on a histogram should not be dependent on tracing decisions.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit tests

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@danielhochman danielhochman requested a review from a team as a code owner June 20, 2024 20:53
Copy link

linux-foundation-easycla bot commented Jun 20, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@xrmx
Copy link
Contributor

xrmx commented Jun 21, 2024

@danielhochman You need the CLA signed to get your contribution accepted

@danielhochman
Copy link
Contributor Author

@xrmx Thanks, was waiting on Corp CLA approval. It's signed now!

…-contrib into middleware-always-set-status-code-on-duration-attrs
@danielhochman
Copy link
Contributor Author

@xrmx lint should pass now (tested locally), sorry for the churn.

@danielhochman
Copy link
Contributor Author

@xrmx Thanks again. I think this should be ready to merge!

@danielhochman
Copy link
Contributor Author

@xrmx Thanks for your review! Are we ready to merge?

@lzchen
Copy link
Contributor

lzchen commented Jul 3, 2024

@danielhochman

Recent changes to asgi instrumentation changes has caused some conflicts. I will resolve them by directly committing to your branch.

Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did som runs in some scenarios I have here and it's working as expected:
For old semconv:

{
    "name": "http.server.duration",
    "description": "Duration of HTTP server requests.",
    "unit": "ms",
    "data": {
        "data_points": [
            {
                "attributes": {
                    "http.scheme": "http",
                    "http.host": "127.0.0.1:8000",
                    "net.host.port": 8000,
                    "http.flavor": "1.1",
                    "http.method": "GET",
                    "http.server_name": "localhost:8000",
                    "http.status_code": 500,
                    "http.target": "/foobar"
                },
            }

For new semconv:

{
"name": "http.server.request.duration",
"description": "Duration of HTTP server requests.",
"unit": "s",
"data": {
    "data_points": [
        {
            "attributes": {
                "url.scheme": "http",
                "network.protocol.version": "1.1",
                "http.request.method": "GET",
                "http.route": "/foobar",
                "http.response.status_code": 500,
                "error.type": "500"
}

@lzchen lzchen merged commit b697f4a into open-telemetry:main Jul 12, 2024
379 checks passed
@danielhochman danielhochman deleted the middleware-always-set-status-code-on-duration-attrs branch July 17, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants