-
Notifications
You must be signed in to change notification settings - Fork 867
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
PeerService Resolver #9061
PeerService Resolver #9061
Conversation
4a0db07
to
9ae9082
Compare
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.
Thanks for contributing! Sorry that I had so many comments. I don't think any of them should be particularly challenging to implement.
...test/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolverTest.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
...va/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractor.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
450763e
to
d9faa5e
Compare
Also, as otel.instrumentation.common.peer-service-mapping is defined once for all, the PeerServiceResolver could be Singleton but I don't see how to achieve this. The config is created in javaagent-extension-api and the extractor in instrumentation-api-semconv. Would it be possible to place the PeerServiceResolver class in a way they can both use it ? |
9a8ac32
to
a4d697c
Compare
...va/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractor.java
Outdated
Show resolved
Hide resolved
...va/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractor.java
Outdated
Show resolved
Hide resolved
...va/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractor.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolver.java
Outdated
Show resolved
Hide resolved
if (port != null) { | ||
return port.equals(this.port); | ||
} |
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.
Why is a port
condition here? Isn't this part about the path
?
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.
Yes it is. When the matcher has a path, the tested port need to match the matcher's port. Otherwise with the mapping :
localhost/mypath=myservice
localhost:4859/mypath and localhost:8081/mypath would both be resolved as myservice.
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.
Yeah, but doesn't the
if (port != null) {
return port.equals(this.port);
}
condition above already handle that?
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 checker can have a null port.
The first port checking requires the two ports to match if the checker has a defined port.
When it comes to path checking.
Once the path are matching, then the ports must also be equals.
condition above already handle that?
With the tests I did, it was not enough.
I'm interested if there is a shorter and easier way to ensure that without making port a required attribute.
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'm not sure I get the scenario you're trying to cover.
So, when the mapping is 1.2.3.4/abc -> def
and you pass (1.2.3.4, 8080, /abc)
shouldn't you get def
in return? That extra condition makes it return null
, which does not seem correct to me.
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.
If you have the mapping (1.2.3.4, null, /abc) -> def
but in reality you have (1.2.3.4, 8080, /abc) -> def
and (1.2.3.4, 8081, /abc) -> ghi
, I believe that it's better to return null
so the mapping has to be fixed to have the port provided instead of having a misleading mapping.
You could make the |
b952585
to
e90e5d1
Compare
Signed-off-by: Matthieu MOREL <[email protected]> Co-Authored-By: Trask Stalnaker <[email protected]>
e90e5d1
to
1dd3978
Compare
|
||
String serverAddress = attributesGetter.getServerAddress(request); | ||
Integer serverPort = attributesGetter.getServerPort(request); | ||
String path = getUrlPath(attributesGetter, request); |
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.
what do you think about passing in the
http.url
(and only thehttp.url
) to the PeerServiceResolver? and the PeerServiceResolver could then just check matches directly against thehttp.url
without needing to do any parsing I think
Alternatively, the resolver could accept a Supplier<String>
just for the path parameter, and only lazily evaluate that when host & port match.
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceResolverTest.java
Outdated
Show resolved
Hide resolved
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
...mconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlParserTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Mateusz Rzeszutek <[email protected]>
Hi @trask , @mateuszrzeszutek , |
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.
Approved 👍
@trask there is one more open discussion about the port behavior: #9061 (comment)
Perhaps we should merge this PR and tackle that later?
I just resolved that discussion (sorry, I was having boolean logic failures in my head). I'd still prefer not to add url parsing on the hot path for a feature that most people won't be using, so would prefer if we can implement some kind of lazy evaluation in this PR. I think the @mmorel-35 can you try that out? |
Hi @trask , |
thanks @mmorel-35 ❤️ |
Hi!
Here is a first draft of a Resolver for Peer Services.
For now protocol and path are not wired in
instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractor.java
butPeerServiceResolver
is already able to handle them.What do you think ?
Fixes #9047