question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There should be a way to disable OpenCensus stats and tracing

See original GitHub issue

Currently, out-of-the-box client and server config includes a very expensive “no-op” in the form of the enabled-by-default opencensus tracing and stats interceptors. This is the case even if no implementation library is on the classpath, and disabling them is difficult/discouraged/impossible (without reflection) depending on the transport.

Benchmark                         (direct)  (statsAndTracing)  (transport)  Mode  Cnt      Score      Error  Units
TransportBenchmark.unaryCall1024      true               true    INPROCESS  avgt   10   3313.595 ±  107.360  ns/op
TransportBenchmark.unaryCall1024      true              false    INPROCESS  avgt   10   2142.610 ±   99.678  ns/op
TransportBenchmark.unaryCall1024      true               true  NETTY_LOCAL  avgt   10  64780.414 ± 1564.422  ns/op
TransportBenchmark.unaryCall1024      true              false  NETTY_LOCAL  avgt   10  60969.867 ± 1447.113  ns/op
TransportBenchmark.unaryCall1024      true               true        NETTY  avgt   10  85561.145 ± 3765.635  ns/op
TransportBenchmark.unaryCall1024      true              false        NETTY  avgt   10  81556.086 ± 2136.174  ns/op
TransportBenchmark.unaryCall1024      true               true  NETTY_EPOLL  avgt   10  79758.331 ± 3005.046  ns/op
TransportBenchmark.unaryCall1024      true              false  NETTY_EPOLL  avgt   10  75667.486 ± 2734.508  ns/op
TransportBenchmark.unaryCall1024      true               true       OKHTTP  avgt   10  74714.350 ± 2848.833  ns/op
TransportBenchmark.unaryCall1024      true              false       OKHTTP  avgt   10  70527.535 ± 2945.292  ns/op

There’s also significantly more garbage produced when enabled.

It would be great to enable these only when the impl library is detected, however:

  • There are circumstances when it might be there but not used
  • It may be the case that only one of stats or tracing is being used
  • Even if it is being used, instrumentation overhead of this magnitude may be considered undesirable (and these numbers are just the api plumbing without any additional cost from the impl itself)

Could these be changed to be disabled by default? I’m unsure why such settings are considered internal when they pertain to external functionality. There’s not much danger of anyone “accidentally” leaving it disabled since it would be immediately apparent that the stats aren’t working but the converse is of course true and I would assume most common.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
zhangkun83commented, Mar 28, 2019

As we revisit the decision to include the OpenCensus into grpc-core, we regret it. That’s why we don’t expose public API to disable it. We are considering moving that of grpc-core and make its own artifact grpc-census. There may be two ways to approach it:

  1. Let the core find classes of grpc-census and load then if available. The user controls whether to have stats/tracing by having or not having grpc-census in their class path.
  2. Ditch dynamic loading, and have a utility class in grpc-census to install interceptors/tracers on the channel/server builders.

Option 1 allows current stats/tracing-dependent users to migrate without any code change. Option 2 is cleaner as it gives the user the maximum control, while it requires code changes to migrate. I personally prefer Option 2 but I am not sure whether the churn brought to users is acceptable. @ejona86 may want to chime in.

1reaction
ejona86commented, Jan 16, 2020

Yes, I think #6577 (not #5510 😄) addressed this. I don’t think all the discussions are done, but the major issue should be addressed now.

Closing. @njhill, if things still don’t look right we can reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Metrics - OpenCensus
In this quickstart, we'll glean insights from code segments and learn how to: Collect metrics using OpenCensus Metrics and Tags; Register and enable...
Read more >
Tracing - OpenCensus
Click Find Traces, and you should see a trace. Click into that, and you should see the details. How does it work? Snippet;...
Read more >
Client - OpenCensus
Traces. Traces can be continued and used simply by passing the context that contains traces into the request that will then be used...
Read more >
Metrics - OpenCensus
In this quickstart, we'll glean insights from code segments and learn how to: Collect metrics using OpenCensus Metrics and Tags; Register and enable...
Read more >
Tracing - OpenCensus
To enable tracing, we'll need to use the OpenCensus C++ library. ... This is how diamond dependencies are prevented. http_archive( name = "com_google_absl", ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found