Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit f37b73d

Browse files
authored
Renaming (#45)
* Rename samplers to match spec * Rename Reporter -> Exporter
1 parent 55f0f8c commit f37b73d

24 files changed

Lines changed: 107 additions & 107 deletions

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ $ composer require opencensus/opencensus
1919

2020
```php
2121
use OpenCensus\Trace\RequestTracer;
22-
use OpenCensus\Trace\Reporter\EchoReporter;
22+
use OpenCensus\Trace\Exporter\EchoExporter;
2323

24-
RequestTracer::start(new EchoReporter());
24+
RequestTracer::start(new EchoExporter());
2525
```
2626

2727
### PHP Extension
@@ -42,21 +42,21 @@ extension=opencensus.so
4242

4343
### Reporting Traces
4444

45-
The above sample uses the `EchoReporter` to dump trace results to the
45+
The above sample uses the `EchoExporter` to dump trace results to the
4646
bottom of the webpage.
4747

48-
If you would like to provide your own reporter, create a class that implements `ReporterInterface`.
48+
If you would like to provide your own reporter, create a class that implements `ExporterInterface`.
4949

5050
#### Currently implemented reporters
5151

5252
| Class | Description |
5353
| ----- | ----------- |
54-
| [EchoReporter](src/Trace/Reporter/EchoReporter.php) | Output the collected spans to stdout |
55-
| [FileReporter](src/Trace/Reporter/FileReporter.php) | Output JSON encoded spans to a file |
56-
| [GoogleCloudReporter](src/Trace/Reporter/GoogleCloudReporter.php) | Report traces to Google Cloud Stackdriver Trace |
57-
| [LoggerReporter](src/Trace/Reporter/LoggerReporter.php) | Reporter JSON encoded spans to a PSR-3 logger |
58-
| [NullReporter](scr/Trace/Reporter/NullReporter.php) | No-op |
59-
| [ZipkinReporter](src/Trace/Reporter/ZipkinReporter.php) | Report collected spans to a Zipkin server |
54+
| [EchoExporter](src/Trace/Exporter/EchoExporter.php) | Output the collected spans to stdout |
55+
| [FileExporter](src/Trace/Exporter/FileExporter.php) | Output JSON encoded spans to a file |
56+
| [GoogleCloudExporter](src/Trace/Exporter/GoogleCloudExporter.php) | Report traces to Google Cloud Stackdriver Trace |
57+
| [LoggerExporter](src/Trace/Exporter/LoggerExporter.php) | Exporter JSON encoded spans to a PSR-3 logger |
58+
| [NullExporter](scr/Trace/Exporter/NullExporter.php) | No-op |
59+
| [ZipkinExporter](src/Trace/Exporter/ZipkinExporter.php) | Report collected spans to a Zipkin server |
6060

6161
### Sampling Rate
6262

@@ -68,12 +68,12 @@ The preferred sampler is the `QpsSampler` (Queries Per Second). This sampler imp
6868
requires a PSR-6 cache implementation to function.
6969

7070
```php
71-
use OpenCensus\Trace\Reporter\EchoReporter;
71+
use OpenCensus\Trace\Exporter\EchoExporter;
7272
use OpenCensus\Trace\Sampler\QpsSampler;
7373

7474
$cache = new SomeCacheImplementation();
7575
$sampler = new QpsSampler($cache, ['rate' => 0.1]); // sample 0.1 requests per second
76-
RequestTracer::start(new EchoReporter(), ['sampler' => $sampler]);
76+
RequestTracer::start(new EchoExporter(), ['sampler' => $sampler]);
7777
```
7878

7979
Please note: While required for the `QpsSampler`, a PSR-6 implementation is
@@ -83,24 +83,24 @@ dependency to fulfill this requirement. For PSR-6 implementations, please see th
8383
If the APCu extension is available (available on Google AppEngine Flexible Environment)
8484
and you include the cache/apcu-adapter composer package, we will set up the cache for you.
8585

86-
You can also choose to use the `RandomSampler` which simply samples a flat
86+
You can also choose to use the `ProbabilitySampler` which simply samples a flat
8787
percentage of requests.
8888

8989
#### Currently implemented samplers
9090

9191
| Class | Description |
9292
| ----- | ----------- |
93-
| [AlwaysOffSampler](src/Trace/Sampler/AlwaysOffSampler.php) | Never trace any requests |
94-
| [AlwaysOnSampler](src/Trace/Sampler/AlwaysOnSampler.php) | Trace all requests |
93+
| [NeverSampleSampler](src/Trace/Sampler/NeverSampleSampler.php) | Never trace any requests |
94+
| [AlwaysSampleSampler](src/Trace/Sampler/AlwaysSampleSampler.php) | Trace all requests |
9595
| [QpsSampler](src/Trace/Sampler/QpsSampler.php) | Trace X requests per second. Requires a PSR-6 cache implementation |
96-
| [RandomSampler](src/Trace/Sampler/RandomSampler.php) | Trace X percent of requests. |
96+
| [ProbabilitySampler](src/Trace/Sampler/ProbabilitySampler.php) | Trace X percent of requests. |
9797

9898
```php
99-
use OpenCensus\Trace\Reporter\EchoReporter;
100-
use OpenCensus\Trace\Sampler\RandomSampler;
99+
use OpenCensus\Trace\Exporter\EchoExporter;
100+
use OpenCensus\Trace\Sampler\ProbabilitySampler;
101101

102-
$sampler = new RandomSampler(0.1); // sample 10% of requests
103-
RequestTracer::start(new EchoReporter(), ['sampler' => $sampler]);
102+
$sampler = new ProbabilitySampler(0.1); // sample 10% of requests
103+
RequestTracer::start(new EchoExporter(), ['sampler' => $sampler]);
104104
```
105105

106106
If you would like to provide your own sampler, create a class that implements `SamplerInterface`.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace OpenCensus\Trace\Reporter;
18+
namespace OpenCensus\Trace\Exporter;
1919

2020
use OpenCensus\Trace\Tracer\TracerInterface;
2121

2222
/**
23-
* This implementation of the ReporterInterface uses `print_r` to output
23+
* This implementation of the ExporterInterface uses `print_r` to output
2424
* the trace's representation to stdout.
2525
*/
26-
class EchoReporter implements ReporterInterface
26+
class EchoExporter implements ExporterInterface
2727
{
2828
/**
2929
* Report the provided Trace to a backend.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace OpenCensus\Trace\Reporter;
18+
namespace OpenCensus\Trace\Exporter;
1919

2020
use OpenCensus\Trace\Tracer\TracerInterface;
2121

2222
/**
23-
* The ReporterInterface allows you to swap out the Trace reporting mechanism
23+
* The ExporterInterface allows you to swap out the Trace reporting mechanism
2424
*/
25-
interface ReporterInterface
25+
interface ExporterInterface
2626
{
2727
/**
2828
* Report the provided Trace to a backend.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace OpenCensus\Trace\Reporter;
18+
namespace OpenCensus\Trace\Exporter;
1919

2020
use OpenCensus\Trace\Tracer\TracerInterface;
2121

2222
/**
23-
* This implementation of the ReporterInterface appends a json
23+
* This implementation of the ExporterInterface appends a json
2424
* representation of the trace to a file.
2525
*/
26-
class FileReporter implements ReporterInterface
26+
class FileExporter implements ExporterInterface
2727
{
2828
/**
2929
* @var string The path to the output file.
3030
*/
3131
private $filename;
3232

3333
/**
34-
* Create a new EchoReporter
34+
* Create a new EchoExporter
3535
*
3636
* @param string $filename The path to the output file.
3737
*/

src/Trace/Reporter/GoogleCloudReporter.php renamed to src/Trace/Exporter/GoogleCloudExporter.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace OpenCensus\Trace\Reporter;
18+
namespace OpenCensus\Trace\Exporter;
1919

2020
use Google\Cloud\Core\Batch\BatchRunner;
2121
use Google\Cloud\Core\Batch\BatchTrait;
@@ -25,15 +25,15 @@
2525
use OpenCensus\Trace\TraceSpan as OpenCensusTraceSpan;
2626

2727
/**
28-
* This implementation of the ReporterInterface use the BatchRunner to provide
28+
* This implementation of the ExporterInterface use the BatchRunner to provide
2929
* reporting of Traces and their TraceSpans to Google Cloud Stackdriver Trace.
3030
*
3131
* Example:
3232
* ```
3333
* use OpenCensus\Trace\RequestTracer;
34-
* use OpenCensus\Trace\Reporter\GoogleCloudReporter;
34+
* use OpenCensus\Trace\Exporter\GoogleCloudExporter;
3535
*
36-
* $reporter = new GoogleCloudReporter([
36+
* $reporter = new GoogleCloudExporter([
3737
* 'clientConfig' => [
3838
* 'projectId' => 'my-project'
3939
* ]
@@ -48,9 +48,9 @@
4848
* Example:
4949
* ```
5050
* use OpenCensus\Trace\RequestTracer;
51-
* use OpenCensus\Trace\Reporter\GoogleCloudReporter;
51+
* use OpenCensus\Trace\Exporter\GoogleCloudExporter;
5252
*
53-
* $reporter = new GoogleCloudReporter([
53+
* $reporter = new GoogleCloudExporter([
5454
* 'async' => true,
5555
* 'clientConfig' => [
5656
* 'projectId' => 'my-project'
@@ -67,7 +67,7 @@
6767
* incompatible ways. Please use with caution, and test thoroughly when
6868
* upgrading.
6969
*/
70-
class GoogleCloudReporter implements ReporterInterface
70+
class GoogleCloudExporter implements ExporterInterface
7171
{
7272
const VERSION = '0.1.0';
7373

@@ -108,7 +108,7 @@ class GoogleCloudReporter implements ReporterInterface
108108
private $async;
109109

110110
/**
111-
* Create a TraceReporter that utilizes background batching.
111+
* Create a TraceExporter that utilizes background batching.
112112
*
113113
* @param array $options [optional] {
114114
* Configuration options.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace OpenCensus\Trace\Reporter;
18+
namespace OpenCensus\Trace\Exporter;
1919

2020
use OpenCensus\Trace\Tracer\TracerInterface;
2121
use Psr\Log\LoggerInterface;
2222

2323
/**
24-
* This implementation of the ReporterInterface appends a json
24+
* This implementation of the ExporterInterface appends a json
2525
* representation of the trace to a file.
2626
*/
27-
class LoggerReporter implements ReporterInterface
27+
class LoggerExporter implements ExporterInterface
2828
{
2929
const DEFAULT_LOG_LEVEL = 'notice';
3030

@@ -39,7 +39,7 @@ class LoggerReporter implements ReporterInterface
3939
private $level;
4040

4141
/**
42-
* Create a new LoggerReporter
42+
* Create a new LoggerExporter
4343
*
4444
* @param LoggerInterface $logger The logger to write to.
4545
* @param string $level The logger level to write as. **Defaults to** `notice`.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace OpenCensus\Trace\Reporter;
18+
namespace OpenCensus\Trace\Exporter;
1919

2020
use OpenCensus\Trace\Tracer\TracerInterface;
2121

2222
/**
23-
* This implementation of the ReporterInterface does nothing.
23+
* This implementation of the ExporterInterface does nothing.
2424
*/
25-
class NullReporter implements ReporterInterface
25+
class NullExporter implements ExporterInterface
2626
{
2727
/**
2828
* Does nothing.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace OpenCensus\Trace\Reporter;
18+
namespace OpenCensus\Trace\Exporter;
1919

2020
use OpenCensus\Trace\Tracer\TracerInterface;
2121
use OpenCensus\Trace\TraceSpan;
2222

2323
/**
24-
* This implementation of the ReporterInterface appends a json
24+
* This implementation of the ExporterInterface appends a json
2525
* representation of the trace to a file.
2626
*/
27-
class ZipkinReporter implements ReporterInterface
27+
class ZipkinExporter implements ExporterInterface
2828
{
2929
/**
3030
* @var string
@@ -47,7 +47,7 @@ class ZipkinReporter implements ReporterInterface
4747
private $url;
4848

4949
/**
50-
* Create a new ZipkinReporter
50+
* Create a new ZipkinExporter
5151
*
5252
* @param string $name The name of this application
5353
* @param string $host The hostname of the Zipkin server

src/Trace/RequestHandler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
namespace OpenCensus\Trace;
1919

20-
use OpenCensus\Trace\Reporter\ReporterInterface;
20+
use OpenCensus\Trace\Exporter\ExporterInterface;
2121
use OpenCensus\Trace\Sampler\SamplerInterface;
2222
use OpenCensus\Trace\TraceSpan;
2323
use OpenCensus\Trace\Tracer\ContextTracer;
@@ -38,7 +38,7 @@ class RequestHandler
3838
const DEFAULT_ROOT_SPAN_NAME = 'main';
3939

4040
/**
41-
* @var ReporterInterface The reported to use at the end of the request
41+
* @var ExporterInterface The reported to use at the end of the request
4242
*/
4343
private $reporter;
4444

@@ -50,7 +50,7 @@ class RequestHandler
5050
/**
5151
* Create a new RequestHandler.
5252
*
53-
* @param ReporterInterface $reporter How to report the trace at the end of the request
53+
* @param ExporterInterface $reporter How to report the trace at the end of the request
5454
* @param SamplerInterface $sampler Which sampler to use for sampling requests
5555
* @param PropagatorInterface $propagator TraceContext propagator
5656
* @param array $options [optional] {
@@ -61,7 +61,7 @@ class RequestHandler
6161
* }
6262
*/
6363
public function __construct(
64-
ReporterInterface $reporter,
64+
ExporterInterface $reporter,
6565
SamplerInterface $sampler,
6666
PropagatorInterface $propagator,
6767
array $options = []
@@ -104,7 +104,7 @@ public function __construct(
104104

105105
/**
106106
* The function registered as the shutdown function. Cleans up the trace and
107-
* reports using the provided ReporterInterface. Adds additional labels to
107+
* reports using the provided ExporterInterface. Adds additional labels to
108108
* the root span detected from the response.
109109
*/
110110
public function onExit()

src/Trace/RequestTracer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
use OpenCensus\Trace\Sampler\SamplerFactory;
2121
use OpenCensus\Trace\Sampler\SamplerInterface;
22-
use OpenCensus\Trace\Reporter\ReporterInterface;
22+
use OpenCensus\Trace\Exporter\ExporterInterface;
2323
use OpenCensus\Trace\Propagator\PropagatorInterface;
2424
use OpenCensus\Trace\Propagator\HttpHeaderPropagator;
2525

@@ -33,9 +33,9 @@
3333
* Example:
3434
* ```
3535
* use OpenCensus\Trace\RequestTracer;
36-
* use OpenCensus\Trace\Reporter\EchoReporter;
36+
* use OpenCensus\Trace\Exporter\EchoExporter;
3737
*
38-
* $reporter = new EchoReporter();
38+
* $reporter = new EchoExporter();
3939
* RequestTracer::start($reporter);
4040
* ```
4141
*
@@ -110,7 +110,7 @@ class RequestTracer
110110
* Start a new trace session for this request. You should call this as early as
111111
* possible for the most accurate results.
112112
*
113-
* @param ReporterInterface $reporter
113+
* @param ExporterInterface $reporter
114114
* @param array $options {
115115
* Configuration options. See
116116
* {@see OpenCensus\Trace\TraceSpan::__construct()} for the other available options.
@@ -123,7 +123,7 @@ class RequestTracer
123123
* }
124124
* @return RequestHandler
125125
*/
126-
public static function start(ReporterInterface $reporter, array $options = [])
126+
public static function start(ExporterInterface $reporter, array $options = [])
127127
{
128128
$samplerOptions = array_key_exists('sampler', $options) ? $options['sampler'] : [];
129129
unset($options['sampler']);

0 commit comments

Comments
 (0)