Skip to content

How to access rpc.system from connect.WithRecover callback #816

Open
@mattdowdell

Description

Is your feature request related to a problem? Please describe.
I've created a metric that counts the number of panics that occur in my handlers. I've aimed to align with the [OpenTelemetry Semantic Conventions for RPC Metrics], using the recommended attributes of rpc.service and rpc.method. For completeness, I would like to also include the required rpc.system, but see no obvious way to obtain this information from what is made available in connect.WithRecover.

I can see in otelconnect that rpc.system is derived from connect.AnyRequest.Peer().Protocol (see https://github.com/connectrpc/otelconnect-go/blob/v0.7.1/interceptor.go#L101), but the peer is not included the parameters provided by connect.WithRecover.

Describe the solution you'd like
Consider extending the information made available in connect.WithRecover to fully mirror the values accessible to otelconnect.Interceptor.

Describe alternatives you've considered
None at this time

Additional context
N/A


On a semi-related note, I've observed that the recover interceptor is a little awkward to compose with other interceptors. For example, I might want to add otelconnect, then recover, then validate, etc. such that I always have observability, but also have some panic protection for as many interceptors as possible. This ordering appears possible if you group interceptors by those that should be applied before and after the recover interceptor. But realising that required a bit of digging into how interceptors are chained together.

One way out of this small issue might be to make the recover interceptor public. Alternatively, one might expose the interceptor via WithRecoverInterceptor and WithRecover becomes WithInterceptors(WithRecoverInterceptor(handle)).

Activity

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

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions