jrpc2 icon indicating copy to clipboard operation
jrpc2 copied to clipboard

Support for opentelemetry

Open okhowang opened this issue 2 years ago • 5 comments

refer https://opentelemetry.io/docs/specs/semconv/rpc/json-rpc/

okhowang avatar Sep 20 '23 08:09 okhowang

Can you say more about what you have in mind here?

creachadair avatar Sep 20 '23 16:09 creachadair

OpenTelemetry is a collection of APIs, SDKs, and tools. Use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) to help you analyze your software’s performance and behavior.

go sdk support trace and metric currently. and spec defines some standard attribute in here https://opentelemetry.io/docs/specs/semconv/rpc/json-rpc/

we can add some hook func to export low level data to outer, like go-redis. and make use of it to do tracing

okhowang avatar Sep 21 '23 03:09 okhowang

Where do you imagine these hooks would go? Given that the telemetry metrics are already per request, this seems like something that could be handled by user-defined middleware. It's not clear to me that the library needs any special features to support it.

creachadair avatar Sep 22 '23 04:09 creachadair

this seems like something that could be handled by user-defined middleware.

do you mean wrapping jrpc2.Handler? it's used in server-side.

middleware (or filter) may used in client-side.

okhowang avatar Sep 26 '23 08:09 okhowang

this seems like something that could be handled by user-defined middleware.

do you mean wrapping jrpc2.Handler? it's used in server-side.

middleware (or filter) may used in client-side.

Yes, if the client needs to forward something to the server, it would have to do so by including it in the parameters anyway, since that's the only place the protocol has space for data. On the server side (or in callbacks) one can inject a wrapper that captures those data.

creachadair avatar Sep 27 '23 02:09 creachadair