-
Notifications
You must be signed in to change notification settings - Fork 836
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(instrumentation-grpc): set net.peer.name and net.peer.port on client spans #3430
feat(instrumentation-grpc): set net.peer.name and net.peer.port on client spans #3430
Conversation
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.
could you add a test for this ?
23aedb3
to
2e48472
Compare
@vmarchaud, absolutely! unit tests added. |
2e48472
to
0880262
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3430 +/- ##
==========================================
+ Coverage 93.75% 93.77% +0.02%
==========================================
Files 248 248
Lines 7552 7561 +9
Branches 1576 1578 +2
==========================================
+ Hits 7080 7090 +10
+ Misses 472 471 -1
|
4d65da9
to
d341bbe
Compare
added CHANGELOG addition, fixed lint error |
@@ -306,6 +306,11 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< | |||
[SemanticAttributes.RPC_METHOD]: method, | |||
[SemanticAttributes.RPC_SERVICE]: service, | |||
}); | |||
// set peer.service from target (e.g., "dns:otel-productcatalogservice:8080") as a hint to APMs | |||
const parsedUri = URI_REGEX.exec(this.getChannel().getTarget()); |
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.
The specification defines that peer.service
:
SHOULD be equal to the actual
service.name
resource attribute of the remote service if any.
Channel#getTarget
returns the address that this client is connected to, rather than the desired service.name
.
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.
haha - I agree! I was looking at values in flight from some service which happen to set it to host:port. I'll adjust. Thank you for the reference.
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.
Lemme see how other auto-instrumentation frameworks set this.
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.
@legendecas - ok, I've change this to set net.peer.name and net.peer.port per OTEL RPC conventions.
Per this, we always set net.peer.name regardless of whether is a DNS name or IP: "Sometimes host name is only available to instrumentation as a string which may contain DNS name or IP address. net.peer.name SHOULD be set to the available known hostname (e.g., "127.0.0.1" if connecting to an URL https://127.0.0.1.com/foo)."
d341bbe
to
067caa9
Compare
067caa9
to
6f46a77
Compare
@ty-elastic Could you rebase and fix conflicts please ? |
fcaee74
to
f076625
Compare
@vmarchaud, rebased, conflicts resolved. thx! |
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.
Thank you for working on this!
To fix the linter complaints, you can run npm run lint:fix
in experimental/packages/opentelemetry-instrumentation-grpc
.
f076625
to
592b13a
Compare
592b13a
to
dd37c6e
Compare
@legendecas , my pleasure! linted... thanks! |
Which problem is this PR solving?
Set net.peer.name and net.peer.port span attribute on gRPC client spans as a hint to APMs to look for service dependencies. This is a requirement of OTEL gRPC span conventions.
Fixes #3429
Short description of the changes
Type of change
How Has This Been Tested?
Checklist: