I haven’t used opencensus myself before, so I’d recommend asking this question again in their forums or chat channels. They might know a configuration to help you out.
If you don’t mind running an additional component in between your application and Tempo, you can setup a tracing pipeline with the OpenTelemetry Collector.
It’s possible to run the probabilistic sampler processor between the receiver and the exporter. If you set the sampling percentage at
0 this will drop all traces.
This would allow you to control this in a central place.
Your config would look something like this:
sampling_percentage: 100 # set this to 0 to drop all traces
endpoint: tempo:9411 # replace with your endpoint, you could also export traces using OTLP GRPC
insecure: true # TODO check if necessary
traces: # This pipeline will...
receivers: [zipkin]. # ...receive zipkin traces
processors: [probabilistic_sampler] # ...sample them
exporters: [zipkin] # and export zipkin traces to Tempo
Refer to the OpenTelemetry documentation for more details: Configuration | OpenTelemetry