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

Annotations to inject and extract data with auto-instrumentation #9128

Closed
SimoneGiusso opened this issue Jul 24, 2023 · 10 comments
Closed

Annotations to inject and extract data with auto-instrumentation #9128

SimoneGiusso opened this issue Jul 24, 2023 · 10 comments
Labels
enhancement New feature or request needs author feedback Waiting for additional feedback from the author stale

Comments

@SimoneGiusso
Copy link
Contributor

Is your feature request related to a problem? Please describe.

  • Tell Auto-instrumentation to add attribute to current active span
  • Tell Auto-instrumentation to extract attribute from current span

Describe the solution you'd like

    // when calling this method the parameter1 and parameter2 are added to the current span
    @WithCurrentSpan
    public void myMethod(@SpanAttribute("parameter1") String parameter1,
        @SpanAttribute("parameter2") long parameter2) {
        <...>
    }

    // when calling this method the parameter1 is returned
    @WithCurrentSpan
    public String myMethod(@SpanAttribute("parameter1") String parameter1) {
        return paramter1;
    }

Describe alternatives you've considered
Use manual instrumentation.

@trask
Copy link
Member

trask commented Jul 24, 2023

hi @SimoneGiusso!

    // when calling this method the parameter1 and parameter2 are added to the current span
    @WithCurrentSpan
    public void myMethod(@SpanAttribute("parameter1") String parameter1,
        @SpanAttribute("parameter2") long parameter2) {
        <...>
    }

check out #7787

    // when calling this method the parameter1 is returned
    @WithCurrentSpan
    public String myMethod(@SpanAttribute("parameter1") String parameter1) {
        return paramter1;
    }

Can you clarify this example? Wouldn't this capture the value of the method arg into the span attribute named parameter1 (similar to above example)?

@SimoneGiusso
Copy link
Contributor Author

Hello indeed @SpanAttributesAnnotations seems already full filled the first thing I asked (my bad, I didn't see in the doc and I didn't checked the project).

For the second case, basically I would like to capture and use the data propagated within the trace. I think the only way to do it for now is with to use the OpenTelemetry API. In other words a way to let service 2 read the attribute service one sent with @SpanAttributesAnnotations.

@trask
Copy link
Member

trask commented Jul 26, 2023

For the second case, basically I would like to capture and use the data propagated within the trace. I think the only way to do it for now is with to use the OpenTelemetry API.

can you clarify, maybe with some psuedo code, how you would do this today with the OpenTelemetry API?

@jkwatson
Copy link
Contributor

jkwatson commented Aug 2, 2023

moving this issue to the instrumentation repository...

@jkwatson jkwatson transferred this issue from open-telemetry/opentelemetry-java Aug 2, 2023
@mateuszrzeszutek
Copy link
Member

ping @SimoneGiusso

can you clarify, maybe with some psuedo code, how you would do this today with the OpenTelemetry API?

@mateuszrzeszutek mateuszrzeszutek added enhancement New feature or request needs author feedback Waiting for additional feedback from the author and removed Feature Request labels Aug 3, 2023
@SimoneGiusso
Copy link
Contributor Author

can you clarify, maybe with some psuedo code, how you would do this today with the OpenTelemetry API?

I think the only way to achieve context propagation with the OpenTelemetry API is as explained in the doc and use the TextMapPropagator.

What I would like to have is an API similar to OpenTracing to propagate the context:

# client side
span.context.set_baggage_item('auth-token', '.....')

# server side (one or more levels down from the client)
token = span.context.get_baggage_item('auth-token')

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label Aug 3, 2023
@laurit
Copy link
Contributor

laurit commented Aug 9, 2023

@SimoneGiusso opentelemetry also has baggage api.

// on client
Baggage baggage = Baggage.builder().put("key", "value").build();
try (Scope ignore = baggage.makeCurrent()) {
  // call the server      
}

// on server
String value = Baggage.current().getEntryValue("key");

@laurit laurit added the needs author feedback Waiting for additional feedback from the author label Aug 9, 2023
@mateuszrzeszutek
Copy link
Member

@SimoneGiusso as discussed in open-telemetry/opentelemetry-java#5651, OTel baggage API is simply different from OpenTracing. It's not possible to 1:1 map OpenTracing to OTel, you have to restructure your code.

@SimoneGiusso
Copy link
Contributor Author

@SimoneGiusso as discussed in open-telemetry/opentelemetry-java#5651, OTel baggage API is simply different from OpenTracing. It's not possible to 1:1 map OpenTracing to OTel, you have to restructure your code.

I'll try to restructure the code since where I set the baggage I don't make the call to the server.

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label Aug 9, 2023
@trask trask added the needs author feedback Waiting for additional feedback from the author label Sep 4, 2023
@github-actions
Copy link
Contributor

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment.

@github-actions github-actions bot added the stale label Sep 11, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs author feedback Waiting for additional feedback from the author stale
Projects
None yet
Development

No branches or pull requests

5 participants