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

Set http.route attribute as path template #149

Merged

Conversation

StevenPJ
Copy link
Contributor

We have seen issues with the current spans exported from the http
library in observability backends, due to too granular span names when
the routes contain path variables.

As per the opentelemetry specification, this PR extracts the path
template from the UriRouteMatch object, and sets it as the
http.route attribute.

https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/http/#http-server-semantic-conventions

We have seen issues with the current spans exported from the http
library in observability backends, due to too granular span names when
the routes contain path variables.

As per the opentelemetry specification, this PR extracts the path
template from the UriRouteMatch object, and sets it as the
`http.route` attribute.

https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/http/#http-server-semantic-conventions
@StevenPJ
Copy link
Contributor Author

appreciate any feedback @sdelamo

@sdelamo sdelamo requested a review from n0tl3ss September 6, 2022 10:15
…opentelemetry/instrument/http/server/MicronautHttpServerAttributesGetter.java
@altro3
Copy link
Contributor

altro3 commented Oct 13, 2022

@StevenPJ Hi! Could youresolve conflicts?

@n0tl3ss n0tl3ss merged commit eac6ff7 into micronaut-projects:master Oct 14, 2022
@StevenPJ StevenPJ deleted the use_route_template_for_spans branch November 24, 2022 14:49
n0tl3ss added a commit that referenced this pull request Jan 30, 2023
* Set http.route attribute as path template

We have seen issues with the current spans exported from the http
library in observability backends, due to too granular span names when
the routes contain path variables.

As per the opentelemetry specification, this PR extracts the path
template from the UriRouteMatch object, and sets it as the
`http.route` attribute.

https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/http/#http-server-semantic-conventions

* Update tracing-opentelemetry-http/src/main/java/io/micronaut/tracing/opentelemetry/instrument/http/server/MicronautHttpServerAttributesGetter.java

Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>
Co-authored-by: Nemanja Mikic <nemanja.mikic@oracle.com>
n0tl3ss added a commit that referenced this pull request Jan 31, 2023
* User route template as OpenTelemetry HTTP route (#182)

* Remove unused import

* Verify 404 not found still has route path returned

* Set status code in doOnNext

* Update tracing-opentelemetry-http/src/main/java/io/micronaut/tracing/opentelemetry/instrument/http/server/OpenTelemetryServerFilter.java

Co-authored-by: Nemanja Mikic <n0t_l3ss@outlook.com>

* Set http.route attribute as path template (#149)

We have seen issues with the current spans exported from the http
library in observability backends, due to too granular span names when
the routes contain path variables.

As per the opentelemetry specification, this PR extracts the path
template from the UriRouteMatch object, and sets it as the
`http.route` attribute.

https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/http/#http-server-semantic-conventions

* Update tracing-opentelemetry-http/src/main/java/io/micronaut/tracing/opentelemetry/instrument/http/server/MicronautHttpServerAttributesGetter.java

Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>
Co-authored-by: Nemanja Mikic <nemanja.mikic@oracle.com>

* Update common files (#175)

* fix build (#233)

---------

Co-authored-by: Xiaochao Yang <xy@zira.ai>
Co-authored-by: StevenPJ <spalmerjones@gmail.com>
Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>
Co-authored-by: micronaut-build <65172877+micronaut-build@users.noreply.github.com>
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.

4 participants