Skip to content

Add "cancelled" information to the GrpcServerObservationContext #5301

Closed

Description

@JordiMartinezVicent

Derived from the comment #5109 (comment)

When creating a Grpc Server metric, we would like to know either the request has been cancelled or not. Currently an observation event is generated, but this information is lost for the Grpc Server timer metric.

It would be nice the both approaches which @jonatan-ivanov at the comment:

  • Add the information to the context so we can use it at custom ObservationFilter, ObservationHandler or GrpcServerObservationConvention
  • Add the information as a low cardinality key-value so we can differentiate which resquests have been cancelled.

Something similar to this commit would be nice: ttddyy@53313ef but I do not know why it was discarded.

Activity

  1. shakuzen commented on Jul 16, 2024

    @shakuzen
    Member

    Thank you for opening the issue and giving feedback on the approach taken to resolve #5109.

    Adding the info to the context sounds like an easy thing to do with little concern for effects on other things. Whether to add a low cardinality key-value I think warrants some additional discussion to understand the need and what's missing currently.

    Something similar to this commit would be nice: ttddyy@53313ef but I do not know why it was discarded.

    There was some offline discussion about which approach to take (event vs tag). It sounds like you have a valuable perspective that would have contributed to the discussion. In general, tags that have a boolean value (or rather some string representation of a boolean value) are a bit of a smell, in my opinion. It would be ideal to encode such information in an otherwise meaningful tag such as the status code tag. However, I see from #5109 (comment) we couldn't go that direction because there is a status code irrespective of the cancelled status. I lack experience with grpc but I see from https://grpc.github.io/grpc/core/md_doc_statuscodes.html that there is a CANCELLED status, and the second table indicates it should be used on both the client and server side. Can someone help me understand the original issue why this isn't happening with our instrumentation? /cc @ttddyy

  2. JordiMartinezVicent commented on Jul 16, 2024

    @JordiMartinezVicent
    Author

    Adding the info to the context sounds like an easy thing to do with little concern for effects on other things.

    Yes! It would be nice having that information independently of whether or not having the "cancelled" information as low cardinality key-value.

    I do not know why grpc does not set the status as CANCELLED, in my opinion it would have sense. Having said that, we internally change the status in order to have this information in our metrics. Having the info at the context, would have our logic quite more easy.

  3. shakuzen commented on Aug 9, 2024

    @shakuzen
    Member

    @ttddyy would you happen to have any spare time to look at this?

  4. added
    enhancement
    module: micrometer-core
    instrumentation
    on Sep 4, 2024
  5. added this to the 1.14.0-M3 milestone on Sep 4, 2024
  6. added a commit that references this issue on Sep 4, 2024
    a720efd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementinstrumentationmodule: micrometer-core

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions