Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Introduce BaseReporter type (#329)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro authored Sep 7, 2021
1 parent 2d91bd5 commit c79ef27
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions jaeger_client/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
default_logger = logging.getLogger('jaeger_tracing')


class NullReporter(object):
"""Ignores all spans."""
class BaseReporter(object):
"""Abstract class."""
def report_span(self, span):
pass
raise NotImplementedError()

def set_process(self, service_name, tags, max_length):
pass
Expand All @@ -48,7 +48,13 @@ def close(self):
return fut


class InMemoryReporter(NullReporter):
class NullReporter(BaseReporter):
"""Ignores all spans."""
def report_span(self, span):
pass


class InMemoryReporter(BaseReporter):
"""Stores spans in memory and returns them via get_spans()."""
def __init__(self):
super(InMemoryReporter, self).__init__()
Expand All @@ -64,7 +70,7 @@ def get_spans(self):
return self.spans[:]


class LoggingReporter(NullReporter):
class LoggingReporter(BaseReporter):
"""Logs all spans."""
def __init__(self, logger=None):
self.logger = logger if logger else default_logger
Expand All @@ -73,7 +79,7 @@ def report_span(self, span):
self.logger.info('Reporting span %s', span)


class Reporter(NullReporter):
class Reporter(BaseReporter):
"""Receives completed spans from Tracer and submits them out of process."""
def __init__(self, channel, queue_capacity=100, batch_size=10,
flush_interval=DEFAULT_FLUSH_INTERVAL, io_loop=None,
Expand Down Expand Up @@ -240,7 +246,7 @@ def __init__(self, metrics_factory):
metrics_factory.create_gauge(name='jaeger:reporter_queue_length')


class CompositeReporter(NullReporter):
class CompositeReporter(BaseReporter):
"""Delegates reporting to one or more underlying reporters."""
def __init__(self, *reporters):
self.reporters = reporters
Expand Down

0 comments on commit c79ef27

Please sign in to comment.