-
Notifications
You must be signed in to change notification settings - Fork 792
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
feat: improve http span name #3603
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0b164f4
feat: improve http span name
Flarna 786f392
Update experimental/CHANGELOG.md
Flarna f325e76
Merge branch 'main' into http-name
Flarna 74f7a25
Merge branch 'main' into http-name
Flarna cde2c6e
improve changelog
Flarna ac99ffc
Merge branch 'main' into http-name
Flarna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ import { | |
} from '@opentelemetry/instrumentation'; | ||
import { RPCMetadata, RPCType, setRPCMetadata } from '@opentelemetry/core'; | ||
import { errorMonitor } from 'events'; | ||
import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; | ||
|
||
/** | ||
* Http instrumentation instrumentation for Opentelemetry | ||
|
@@ -489,11 +490,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> { | |
utils.getIncomingRequestMetricAttributes(spanAttributes); | ||
|
||
const ctx = propagation.extract(ROOT_CONTEXT, headers); | ||
const span = instrumentation._startHttpSpan( | ||
`${component.toLocaleUpperCase()} ${method}`, | ||
spanOptions, | ||
ctx | ||
); | ||
const span = instrumentation._startHttpSpan(method, spanOptions, ctx); | ||
const rpcMetadata: RPCMetadata = { | ||
type: RPCType.HTTP, | ||
span, | ||
|
@@ -622,7 +619,6 @@ export class HttpInstrumentation extends InstrumentationBase<Http> { | |
return original.apply(this, [optionsParsed, ...args]); | ||
} | ||
|
||
const operationName = `${component.toUpperCase()} ${method}`; | ||
const { hostname, port } = utils.extractHostnameAndPort(optionsParsed); | ||
|
||
const attributes = utils.getOutgoingRequestAttributes(optionsParsed, { | ||
|
@@ -643,7 +639,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> { | |
kind: SpanKind.CLIENT, | ||
attributes, | ||
}; | ||
const span = instrumentation._startHttpSpan(operationName, spanOptions); | ||
const span = instrumentation._startHttpSpan(method, spanOptions); | ||
|
||
const parentContext = context.active(); | ||
const requestContext = trace.setSpan(parentContext, span); | ||
|
@@ -717,6 +713,11 @@ export class HttpInstrumentation extends InstrumentationBase<Http> { | |
code: utils.parseResponseStatus(SpanKind.SERVER, response.statusCode), | ||
}); | ||
|
||
const route = attributes[SemanticAttributes.HTTP_ROUTE]; | ||
if (route) { | ||
span.updateName(`${request.method || 'GET'} ${route}`); | ||
} | ||
Comment on lines
+716
to
+719
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. Maybe an entry for this new feature in the changelog as well? 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. done |
||
|
||
if (this._getConfig().applyCustomAttributesOnSpan) { | ||
safeExecuteInTheMiddle( | ||
() => | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is considered a breaking change since any queries by span name will break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was not marked as breaking in spec so why here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyhow, added an entry in breaking changes and adapted wording in feat section