Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 8370e6b

Browse files
authored
Rename reporters to exporters (#42)
1 parent 612d546 commit 8370e6b

24 files changed

Lines changed: 199 additions & 199 deletions
File renamed without changes.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Module containing base class for reporters."""
15+
"""Module containing base class for exporters."""
1616

1717

18-
class Reporter(object):
19-
"""Base class for opencensus trace request reporters.
18+
class Exporter(object):
19+
"""Base class for opencensus trace request exporters.
2020
21-
Subclasses of :class:`Reporter` must override :meth:`report`.
21+
Subclasses of :class:`Exporter` must override :meth:`export`.
2222
"""
2323

24-
def report(self, trace):
24+
def export(self, trace):
2525
"""Export the trace."""
2626
raise NotImplementedError

trace/opencensus/trace/reporters/file_reporter.py renamed to trace/opencensus/trace/exporters/file_exporter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
import json
1818

19-
from opencensus.trace.reporters import base
19+
from opencensus.trace.exporters import base
2020

2121
DEFAULT_FILENAME = 'opencensus-traces.json'
2222

2323

24-
class FileReporter(base.Reporter):
24+
class FileExporter(base.Exporter):
2525
"""
2626
:type file_name: str
2727
:param file_name: The name of the output file.
@@ -30,7 +30,7 @@ class FileReporter(base.Reporter):
3030
def __init__(self, file_name=DEFAULT_FILENAME):
3131
self.file_name = file_name
3232

33-
def report(self, trace):
33+
def export(self, trace):
3434
"""
3535
:type trace: dict
3636
:param trace: Trace collected.

trace/opencensus/trace/reporters/google_cloud_reporter.py renamed to trace/opencensus/trace/exporters/google_cloud_exporter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from opencensus.trace.reporters import base
15+
from opencensus.trace.exporters import base
1616

1717
from google.cloud.trace.client import Client
1818

1919

20-
class GoogleCloudReporter(base.Reporter):
21-
"""A reporter that send traces and trace spans to Google Cloud Stackdriver
20+
class GoogleCloudExporter(base.Exporter):
21+
"""A exporter that send traces and trace spans to Google Cloud Stackdriver
2222
Trace.
2323
"""
2424
def __init__(self, client=None, project_id=None):
@@ -29,7 +29,7 @@ def __init__(self, client=None, project_id=None):
2929
self.client = client
3030
self.project_id = client.project
3131

32-
def report(self, trace):
32+
def export(self, trace):
3333
"""
3434
:type trace: dict
3535
:param trace: Trace collected.

trace/opencensus/trace/reporters/logging_reporter.py renamed to trace/opencensus/trace/exporters/logging_exporter.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
import logging
1818

19-
from opencensus.trace.reporters import base
19+
from opencensus.trace.exporters import base
2020

2121

22-
class LoggingReporter(base.Reporter):
23-
"""A reporter to export the spans data to python logging. Also can use
22+
class LoggingExporter(base.Exporter):
23+
"""A exporter to export the spans data to python logging. Also can use
2424
handlers like CloudLoggingHandler to log to Stackdriver Logging API.
2525
2626
:type handler: :class:`logging.handler`
@@ -32,16 +32,16 @@ class LoggingReporter(base.Reporter):
3232
3333
import google.cloud.logging
3434
from google.cloud.logging.handlers import CloudLoggingHandler
35-
from opencensus.trace.reporters import logging_reporter
35+
from opencensus.trace.exporters import logging_exporter
3636
3737
client = google.cloud.logging.Client()
3838
cloud_handler = CloudLoggingHandler(client)
39-
reporter = logging_reporter.LoggingReporter(handler=cloud_handler)
39+
exporter = logging_exporter.LoggingExporter(handler=cloud_handler)
4040
41-
reporter.report(your_spans_list)
41+
exporter.export(your_spans_list)
4242
43-
Or initialize a context tracer with the logging reporter, then the traces
44-
will be reported to logging when finished.
43+
Or initialize a context tracer with the logging exporter, then the traces
44+
will be exported to logging when finished.
4545
"""
4646

4747
def __init__(self, handler=None):
@@ -54,7 +54,7 @@ def __init__(self, handler=None):
5454
self.logger.addHandler(handler)
5555
self.logger.setLevel(logging.INFO)
5656

57-
def report(self, trace):
57+
def export(self, trace):
5858
"""
5959
:type traces: dict
6060
:param traces: Trace collected.

trace/opencensus/trace/reporters/print_reporter.py renamed to trace/opencensus/trace/exporters/print_exporter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
"""Export the trace spans by printing them out."""
1616

17-
from opencensus.trace.reporters import base
17+
from opencensus.trace.exporters import base
1818

1919

20-
class PrintReporter(base.Reporter):
21-
def report(self, trace):
22-
"""Report the traces by printing it out.
20+
class PrintExporter(base.Exporter):
21+
def export(self, trace):
22+
"""export the traces by printing it out.
2323
2424
:type trace: dict
2525
:param trace: Trace collected.

trace/opencensus/trace/reporters/zipkin_reporter.py renamed to trace/opencensus/trace/exporters/zipkin_exporter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import requests
2121
import calendar
2222

23-
from opencensus.trace.reporters import base
23+
from opencensus.trace.exporters import base
2424

2525
DEFAULT_ENDPOINT = '/api/v2/spans'
2626
DEFAULT_HOST_NAME = 'localhost'
@@ -38,8 +38,8 @@
3838
SUCCESS_STATUS_CODE = (200, 202)
3939

4040

41-
class ZipkinReporter(base.Reporter):
42-
"""Report the spans to Zipkin.
41+
class ZipkinExporter(base.Exporter):
42+
"""export the spans to Zipkin.
4343
4444
See: http://zipkin.io/zipkin-api/#
4545
@@ -54,7 +54,7 @@ class ZipkinReporter(base.Reporter):
5454
:param port: (Optional) The port of the Zipkin server.
5555
5656
:type end_point: str
57-
:param end_point: (Optional) The path for the span reporting endpoint.
57+
:param end_point: (Optional) The path for the span exporting endpoint.
5858
"""
5959

6060
def __init__(
@@ -76,7 +76,7 @@ def get_url(self):
7676
self.port,
7777
self.endpoint)
7878

79-
def report(self, trace):
79+
def export(self, trace):
8080
"""Send trace to Zipkin server, default using the v1 API.
8181
8282
:type trace: dict
@@ -106,7 +106,7 @@ def translate_to_zipkin(self, trace_id, spans):
106106
:param trace_id: Trace ID.
107107
108108
:type spans: list
109-
:param spans: List of spans to be reported.
109+
:param spans: List of spans to be exported.
110110
111111
:rtype: list
112112
:returns: List of zipkin format spans.

trace/opencensus/trace/ext/django/config.py

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

2020
DEFAULT_DJANGO_TRACER_CONFIG = {
2121
'SAMPLER': 'opencensus.trace.samplers.always_on.AlwaysOnSampler',
22-
'REPORTER':
23-
'opencensus.trace.reporters.print_reporter.PrintReporter',
22+
'EXPORTER':
23+
'opencensus.trace.exporters.print_exporter.PrintExporter',
2424
'PROPAGATOR': 'opencensus.trace.propagation.google_cloud_format.'
2525
'GoogleCloudFormatPropagator',
2626
}
2727

2828
DEFAULT_DJANGO_TRACER_PARAMS = {
2929
'SAMPLING_RATE': 0.5,
30-
'GCP_REPORTER_PROJECT': None,
31-
'ZIPKIN_REPORTER_SERVICE_NAME': 'my_service',
32-
'ZIPKIN_REPORTER_HOST_NAME': 'localhost',
33-
'ZIPKIN_REPORTER_PORT': 9411,
30+
'GCP_EXPORTER_PROJECT': None,
31+
'ZIPKIN_EXPORTER_SERVICE_NAME': 'my_service',
32+
'ZIPKIN_EXPORTER_HOST_NAME': 'localhost',
33+
'ZIPKIN_EXPORTER_PORT': 9411,
3434
}
3535

3636

@@ -41,7 +41,7 @@
4141

4242
class DjangoTraceSettings(object):
4343
"""Set the params for a django tracer, including the tracer, sampler and
44-
reporter. If the user did not define the settings in django settings file.
44+
exporter. If the user did not define the settings in django settings file.
4545
then use the dafaults.
4646
"""
4747

trace/opencensus/trace/ext/django/middleware.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030

3131
_DJANGO_TRACE_HEADER = 'HTTP_X_CLOUD_TRACE_CONTEXT'
3232

33-
GCP_REPORTER_PROJECT = 'GCP_REPORTER_PROJECT'
33+
GCP_EXPORTER_PROJECT = 'GCP_EXPORTER_PROJECT'
3434
SAMPLING_RATE = 'SAMPLING_RATE'
35-
ZIPKIN_REPORTER_SERVICE_NAME = 'ZIPKIN_REPORTER_SERVICE_NAME'
36-
ZIPKIN_REPORTER_HOST_NAME = 'ZIPKIN_REPORTER_HOST_NAME'
37-
ZIPKIN_REPORTER_PORT = 'ZIPKIN_REPORTER_PORT'
35+
ZIPKIN_EXPORTER_SERVICE_NAME = 'ZIPKIN_EXPORTER_SERVICE_NAME'
36+
ZIPKIN_EXPORTER_HOST_NAME = 'ZIPKIN_EXPORTER_HOST_NAME'
37+
ZIPKIN_EXPORTER_PORT = 'ZIPKIN_EXPORTER_PORT'
3838

3939
log = logging.getLogger(__name__)
4040

@@ -91,7 +91,7 @@ def __init__(self, get_response=None):
9191
# One-time configuration and initialization.
9292
self.get_response = get_response
9393
self._sampler = settings.SAMPLER
94-
self._reporter = settings.REPORTER
94+
self._exporter = settings.EXPORTER
9595
self._propagator = settings.PROPAGATOR
9696

9797
# Initialize the sampler
@@ -102,23 +102,23 @@ def __init__(self, get_response=None):
102102
else:
103103
self.sampler = self._sampler()
104104

105-
# Initialize the reporter
106-
if self._reporter.__name__ == 'GoogleCloudReporter':
107-
_project_id = settings.params.get(GCP_REPORTER_PROJECT, None)
108-
self.reporter = self._reporter(project_id=_project_id)
109-
elif self._reporter.__name__ == 'ZipkinReporter':
105+
# Initialize the exporter
106+
if self._exporter.__name__ == 'GoogleCloudExporter':
107+
_project_id = settings.params.get(GCP_EXPORTER_PROJECT, None)
108+
self.exporter = self._exporter(project_id=_project_id)
109+
elif self._exporter.__name__ == 'ZipkinExporter':
110110
_zipkin_service_name = settings.params.get(
111-
ZIPKIN_REPORTER_SERVICE_NAME, 'my_service')
111+
ZIPKIN_EXPORTER_SERVICE_NAME, 'my_service')
112112
_zipkin_host_name = settings.params.get(
113-
ZIPKIN_REPORTER_HOST_NAME, 'localhost')
113+
ZIPKIN_EXPORTER_HOST_NAME, 'localhost')
114114
_zipkin_port = settings.params.get(
115-
ZIPKIN_REPORTER_PORT, 9411)
116-
self.reporter = self._reporter(
115+
ZIPKIN_EXPORTER_PORT, 9411)
116+
self.exporter = self._exporter(
117117
service_name=_zipkin_service_name,
118118
host_name=_zipkin_host_name,
119119
port=_zipkin_port)
120120
else:
121-
self.reporter = self._reporter()
121+
self.exporter = self._exporter()
122122

123123
# Initialize the propagator
124124
self.propagator = self._propagator()
@@ -143,7 +143,7 @@ def process_request(self, request):
143143
tracer = request_tracer.RequestTracer(
144144
span_context=span_context,
145145
sampler=self.sampler,
146-
reporter=self.reporter,
146+
exporter=self.exporter,
147147
propagator=self.propagator)
148148

149149
tracer.start_trace()

trace/opencensus/trace/ext/flask/flask_middleware.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from opencensus.trace import labels_helper
1919
from opencensus.trace import execution_context
2020
from opencensus.trace.propagation import google_cloud_format
21-
from opencensus.trace.reporters import print_reporter
21+
from opencensus.trace.exporters import print_exporter
2222
from opencensus.trace.samplers import always_on
2323
from opencensus.trace import request_tracer
2424

@@ -44,24 +44,24 @@ class FlaskMiddleware(object):
4444
:class:`.AlwaysOnSampler`. The rest options are
4545
:class:`.AlwaysOffSampler`, :class:`.FixedRateSampler`.
4646
47-
:type reporter: :class: `type`
48-
:param reporter: Class for creating new Reporter objects. Default to
49-
:class:`.PrintReporter`. The rest option is
50-
:class:`.FileReporter`.
47+
:type exporter: :class: `type`
48+
:param exporter: Class for creating new exporter objects. Default to
49+
:class:`.PrintExporter`. The rest option is
50+
:class:`.FileExporter`.
5151
"""
52-
def __init__(self, app, sampler=None, reporter=None, propagator=None):
52+
def __init__(self, app, sampler=None, exporter=None, propagator=None):
5353
if sampler is None:
5454
sampler = always_on.AlwaysOnSampler()
5555

56-
if reporter is None:
57-
reporter = print_reporter.PrintReporter()
56+
if exporter is None:
57+
exporter = print_exporter.PrintExporter()
5858

5959
if propagator is None:
6060
propagator = google_cloud_format.GoogleCloudFormatPropagator()
6161

6262
self.app = app
6363
self.sampler = sampler
64-
self.reporter = reporter
64+
self.exporter = exporter
6565
self.propagator = propagator
6666
self.setup_trace()
6767

@@ -81,7 +81,7 @@ def _before_request(self):
8181
tracer = request_tracer.RequestTracer(
8282
span_context=span_context,
8383
sampler=self.sampler,
84-
reporter=self.reporter,
84+
exporter=self.exporter,
8585
propagator=self.propagator)
8686

8787
tracer.start_trace()

0 commit comments

Comments
 (0)