Skip to content

feat(RpcServer, RpcClient): add span-customization hook #8054

Description

@anatolzak

What is the problem this feature would solve?

Like #8053 for HttpClient, the spans RpcServer and RpcClient create are almost entirely fixed. Today you can only set the span prefix and add static span attributes.

So short of wrapping or reimplementing the transport, none of the following is possible:

  • Set the span kind. It's hardcoded to internal on both sides, so the RPC operation never surfaces as a server/client operation in convention-driven backends (Grafana Cloud) and the HTTP transport span wins instead. There's no way to make RpcServer.GetUser a server span or RpcClient.GetUser a client span.
  • Control the span name beyond the prefix. There's no SpanNameGenerator equivalent (HttpClient has one).
  • Add per-request / per-method attributes. Possible to do on the server with Effect.annotateCurrentSpan but not possible on the client.
  • Set an error-to-span-status policy.

What is the feature you are proposing to solve the problem?

A span-customization hook, symmetric with the HttpClient one in #8053, that receives the span and the rpc/request (and the result on completion) and can set or overwrite any attribute, set the span kind, set the status, and shape the name.

What alternatives have you considered?

  • Patching Effect to set server/client kind on RPC spans instead of internal default

Activity

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions