refactor: Updated instrumentation for http, undici, grpc to use a new segment.captureExternalAttributes
to centralize the necessary data needed to create segment and span attributes
#2179
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.
Description
This PR adds a new method to TraceSegment called
captureExternalAttributes
. I tried to do more with reducing the number of times we parse a url and actually swap it out fornew URL
but the signatures do not contain an absolute URL or even all the parts to construct it in http-outbound instrumentation. I also found when reviewing #2169 that in the streaming span events we weren't properly removing the attributes that get translated when applied from segment. This cleans that up and adds necessary assertions. Lastly, grpc instrumentation was defining the translated attributes likehttp.url
,http.method
directly on segment. Since this instrumentation was updated to use the newcaptureExternalAttributes
it'll assign the appropriate attributes on segment and then propagate to span where applicable.Oh yea, and I also removed
captureDBInstanceAttributes
from TraceSegment. It was only used in tests and duplicate logic from the DatastoreShim. My guess is the code that was removed came first and when shim was a thing it was never updated.Related Issues
Closes #2177