packageio.opencensus.tutorials.tracing.sampling;importio.opencensus.trace.config.TraceConfig;publicclassApp{publicstaticvoidmain(String[]args){// Get the global TraceConfig
TraceConfigglobalTraceConfig=Tracing.getTraceConfig();// Now update the global TraceConfig
globalTraceConfig.updateActiveTraceParams(traceConfig.getActiveTraceParams().toBuilder.setSampler(theSampler));}}

Rules

A sampling decision from a ParentSpan is ALWAYS inherited by all its regardless of the trace configuration.
This ensures continuity of traces – for example, if a parent were sampled but one of its children were not,
we’d then lose parts of the trace, and vice versa if the parent weren’t sampled yet one of its children were,
we wouldn’t know where the span began