1919
2020use OpenCensus \Core \Scope ;
2121use OpenCensus \Trace \Span ;
22- use OpenCensus \Trace \Sampler \SamplerFactory ;
22+ use OpenCensus \Trace \Sampler \AlwaysSampleSampler ;
2323use OpenCensus \Trace \Sampler \SamplerInterface ;
2424use OpenCensus \Trace \Exporter \ExporterInterface ;
2525use OpenCensus \Trace \Propagator \PropagatorInterface ;
5757 * The above uses a query-per-second sampler at 0.1 requests/second. The implementation
5858 * requires a PSR-6 cache. See {@see OpenCensus\Trace\Sampler\QpsSampler} for more information.
5959 * You may provide your own implementation of {@see OpenCensus\Trace\Sampler\SamplerInterface}
60- * or use one of the provided. You may provide a configuration array for the sampler instead. See
61- * {@see OpenCensus\Trace\Sampler\SamplerFactory::build()} for builder options:
62- *
63- * ```
64- * // $cache is a PSR-6 cache implementation
65- * Tracer::start($reporter, [
66- * 'sampler' => [
67- * 'type' => 'qps',
68- * 'rate' => 0.1,
69- * 'cache' => $cache
70- * ]
71- * ]);
72- * ```
60+ * or use one of the provided.
7361 *
7462 * To trace code, you can use static {@see OpenCensus\Trace\Tracer::inSpan()} helper function:
7563 *
@@ -120,8 +108,8 @@ class Tracer
120108 * Configuration options. See
121109 * {@see OpenCensus\Trace\Span::__construct()} for the other available options.
122110 *
123- * @type SamplerInterface|array $sampler Sampler or sampler factory build arguments. See
124- * {@see OpenCensus\Trace\Sampler\SamplerFactory::build()} for the available options .
111+ * @type SamplerInterface $sampler Sampler that defines the sampling rules.
112+ * **Defaults to** a new `AlwaysSampleSampler` .
125113 * @type PropagatorInterface $propagator SpanContext propagator. **Defaults to**
126114 * a new `HttpHeaderPropagator` instance
127115 * @type array $headers Optional array of headers to use in place of $_SERVER
@@ -130,13 +118,11 @@ class Tracer
130118 */
131119 public static function start (ExporterInterface $ reporter , array $ options = [])
132120 {
133- $ samplerOptions = array_key_exists ('sampler ' , $ options ) ? $ options ['sampler ' ] : [];
121+ $ sampler = array_key_exists ('sampler ' , $ options )
122+ ? $ options ['sampler ' ]
123+ : new AlwaysSampleSampler ();
134124 unset($ options ['sampler ' ]);
135125
136- $ sampler = ($ samplerOptions instanceof SamplerInterface)
137- ? $ samplerOptions
138- : SamplerFactory::build ($ samplerOptions );
139-
140126 $ propagator = array_key_exists ('propagator ' , $ options )
141127 ? $ options ['propagator ' ]
142128 : new HttpHeaderPropagator ();
0 commit comments