opencensus-java icon indicating copy to clipboard operation
opencensus-java copied to clipboard

Provide a way to determine whether tags, stats, or trace classes are no-op implementations.

Open sebright2 opened this issue 8 years ago • 7 comments

The no-op implementations can often be used to avoid unnecessary if statements, but it is important to be able to check whether they are no-op when necessary.

See https://github.com/census-instrumentation/opencensus-java/issues/215#issuecomment-296304442

sebright2 avatar Sep 05 '17 21:09 sebright2

This probably should apply to all.

bogdandrutu avatar Sep 05 '17 22:09 bogdandrutu

This probably should apply to all.

I'm not sure I understand. Do you mean all of stats, tags, and tracing, or all classes?

sebright2 avatar Sep 05 '17 23:09 sebright2

#659 adds a getState method to Tags and TagsComponent.

sebright2 avatar Sep 22 '17 01:09 sebright2

Even if we have getState and setState methods, users may want to be able to check whether setState(ENABLED) will be ignored. See the discussions in #659 and #673.

sebright2 avatar Sep 26 '17 18:09 sebright2

@bogdandrutu Do you have any examples of use cases where users would want to distinguish between the no-op implementation and functionality turned off programmatically?

sebright2 avatar Sep 29 '17 22:09 sebright2

One use case for checking whether the implementation is available is performance optimizations that rely on stats, tagging, and tracing never being turned on at runtime. For example, @zhangkun83 mentioned that gRPC could skip initializing the CensusStatsModule if there was no implementation.

sebright2 avatar Nov 02 '17 19:11 sebright2

Another use case is allowing libraries that depend on OpenCensus functionality to report a more specific error when an implementation isn't available.

sebright2 avatar Nov 03 '17 00:11 sebright2