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-undici] make http.response.status_code available for use in hooks #2179

Closed
cpatti97100 opened this issue May 7, 2024 · 0 comments · Fixed by #2356

Comments

@cpatti97100
Copy link

cpatti97100 commented May 7, 2024

Is your feature request related to a problem? Please describe

Good morning all, I tried to use the 2 exposed hooks requestHook and startSpanHook from @opentelemetry/instrumentation-undici in order to access http.response.status_code from the span and copy its value into http.status_code for compatibility with our systems. From my understanding, this hooks run at a point in time before the monitored request actually concludes, so there is no way currently to achieve this.

Describe the solution you'd like to see

A hook that allows you to modify the span in terms of attributes after the request succeeded or failed.

Describe alternatives you've considered

Additional context

new UndiciInstrumentation({
        requestHook: (span, request) => {
          span.setAttribute(
            'http.host',
            span.attributes['server.address'] +
              ':' +
              span.attributes['server.port']
          )
          span.setAttribute(
            'http.method',
            span.attributes['http.request.method']
          )
          span.setAttribute(
            'http.target',
            span.attributes['url.path'] + span.attributes['url.query']
          )
          span.setAttribute('http.url', span.attributes['url.full'])
          
          // http.response.status_code does not exist yet
          span.setAttribute(
            'http.status_code',
            parseInt(span.attributes['http.response.status_code'])
          )
        },
      })
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 a pull request may close this issue.

1 participant