-
Notifications
You must be signed in to change notification settings - Fork 160
Add http.route attribute and update span name from Plug router #621
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
15a197c
c0df875
3bf3271
98285ae
4420180
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,8 +239,8 @@ defmodule OpentelemetryBandit do | |
|
|
||
| name = | ||
| if request_method == HTTPAttributes.http_request_method_values().other, | ||
| do: :HTTP, | ||
| else: request_method | ||
| do: "HTTP", | ||
| else: conn.method | ||
|
|
||
| if public_endpoint?(conn, config) do | ||
| propagated_ctx = | ||
|
|
@@ -264,7 +264,7 @@ defmodule OpentelemetryBandit do | |
|
|
||
| # error with no conn | ||
| def handle_request_start(_meta, _config) do | ||
| Tracer.start_span(:HTTP, %{kind: :server}) | ||
| Tracer.start_span("HTTP", %{kind: :server}) | ||
| |> Tracer.set_current_span() | ||
| end | ||
|
|
||
|
|
@@ -468,10 +468,29 @@ defmodule OpentelemetryBandit do | |
| |> Tracer.set_attributes() | ||
| end | ||
|
|
||
| maybe_update_span_name(conn) | ||
|
lunks marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This couldn't be moved to the start event?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. We only have the URL path, not the route name.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tsloughter I am gonna defer to you, I am not sure if changing midway the span name is a major concern or not
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you folks think there's a better approach to accomplish a similar result, let me know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry. This is fine. |
||
|
|
||
| Tracer.end_span() | ||
| Ctx.clear() | ||
| end | ||
|
|
||
| defp maybe_update_span_name(conn) do | ||
| case conn.private do | ||
| %{plug_route: {route, _fun}} -> | ||
|
lunks marked this conversation as resolved.
|
||
| method = sanitize_method(conn.method) | ||
| Tracer.update_name("#{method} #{route}") | ||
|
lunks marked this conversation as resolved.
|
||
|
|
||
| _ -> | ||
| :ok | ||
| end | ||
| end | ||
|
|
||
| defp sanitize_method(method) do | ||
| if parse_method(method) == HTTPAttributes.http_request_method_values().other, | ||
| do: "HTTP", | ||
| else: method | ||
| end | ||
|
|
||
| @doc false | ||
| def handle_request_exception(meta, config) do | ||
| Tracer.set_status(OpenTelemetry.status(:error, "")) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.