Include exemplars in OpenCensus instrumentation
- Dominant language
- Java
- Stars
- 12.1k
- Forks
- 4k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 37
Description
### Is your feature request related to a problem?
The OpenCensus GRPC instrumentation does not attach [exemplar](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TypedValue#exemplar) spans along with the distribution stats it collects.
> Exemplars are example points that may be used to annotate aggregated distribution values. They are metadata that gives information about a particular value added to a Distribution bucket, such as a trace ID that was active when a value was added. They may contain further information, such as a example values and timestamps, origin, etc.
Google cloud monitoring can interpret and display these exemplars to link metrics to example spans.
### Describe the solution you'd like
Add exemplars to grcp-census instrumentation directly near this code: https://github.com/grpc/grpc-java/blob/020325617129b6ae9b25da1126ba0f98b044bb1b/census/src/main/java/io/grpc/census/CensusStatsModule.java#L647
Adding something like this should work:
```java
ExemplarUtils.putSpanContextAttachments(measureMap, tracer.getCurrentSpan().getContext());
```
### Describe alternatives you've considered
I don't think there is a way to do this without updating the grpc-census instrumentation code. AFAIK adding the exemplar to the `MeasureMap` directly is the only way to do it.
### Additional context
I'm not sure how to get the OpenCensus Tracer for `tracer.getCurrentSpan()` inside of `CensusStatsModule`. It may also be beneficial to check if the current span is being sampled before attaching it to the `MeasureMap`.
cc @nilebox
Contributor guide
Assessment
This issue has not been assessed yet.