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

Instrumenter API improvements #2860

Conversation

mateuszrzeszutek
Copy link
Member

  • Move HTTP & net classes to separate packages
  • Remove db prefix from method names in DbAttributesExtractor
  • Add request-only net attributes extractor (it'll be needed in spring-sleuth-otel once we decide to use Instrumenters there)

* network peer information. If those attributes are available in the request, it is recommended to
* use {@link InetSocketAddressNetAttributesExtractor} instead.
*/
public abstract class InetSocketAddressNetRequestAttributesExtractor<REQUEST, RESPONSE>
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't realize this would be needed already :)

I have considered an approach where there is only one extractor, and @Nullable RESPONSE response - if it's available when response is null (onStart), then it's gotten from request, otherwise gotten when response isn't null (onEnd). The advantage of two classes is it's easier to implement them. The disadvantage is having cognitive load deciding which class to use. I think I'm leaning towards the separate classes actually but wanted to get your thoughts too.

@@ -26,10 +31,6 @@ protected final void onStart(AttributesBuilder attributes, REQUEST request) {
@Override
protected final void onEnd(AttributesBuilder attributes, REQUEST request, RESPONSE response) {
set(attributes, SemanticAttributes.NET_PEER_IP, peerIp(request, response));

// TODO(anuraaga): Clients don't have peer information available during the request usually.
Copy link
Contributor

Choose a reason for hiding this comment

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

But related to my above comment, actually this isn't quite solved since it means instrumentation defining separate ServerNetAttributesExtractor and ClientNetAttributesExtractor, which our pattern doesn't really support since it makes instrumentation more complex. The approach with @Nullable RESPONSE response could solve it though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've refactored the NetAttributesExtractor class so that it has a @Nullable response in its attribute methods.

Mateusz Rzeszutek added 3 commits April 29, 2021 08:43
* Move HTTP & net classes to separate packages
* Remove `db` prefix from method names in `DbAttributesExtractor`
* Add request-only net attributes extractor (it'll be needed in spring-sleuth-otel once we decide to use Instrumenters there)
@mateuszrzeszutek mateuszrzeszutek force-pushed the refactor-existing-instrumenter-api-parts branch from c729d58 to 6e8ddcf Compare April 29, 2021 06:43
Comment on lines +35 to +38
String route = attributesExtractor.route(request);
if (route != null) {
return route;
}
Copy link
Member

Choose a reason for hiding this comment

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

👍

Mateusz Rzeszutek and others added 2 commits May 4, 2021 09:22
@mateuszrzeszutek mateuszrzeszutek merged commit c9a3793 into open-telemetry:main May 6, 2021
@mateuszrzeszutek mateuszrzeszutek deleted the refactor-existing-instrumenter-api-parts branch May 6, 2021 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants