census-instrumentation / opencensus-java

A stats collection and distributed tracing framework
https://opencensus.io
Apache License 2.0
672 stars 202 forks source link

Open Tracestate API for custom info propagation #1465

Open AlexanderWert opened 6 years ago

AlexanderWert commented 6 years ago

Please answer these questions before submitting a bug report.

What version of OpenCensus are you using?

0.16.1

What JVM are you using (java -version)?

1.8

What did you do?

We are building a monitoring agent based on OpenCensus. Consider the example that service A calls a service B. For the use case of conditional metric reporting (on the recipient side of the request) the monitoring code of the receiver (in this case service B) needs to know who was the caller. This needs to be transparent / generic, as this should not affect the API of the services.

What did you expect to see?

Is there currently a way to propagate additional information together with the trace / span information? I see there is a class "Tracestate" which, however, does not provide a way of adding/writing information through the OpenCensus API. Are there any plans to open the API of Tracestate to allow adding or editing Entries to the Tracestate? Can we help with this by providing a pull request?

Thank you!

Cheers, Alex

songy23 commented 6 years ago

Hi @AlexanderWert

I see there is a class "Tracestate" which, however, does not provide a way of adding/writing information through the OpenCensus API.

Are there any plans to open the API of Tracestate to allow adding or editing Entries to the Tracestate?

Currently we don't support setting Tracestate when building a Span. There's a TODO for adding support for it: https://github.com/census-instrumentation/opencensus-java/blob/52f38e48e2ac6cb65e28dcd97b4f7e9650357bba/impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java#L71

Can we help with this by providing a pull request?

Sure, contributions are very welcome :)

For the use case of conditional metric reporting (on the recipient side of the request) the monitoring code of the receiver (in this case service B) needs to know who was the caller. This needs to be transparent / generic, as this should not affect the API of the services.

Have you considered using Tag propagation? It's a very common use case to propagate caller as a tag on the wire.

falenn commented 5 years ago

@songy23, Like @AlexanderWert, I would like to add custom tracking info to tracestate, however, I'm afraid this would violate the intent of the spec.

I just requested clarification w3c/trace-context#264.

What do you all think?

songy23 commented 5 years ago

As per Yuri's response in https://github.com/w3c/trace-context/issues/264#issuecomment-474858239, tracestate only carries the information on tracing library rather than the applications, so probably adding custom info to it is not an expected use case. /cc @bogdandrutu kindly correct me if I'm wrong.