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

chore: Added otel compliant spans to external http spans #2169

Merged
merged 3 commits into from
Apr 30, 2024

Conversation

mrickard
Copy link
Member

Description

Added OTEL-compliant http.request.method and server.address properties to external HTTP spans.

How to Test

This PR includes additions to test/unit/spans/span-event.test.js and test/unit/spans/streaming-span-event.test.js, so running unit tests will include these.

Related Issues

Closes #2150
Closes NR-260118

jsumners-nr
jsumners-nr previously approved these changes Apr 30, 2024
@jsumners-nr jsumners-nr requested a review from bizob2828 April 30, 2024 11:44
Signed-off-by: mrickard <maurice@mauricerickard.com>
Signed-off-by: mrickard <maurice@mauricerickard.com>
@mrickard mrickard force-pushed the NR-260118/add-http-otel-props branch from ca38dc4 to 297267d Compare April 30, 2024 13:58
@@ -128,6 +128,12 @@ class StreamingSpanEvent {

let span = null
if (StreamingHttpSpanEvent.isHttpSegment(segment)) {
// Get external host from the segment name
const nameParams = segment.name.split('/')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems heavy handed. what i would do is abstract away the assigning of the attributes for http externals, and just add another one there for host. the reason i suggest abstracting is because we have multiple libraries that instrument libraries as http externals. in fact looking into this i think we were doing it wrong in grpc. I can show you a diff of what I'm suggesting

…an, updated span event object to take attributes and make server.address and server.port
@@ -227,6 +235,8 @@ function applySegment(opts, makeRequest, hostname, segment) {
segment.addSpanAttribute(`request.parameters.${key}`, parsed.parameters[key])
}
}
segment.attributes.addAttribute(DESTINATIONS.SPAN_EVENT, 'host', host)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding destination of span event as we don't want these attrs on the segment. the lib/spans/span-event and streaming-span-event will take those and make server.address and server.port. I plan on filling a follow up to encapsulate all the external segment/span attributes into a function on the segment so we can call captureExternalAttributes

@@ -197,8 +197,19 @@ class StreamingHttpSpanEvent extends StreamingSpanEvent {
agentAttributes.url = null
}

if (agentAttributes.host) {
this.addAgentAttribute('server.address', agentAttributes.host)
agentAttributes.host = null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the nullifying of these properties isn't doing what we expect. I will file another ticket to deal with that

@bizob2828 bizob2828 merged commit b0a3e6d into newrelic:main Apr 30, 2024
23 checks passed
bizob2828 pushed a commit that referenced this pull request May 20, 2024
@mrickard mrickard deleted the NR-260118/add-http-otel-props branch August 8, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add otel compliant spans to external http spans
3 participants