-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: Emit low-cardinality http.client span names for node:http and undici #23690
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: develop
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ import { | |
| getSanitizedUrlString, | ||
| getSpanStatusFromHttpCode, | ||
| hasSpanStreamingEnabled, | ||
| HTTP_SPAN_NAME_FALLBACK, | ||
| isTracingSuppressed, | ||
| LRUMap, | ||
| parseUrl, | ||
|
|
@@ -49,6 +50,7 @@ import { | |
| SENTRY_OP, | ||
| SERVER_ADDRESS, | ||
| SERVER_PORT, | ||
| URL_DOMAIN, | ||
| URL_FRAGMENT, | ||
| URL_FULL, | ||
| URL_PATH, | ||
|
|
@@ -220,6 +222,7 @@ function onRequestCreated(config: NodeFetchOptions, { request }: RequestMessage) | |
| [HTTP_REQUEST_METHOD]: requestMethod, | ||
| [ATTR_HTTP_REQUEST_METHOD_ORIGINAL]: request.method, | ||
| [URL_FULL]: filterCollectedUrl(requestUrl.toString()), | ||
| [URL_DOMAIN]: requestUrl.hostname || undefined, | ||
| [URL_PATH]: requestUrl.pathname, | ||
| [URL_QUERY]: filterCollectedUrlQuery(getUrlQuery(requestUrl.search)), | ||
| [URL_FRAGMENT]: getUrlFragment(requestUrl.hash), | ||
|
Comment on lines
222
to
228
Contributor
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. Bug: The streaming path for Suggested FixBefore serializing the span for streaming, delete the Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
@@ -262,14 +265,21 @@ function onRequestCreated(config: NodeFetchOptions, { request }: RequestMessage) | |
| // when an OpenTelemetry SDK tracer provider is set up, so we enforce it here too, which covers | ||
| // SDKs that don't use an OpenTelemetry tracer provider at all. | ||
| const isDataUrl = url.startsWith('data:'); | ||
| const spanName = | ||
| requestMethod === '_OTHER' | ||
| ? 'HTTP' | ||
| : isDataUrl | ||
| ? `${request.method || 'GET'} ${stripDataUrlContent(url)}` | ||
| : `${requestMethod} ${getSanitizedUrlString(parseUrl(requestUrl.toString()))}`; | ||
|
|
||
| const client = getClient(); | ||
|
|
||
| let spanName: string; | ||
| if (requestMethod === '_OTHER') { | ||
| spanName = HTTP_SPAN_NAME_FALLBACK; | ||
| } else if (!!client && hasSpanStreamingEnabled(client)) { | ||
| // With span streaming, span names have to be low cardinality, so the URL path is dropped and only | ||
| // the domain is kept. Outgoing requests have no route to parameterize, and data URLs have no domain. | ||
| spanName = requestUrl.hostname ? `${requestMethod} ${requestUrl.hostname}` : requestMethod; | ||
| } else if (isDataUrl) { | ||
| spanName = `${request.method || 'GET'} ${stripDataUrlContent(url)}`; | ||
| } else { | ||
| spanName = `${requestMethod} ${getSanitizedUrlString(parseUrl(requestUrl.toString()))}`; | ||
| } | ||
|
|
||
| const span = startInactiveSpan({ | ||
| name: spanName, | ||
| attributes, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.