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

Allow to mark REST-Client code as failure #35

Open
1 task
pilhuhn opened this issue Aug 1, 2022 · 3 comments
Open
1 task

Allow to mark REST-Client code as failure #35

pilhuhn opened this issue Aug 1, 2022 · 3 comments
Assignees
Milestone

Comments

@pilhuhn
Copy link

pilhuhn commented Aug 1, 2022

Description

As a:

  • [ X] Application user
  • Specification implementer

...I need to be able to:

Mark an interface for a rest-client so that certain return codes trigger marking the span as failed

Something like

@WithSpan(errorOn={4xx,5xx})
@GET
@Path("/access/") // trailing slash is required by api
@Consumes("application/json")
@Produces("application/json")
RbacRaw getRbacInfo(@QueryParam("application") String application,...)

and then in the interceptor code do

 Span span = SpanBuilder.startNew()
  try {
      statusCode = doRemoteCall();   
      if (statusCode matches withSpan.errorOn) {
          span.setStatus(StatusCode.ERROR);
      }
  } catch (Exception e) {
       span.setStatus(StatusCode.ERROR);
       span.recordException(e);
  } finally {
       span.end();
 }

...which enables me to: Get non-behaving remote client calls into the trace without manually wrap all the remote client calls into the mentioned code manually.

@pilhuhn
Copy link
Author

pilhuhn commented Aug 1, 2022

As @WithSpan is part of OTel, we should probably use a different annotation (MP-specific) for the errorOn attribute.

@brunobat
Copy link
Contributor

brunobat commented Aug 2, 2022

Hi Heiko,
The OTel spec has the concept of Sampler, to drop spans that are not needed. This use case seems to fit it.
I don't think there is the need for a specific annotation. The rest-client spec can potentially be updated to include one of these filters.
See an example:
https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/examples/extension/src/main/java/com/example/javaagent/DemoSampler.java

@Emily-Jiang
Copy link
Member

@Azquelt will take a further look at this.

@Emily-Jiang Emily-Jiang added this to the 2.0 milestone Sep 4, 2023
@Emily-Jiang Emily-Jiang modified the milestones: 2.0 , Next Jun 3, 2024
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

No branches or pull requests

4 participants