Skip to content

ObservationGrpcServerCallListener does not capture an uncontrolled error during the execution of the service logic #4490

Closed

Description

@ceremo

The ObservationGrpcServerCallListener currently does not inform to the Observation object when an uncontrolled error occurs during the execution of the gRPC service logic. The current behavior does not allow to determine if an exception ocurred, so the generated metric cannot report accurately if the gRPC service failed.

In our gRPC services, errors can be generated as signals (next, completed, error...), but they can also occur as uncontrolled errors during service execution. What are your thoughts about this?

Activity

  1. ceremo commented on Dec 15, 2023

    @ceremo
    Author
  2. marcingrzejszczak commented on Dec 28, 2023

    @marcingrzejszczak
    Contributor

    Do you have an example that replicates this problem so that we can look into it?

  3. added
    waiting for feedback
    on Dec 28, 2023
  4. github-actions commented on Jan 5, 2024

    @github-actions

    If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

  5. ceremo commented on Jan 10, 2024

    @ceremo
    Author

    No, but you only have to check the behaviour of the method onHalfClose defined in ObservationGrpcServerCallListener, when the grpc server fails with an unexpected error, the exception is captured but it does not pass the error to the observation:

      public void onHalfClose() {
            try (Scope scope = observation.openScope()) {
                super.onHalfClose();
            }
        }
    

    Thxs for your time.

  6. marcingrzejszczak commented on Jan 10, 2024

    @marcingrzejszczak
    Contributor

    @ttddyy so we would have to do this change and it will capture the exception?

    From

    public void onHalfClose() {
            try (Scope scope = observation.openScope()) {
                super.onHalfClose();
            }
        }

    To

    public void onHalfClose() {
            observation.scoped( () -> super.onHalfClose() );
        }
  7. removed
    waiting for feedback
    on Jan 10, 2024
  8. ttddyy commented on Jan 14, 2024

    @ttddyy
    Contributor

    Sorry for the late reply.
    Yes, wrapping with scoped sounds good to me.

  9. marcingrzejszczak commented on Jan 15, 2024

    @marcingrzejszczak
    Contributor

    @ceremo are you willing to this change? It's pretty straight-forward :)

  10. added a commit that references this issue on Jan 16, 2024
    34f993c
  11. added this to the 1.12.3 milestone on Jan 16, 2024
  12. ceremo commented on Jan 23, 2024

    @ceremo
    Author

    Thanks @marcingrzejszczak. I would like your opinion in two improvements about the behaviour of the grpc observation:

    • ObservationGrpcServerInterceptor does not allow to customize the Supplier<GrpcServerObservationContext>, this could be useful in order to add extra information to the context.
    • DefaultGrpcServerObservationConvention only receives the metadata of the request, it would be useful to get the metadata of the response on the close execution, to do that the ObservationGrpcServerCall should set in the context the response metadata, like the status:
      @Override
      public void close(final Status status, final Metadata trailers) {
        if (status.getCause() != null) {
          this.observation.error(status.getCause());
        }
    
        final GrpcServerObservationContext context = (GrpcServerObservationContext) this.observation.getContext();
        context.setStatusCode(status.getCode());
        context.setCarrier(trailers); // HERE THE IMPROVEMENT
        super.close(status, trailers);
      }
    

    Thanks for your time.

  13. marcingrzejszczak commented on Jan 23, 2024

    @marcingrzejszczak
    Contributor

    ObservationGrpcServerInterceptor does not allow to customize the Supplier, this could be useful in order to add extra information to the context.

    The ObservationConvention mechanism should be used to add extra information.

    DefaultGrpcServerObservationConvention only receives the metadata of the request, it would be useful to get the metadata of the response on the close execution, to do that the ObservationGrpcServerCall should set in the context the response metadata, like the status:

    We already are doing this.

  14. ceremo commented on Jan 23, 2024

    @ceremo
    Author

    The ObservationConvention mechanism should be used to add extra information.

    Sorry, I don't get it, the ObservationConvention already receives the context fulfilled, and it is the grpc interceptor that is fullfilling it.

  15. marcingrzejszczak commented on Jan 23, 2024

    @marcingrzejszczak
    Contributor

    You said that you want to add extra information to the context. What information exactly? Are you saying that you're missing some objects that the convention could later reuse ? Cause I understood that assuming that all the information got already provided you wanted to add more tags on the context in which case the ObservationConvention would be the way to go.

  16. ceremo commented on Jan 23, 2024

    @ceremo
    Author

    We need to include additional information to the GrpcServerObservationContext in order to convert it into additional tags in the generated metric. That extra information is included in the Metadata, so to include that in the context I have to define my own ObservationGrpcServerInterceptor because this does not allow customizing the contextSupplier. Finally the ObservationConvention load that additional information to include it as new tags.

    What I'm trying to say it that allowing to customize the supplier context defined in the interceptor will facilitate our case, and could be useful to have it.

  17. marcingrzejszczak commented on Jan 23, 2024

    @marcingrzejszczak
    Contributor

    It would be better IMO to prepare the context accordingly. If you think we're missing things in the context please file a PR that adds this data to the existing context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions