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

Set custom gRPC client/server span name extractor #5244

Merged
merged 8 commits into from
Feb 24, 2022
Merged

Set custom gRPC client/server span name extractor #5244

merged 8 commits into from
Feb 24, 2022

Conversation

eugeniyk
Copy link
Contributor

@eugeniyk eugeniyk commented Jan 26, 2022

Typical use case - set short operation name instead of full description name

@eugeniyk eugeniyk requested a review from a team January 26, 2022 15:57
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 26, 2022

CLA Signed

The committers are authorized under a signed CLA.

/** Sets the {@code peer.service} attribute for http client spans. */
public void setPeerService(String peerService) {
public GrpcTracingBuilder setPeerService(String peerService) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing existing builder method

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

would like @mateuszrzeszutek or @anuraaga's review

* Sets custom client {@link SpanNameExtractor}
*/
public GrpcTracingBuilder setClientSpanNameExtractor(
SpanNameExtractor<? super GrpcRequest> clientSpanNameExtractor) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of just passing the SpanNameExtractor, WDYT about passing a Function<SpanNameExtractor<GrpcRequest>, ? extends SpanNameExtractor<? super GrpcRequest>>? (similar to how the Armeria instrumentation allows modifying the SpanStatusExtractor)
With a transformer function you can still make use of the original span name extractors - or reject them altogether and return your own, if you wish to do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds interesting
Chaining status code transformations makes more sense imo than extracting span name (which is a string, doubt you'd like to have pattern matching on it)

Or what's the use case you have in mind? One could be if length is more that X use shorter version of method name; since default impl is pretty straight forward I'd stick to the current version, + it gives api consistency with other methods

Copy link
Member

Choose a reason for hiding this comment

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

Or what's the use case you have in mind? One could be if length is more that X use shorter version of method name;

That's one option. I was thinking of a case where you might decide to fall back on the default naming scheme based on the request, e.g. (request) -> shouldRename(request) ? customName(request) : originalSpanNameExtractor.extract(request)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@trask what do you think? current way as api consistency vs suggested flexibility?

I'm ok with both

Copy link
Member

Choose a reason for hiding this comment

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

let's go with @mateuszrzeszutek's proposal, thx!

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

thx @eugeniyk!

if you merge main into your branch one more time, it should clear up the windows smoke test failures (#5388)

@laurit laurit merged commit bf16564 into open-telemetry:main Feb 24, 2022
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
* Set custom gRPC client/server span name extractor

* Fix imports

* Fix compilation

* Fix style rule

* Update to use Functions instead

* Fix formatting
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.

4 participants