open-telemetry / opentelemetry-go-contrib

Collection of extensions for OpenTelemetry-Go.
https://opentelemetry.io/
Apache License 2.0
1.15k stars 544 forks source link

otelgin: Using `c.FullPath()` to set `http.route` attribute #5734

Closed NeoCN closed 3 months ago

NeoCN commented 3 months ago

As spanName can be customized with SpanNameFormatter, so the spanName may not be the same with http.route, e.g. the spanName can be GET /users/:id, but the http.route is /users/:id. This PR using c.FullPath() to set http.route attribute in otelgin to keep http.route not affected by SpanNameFormatter.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 63.8%. Comparing base (c932948) to head (b7e90fd).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5734/graphs/tree.svg?width=650&height=150&src=pr&token=P6F3W9WA7Q&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5734?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) ```diff @@ Coverage Diff @@ ## main #5734 +/- ## ===================================== Coverage 63.8% 63.8% ===================================== Files 194 194 Lines 12238 12236 -2 ===================================== - Hits 7818 7817 -1 Misses 4197 4197 + Partials 223 222 -1 ``` | [Files](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5734?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | Coverage Δ | | |---|---|---| | [...ation/github.com/gin-gonic/gin/otelgin/gintrace.go](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5734?src=pr&el=tree&filepath=instrumentation%2Fgithub.com%2Fgin-gonic%2Fgin%2Fotelgin%2Fgintrace.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-aW5zdHJ1bWVudGF0aW9uL2dpdGh1Yi5jb20vZ2luLWdvbmljL2dpbi9vdGVsZ2luL2dpbnRyYWNlLmdv) | `81.1% <100.0%> (+0.8%)` | :arrow_up: |