Example #1
0
    def test_baggage_items(self):
        """Test Baggage Items."""
        # Create parentCtx with baggage items
        tracer = WavefrontTracer(ConsoleReporter(), self.application_tags)
        baggage_item = {'foo': 'bar', 'user': '******'}
        parent_ctx = WavefrontSpanContext(trace_id=uuid.uuid1(),
                                          span_id=uuid.uuid1(),
                                          baggage=baggage_item,
                                          decision=True)
        span = tracer.start_span('test_op', child_of=parent_ctx)
        self.assertEqual('bar', span.get_baggage_item('foo'))
        self.assertEqual('name', span.get_baggage_item('user'))

        # Parent and Follows
        baggage_item = {'tracer': 'id', 'db.name': 'name'}
        follows_ctx = WavefrontSpanContext(trace_id=uuid.uuid1(),
                                           span_id=uuid.uuid1(),
                                           baggage=baggage_item,
                                           decision=True)
        span = tracer.start_span('test_op',
                                 references=[
                                     opentracing.child_of(parent_ctx),
                                     opentracing.child_of(follows_ctx)
                                 ])
        self.assertEqual('bar', span.get_baggage_item('foo'))
        self.assertEqual('name', span.get_baggage_item('user'))
        self.assertEqual('id', span.get_baggage_item('tracer'))
        self.assertEqual('name', span.get_baggage_item('db.name'))

        # Validate root span
        span = tracer.start_span('test_op')
        self.assertIsNotNone(span.context.baggage)
        self.assertTrue(not bool(span.context.baggage))
Example #2
0
 def test_active_span(self):
     """Test Active Span."""
     tracer = WavefrontTracer(ConsoleReporter(), self.application_tags)
     span = tracer.start_span('test_op_1')
     self.assertIsNotNone(span)
     span.finish()
     scope = tracer.start_active_span('test_op_2', finish_on_close=True)
     self.assertIsNotNone(scope)
     self.assertIsNotNone(scope.span)
     scope.close()
Example #3
0
 def test_tags_with_components_defined(self):
     """Test Multi-valued Tags."""
     tracer = WavefrontTracer(ConsoleReporter(), self.application_tags)
     span = tracer.start_span('test_op', tags={'component': 'my_component'})
     self.assertIsNotNone(span)
     self.assertIsNotNone(span.get_tags())
     self.assertIsNotNone(span.get_tags_as_list())
     self.assertIsNotNone(span.get_tags_as_map())
     self.assertEqual(6, len(span.get_tags_as_map()))
     self.assertEqual(['my_component'],
                      span.get_tags_as_map().get('component'))
     span.finish()
     tracer.close()
Example #4
0
 def test_negative_child_sampling(self):
     """Test child span with positive sampling."""
     tracer = WavefrontTracer(ConsoleReporter(), self.application_tags,
                              samplers=[ConstantSampler(True)])
     parent_ctx = WavefrontSpanContext(trace_id=uuid.uuid1(),
                                       span_id=uuid.uuid1(),
                                       decision=False)
     span = tracer.start_span('test_op', child_of=parent_ctx)
     self.assertTrue(tracer.sample(span.operation_name, span.trace_id, 0))
     self.assertIsNotNone(span)
     self.assertEqual(parent_ctx.trace_id, span.trace_id)
     self.assertTrue(span.context.is_sampled())
     self.assertIsNotNone(span.context.get_sampling_decision())
     self.assertFalse(span.context.get_sampling_decision())
Example #5
0
    def test_ignore_active_span(self):
        """Test Ignore Active Span."""
        tracer = WavefrontTracer(ConsoleReporter(), self.application_tags)
        scope = tracer.start_active_span('test_op')
        active_span = scope.span

        # Span created with ignore_active_span=False by default.
        child_span = tracer.start_span(
            operation_name='child_op',
            ignore_active_span=False)
        active_trace_id = str(active_span.trace_id)
        child_trace_id = str(child_span.trace_id)
        self.assertEqual(active_trace_id, child_trace_id)
        child_span.finish()

        # Span created with ignore_active_span=True.
        child_span = tracer.start_span(
            operation_name='child_op',
            ignore_active_span=True)
        child_trace_id = str(child_span.trace_id)
        self.assertNotEqual(active_trace_id, child_trace_id)
        child_span.finish()

        scope.close()
        tracer.close()
Example #6
0
 def test_tags_as_dict(self):
     """Test Multi-valued Tags."""
     tracer = WavefrontTracer(ConsoleReporter(), self.application_tags)
     span = tracer.start_span('test_op', tags={
         'key1': 'val1', 'application': 'new_app'})
     self.assertIsNotNone(span)
     self.assertIsNotNone(span.get_tags())
     self.assertIsNotNone(span.get_tags_as_list())
     self.assertIsNotNone(span.get_tags_as_map())
     self.assertEqual(7, len(span.get_tags_as_map()))
     self.assertTrue('new_app' in span.get_tags_as_map().get('application'))
     self.assertTrue('service' in span.get_tags_as_map().get('service'))
     self.assertTrue('us-west-1' in span.get_tags_as_map().get('cluster'))
     self.assertTrue('primary' in span.get_tags_as_map().get('shard'))
     self.assertTrue('custom_v' in span.get_tags_as_map().get('custom_k'))
     self.assertTrue('val1' in span.get_tags_as_map().get('key1'))
     span.finish()
     tracer.close()
 def test_multi_valued_tags(self):
     """Test Multi-valued Tags."""
     tracer = WavefrontTracer(ConsoleReporter(), self.application_tags)
     span = tracer.start_span("test_op",
                              tags=[("key1", "val1"), ("key1", "val2")])
     self.assertIsNotNone(span)
     self.assertIsNotNone(span.get_tags())
     self.assertIsNotNone(span.get_tags_as_list())
     self.assertIsNotNone(span.get_tags_as_map())
     self.assertEqual(6, len(span.get_tags_as_map()))
     self.assertTrue("app" in span.get_tags_as_map().get("application"))
     self.assertTrue("service" in span.get_tags_as_map().get("service"))
     self.assertTrue("us-west-1" in span.get_tags_as_map().get("cluster"))
     self.assertTrue("primary" in span.get_tags_as_map().get("shard"))
     self.assertTrue("custom_v" in span.get_tags_as_map().get("custom_k"))
     self.assertTrue("val1" in span.get_tags_as_map().get("key1"))
     self.assertTrue("val2" in span.get_tags_as_map().get("key1"))
     span.finish()
     tracer.close()
Example #8
0
 def test_global_multi_valued_tags(self):
     """Test Global Multi-valued Tags."""
     global_tags = [('key1', 'val1'), ('key1', 'val2')]
     tracer = WavefrontTracer(ConsoleReporter(), self.application_tags,
                              global_tags)
     span = tracer.start_span(operation_name='test_op')
     self.assertIsNotNone(span)
     self.assertIsNotNone(span.get_tags())
     self.assertIsNotNone(span.get_tags_as_list())
     self.assertIsNotNone(span.get_tags_as_map())
     self.assertEqual(7, len(span.get_tags_as_map()))
     self.assertTrue('app' in span.get_tags_as_map().get('application'))
     self.assertTrue('service' in span.get_tags_as_map().get('service'))
     self.assertTrue('us-west-1' in span.get_tags_as_map().get('cluster'))
     self.assertTrue('primary' in span.get_tags_as_map().get('shard'))
     self.assertTrue('custom_v' in span.get_tags_as_map().get('custom_k'))
     self.assertTrue('val1' in span.get_tags_as_map().get('key1'))
     self.assertTrue('val2' in span.get_tags_as_map().get('key1'))
     span.finish()
     tracer.close()
Example #9
0
 def test_global_tags(self):
     """Test Global Tags."""
     global_tags = [('foo1', 'bar1'), ('foo2', 'bar2')]
     tracer = WavefrontTracer(ConsoleReporter(), self.application_tags,
                              global_tags)
     span = tracer.start_span(operation_name='test_op',
                              tags=[('foo3', 'bar3')])
     self.assertIsNotNone(span)
     self.assertIsNotNone(span.get_tags())
     self.assertIsNotNone(span.get_tags_as_list())
     self.assertIsNotNone(span.get_tags_as_map())
     self.assertEqual(9, len(span.get_tags()))
     self.assertTrue('app' in span.get_tags_as_map().get('application'))
     self.assertTrue('service' in span.get_tags_as_map().get('service'))
     self.assertTrue('us-west-1' in span.get_tags_as_map().get('cluster'))
     self.assertTrue('primary' in span.get_tags_as_map().get('shard'))
     self.assertTrue('custom_v' in span.get_tags_as_map().get('custom_k'))
     self.assertTrue('bar1' in span.get_tags_as_map().get('foo1'))
     self.assertTrue('bar2' in span.get_tags_as_map().get('foo2'))
     self.assertTrue('bar3' in span.get_tags_as_map().get('foo3'))
     span.finish()
     tracer.close()
Example #10
0
 def test_global_tags(self):
     """Test Global Tags."""
     global_tags = [("foo1", "bar1"), ("foo2", "bar2")]
     tracer = WavefrontTracer(ConsoleReporter(), self.application_tags,
                              global_tags)
     span = tracer.start_span(operation_name="test_op",
                              tags=[("foo3", "bar3")])
     self.assertIsNotNone(span)
     self.assertIsNotNone(span.get_tags())
     self.assertIsNotNone(span.get_tags_as_list())
     self.assertIsNotNone(span.get_tags_as_map())
     self.assertEqual(8, len(span.get_tags()))
     self.assertTrue("app" in span.get_tags_as_map().get("application"))
     self.assertTrue("service" in span.get_tags_as_map().get("service"))
     self.assertTrue("us-west-1" in span.get_tags_as_map().get("cluster"))
     self.assertTrue("primary" in span.get_tags_as_map().get("shard"))
     self.assertTrue("custom_v" in span.get_tags_as_map().get("custom_k"))
     self.assertTrue("bar1" in span.get_tags_as_map().get("foo1"))
     self.assertTrue("bar2" in span.get_tags_as_map().get("foo2"))
     self.assertTrue("bar3" in span.get_tags_as_map().get("foo3"))
     span.finish()
     tracer.close()
 def test_error_span_duration_histogram(self, wf_sender):
     """Test duration histogram generated from error span."""
     operation_name = 'dummy_op'
     source = 'wavefront_source'
     wf_sender = wf_sender()
     tracer = WavefrontTracer(WavefrontSpanReporter(wf_sender, source),
                              self.application_tags,
                              report_frequency_millis=500)
     with freezegun.freeze_time(datetime.datetime(
             year=1, month=1, day=1)) as frozen_datetime:
         span = tracer.start_active_span(operation_name=operation_name,
                                         tags=[('tenant', 'tenant1'),
                                               ('env', 'staging')])
         span.span.set_tag(opentracing.ext.tags.ERROR, True)
         span.close()
         frozen_datetime.tick(delta=datetime.timedelta(seconds=61))
         time.sleep(1)
         tracer.close()
     wf_sender.assert_has_calls([
         mock.call.send_distribution(
             centroids=mock.ANY,
             histogram_granularities={'!M'},
             name='tracing.derived.app.service.{}.duration.'
             'micros'.format(operation_name),
             source=source,
             tags={
                 'application': 'app',
                 'service': 'service',
                 'cluster': 'us-west-1',
                 'shard': 'primary',
                 'error': 'true',
                 'custom_k': 'custom_v',
                 'component': 'none',
                 'operationName': operation_name,
                 'span.kind': NULL_TAG_VAL
             },
             timestamp=mock.ANY)
     ],
                                any_order=True)
    def test_forced_sampling(self):
        """Test span with forced sampling."""
        tracer = WavefrontTracer(ConsoleReporter(),
                                 self.application_tags,
                                 samplers=[ConstantSampler(False)])
        span = tracer.start_span('test_op')
        self.assertIsNotNone(span)
        self.assertIsNotNone(span.context)
        self.assertIsNotNone(span.context.get_sampling_decision())
        self.assertFalse(span.context.get_sampling_decision())

        span.set_tag(opentracing.ext.tags.SAMPLING_PRIORITY, 1)
        self.assertIsNotNone(span.context.get_sampling_decision())
        self.assertTrue(span.context.get_sampling_decision())

        span = tracer.start_span('test_op')
        self.assertIsNotNone(span)
        self.assertIsNotNone(span.context)
        self.assertIsNotNone(span.context.get_sampling_decision())
        self.assertFalse(span.context.get_sampling_decision())

        span.set_tag(opentracing.ext.tags.ERROR, True)
        self.assertIsNotNone(span.context.get_sampling_decision())
        self.assertTrue(span.context.get_sampling_decision())
Example #13
0
 def test_sampling(self):
     """Test Sampling."""
     tracer = WavefrontTracer(ConsoleReporter(),
                              self.application_tags,
                              samplers=[ConstantSampler(True)])
     self.assertTrue(tracer.sample('test_op', 1, 0))
     tracer = WavefrontTracer(ConsoleReporter(),
                              self.application_tags,
                              samplers=[ConstantSampler(False)])
     self.assertFalse(tracer.sample('test_op', 1, 0))
Example #14
0
 def test_inject_extract(self):
     """Test Inject / Extract."""
     tracer = WavefrontTracer(ConsoleReporter(), self.application_tags)
     span = tracer.start_span('test_op')
     self.assertIsNotNone(span)
     span.set_baggage_item("customer", "test_customer")
     span.set_baggage_item("request_type", "mobile")
     carrier = {}
     tracer.inject(span.context, Format.TEXT_MAP, carrier)
     span.finish()
     ctx = tracer.extract(Format.TEXT_MAP, carrier)
     self.assertEqual("test_customer", ctx.get_baggage_item("customer"))
     self.assertEqual("mobile", ctx.get_baggage_item("request_type"))
Example #15
0
 def test_inject_extract(self):
     """Test Inject / Extract."""
     tracer = WavefrontTracer(ConsoleReporter(),
                              self.application_tags,
                              samplers=[ConstantSampler(True)])
     span = tracer.start_span('test_op')
     self.assertIsNotNone(span)
     span.set_baggage_item('customer', 'test_customer')
     span.set_baggage_item('request_type', 'mobile')
     carrier = {}
     tracer.inject(span.context, opentracing.propagation.Format.TEXT_MAP,
                   carrier)
     span.finish()
     ctx = tracer.extract(opentracing.propagation.Format.TEXT_MAP, carrier)
     self.assertTrue(ctx.is_sampled())
     self.assertTrue(ctx.get_sampling_decision())
     self.assertEqual('test_customer', ctx.get_baggage_item('customer'))
     self.assertEqual('mobile', ctx.get_baggage_item('request_type'))
Example #16
0
    def test_root_sampling(self):
        """Test root span with sampling."""
        tracer = WavefrontTracer(ConsoleReporter(), self.application_tags,
                                 samplers=[ConstantSampler(False)])
        span = tracer.start_span('test_op')
        self.assertIsNotNone(span)
        self.assertIsNotNone(span.context)
        self.assertEqual(0, len(span.get_parents()))
        self.assertEqual(0, len(span.get_follows()))
        self.assertIsNotNone(span.context.get_sampling_decision())
        self.assertFalse(span.context.get_sampling_decision())

        tracer = WavefrontTracer(ConsoleReporter(), self.application_tags,
                                 samplers=[ConstantSampler(True)])
        span = tracer.start_span('test_op')
        self.assertIsNotNone(span)
        self.assertIsNotNone(span.context)
        self.assertEqual(0, len(span.get_parents()))
        self.assertEqual(0, len(span.get_follows()))
        self.assertIsNotNone(span.context.get_sampling_decision())
        self.assertTrue(span.context.get_sampling_decision())
Example #17
0
WF_REPORTER = None
if WF_REPORTING_CONFIG and \
        WF_REPORTING_CONFIG.get('reportingMechanism') == 'direct':
    WF_REPORTER = WavefrontDirectReporter(
        server=WF_REPORTING_CONFIG.get('server'),
        token=WF_REPORTING_CONFIG.get('token'),
        reporting_interval=5,
        source=SOURCE).report_minute_distribution()
elif WF_REPORTING_CONFIG and \
        WF_REPORTING_CONFIG.get('reportingMechanism') == 'proxy':
    WF_REPORTER = WavefrontProxyReporter(
        host=WF_REPORTING_CONFIG.get('proxyHost'),
        port=WF_REPORTING_CONFIG.get('proxyMetricsPort'),
        distribution_port=WF_REPORTING_CONFIG.get('proxyDistributionsPort'),
        # tracing_port=WF_REPORTING_CONFIG.get('proxyTracingPort'),
        reporting_interval=5,
        source=SOURCE).report_minute_distribution()

    WF_REPORTER.wavefront_client._tracing_proxy_connection_handler = \
            ProxyConnectionHandler(WF_REPORTING_CONFIG.get('proxyHost'),
                WF_REPORTING_CONFIG.get('proxyTracingPort'),
                WF_REPORTER.wavefront_client._sdk_metrics_registry,
                'tracingHandler',
                timeout=10)

SPAN_REPORTER = WavefrontSpanReporter(client=WF_REPORTER.wavefront_client,
                                      source=SOURCE)

OPENTRACING_TRACING = DjangoTracing(
    WavefrontTracer(reporter=SPAN_REPORTER, application_tags=APPLICATION_TAGS))
Example #18
0
    WF_REPORTING_CONFIG = yaml.load(stream)

APPLICATION_TAGS = None
with open("applicationTags.yaml", "r") as stream:
    application_tags_yaml = yaml.load(stream)
    APPLICATION_TAGS = ApplicationTags(
        application=application_tags_yaml.get('application'),
        service=application_tags_yaml.get('service'),
        cluster=application_tags_yaml.get('cluster'),
        shard=application_tags_yaml.get('shard'),
        custom_tags=application_tags_yaml.get('customTags').items()
    )

SOURCE = WF_REPORTING_CONFIG.get('source') or socket.gethostname()

WF_REPORTER = None
if WF_REPORTING_CONFIG and \
        WF_REPORTING_CONFIG.get('reportingMechanism') == 'direct':
    WF_REPORTER = WavefrontDirectReporter(
        server=WF_REPORTING_CONFIG.get('server'),
        token=WF_REPORTING_CONFIG.get('token'),
        reporting_interval=5,
        source=SOURCE
    ).report_minute_distribution()

SPAN_REPORTER = WavefrontSpanReporter(client=WF_REPORTER.wavefront_client,
                                      source=SOURCE)

OPENTRACING_TRACING = DjangoTracing(WavefrontTracer(
    reporter=SPAN_REPORTER, application_tags=APPLICATION_TAGS))
Example #19
0
    # Create Wavefront Span Reporter using Wavefront Proxy Client.
    proxy_client = wavefront_sdk.WavefrontProxyClient(host=proxy_name,
                                                      metrics_port=proxy_port,
                                                      distribution_port=40000,
                                                      tracing_port=30000)

    proxy_reporter = WavefrontSpanReporter(client=proxy_client, source=myhost)

    # CompositeReporter takes a list of other reporters and invokes them one by one
    # Use ConsoleReporter to output span data to console
    #composite_reporter = CompositeReporter(proxy_reporter, ConsoleReporter())
    #composite_reporter = CompositeReporter(ConsoleReporter())
    composite_reporter = CompositeReporter(proxy_reporter)

    tracer = WavefrontTracer(reporter=composite_reporter,
                             application_tags=application_tag)

    # Create span1, return a newly started and activated Scope.
    scope = tracer.start_active_span(operation_name='journeyRequest',
                                     tags=global_tags,
                                     ignore_active_span=True,
                                     finish_on_close=True)
    span1 = scope.span
    time.sleep(getRandomNumber())
    span1.finish()

    # Create span2, child of span1
    span2 = tracer.start_span(
        operation_name='ParseRequest',
        #references=opentracing.child_of(span1.context),
        tags=global_tags)
Example #20
0
    direct_reporter = WavefrontSpanReporter(direct_client)

    # Create Wavefront Span Reporter using Wavefront Proxy Client.
    proxy_client = WavefrontProxyClient(host="localhost",
                                        tracing_port=30000,
                                        distribution_port=40000,
                                        metrics_port=2878)
    proxy_reporter = WavefrontSpanReporter(proxy_client)

    # Create Composite reporter.
    # Use ConsoleReporter to output span data to console.
    composite_reporter = CompositeReporter(proxy_reporter, direct_reporter,
                                           ConsoleReporter())

    # Create Tracer with Composite Reporter.
    tracer = WavefrontTracer(reporter=composite_reporter)

    global_tags = [("global_key", "global_val")]

    # Create span1, return a newly started and activated Scope.
    scope = tracer.start_active_span(operation_name="span1",
                                     tags=global_tags,
                                     ignore_active_span=True,
                                     finish_on_close=True)
    span1 = scope.span
    time.sleep(1)

    # Create span2, span3 child of span1.
    span2 = tracer.start_span(operation_name="span2",
                              references=child_of(span1.context),
                              tags=[("span2_key", "span2_val")])
# Create Wavefront Span Reporter using Wavefront Proxy Client.
proxy_client = wavefront_sdk.WavefrontProxyClient(host='localhost',
                                                  metrics_port=2878,
                                                  distribution_port=40000,
                                                  tracing_port=30000)

proxy_reporter = WavefrontSpanReporter(client=proxy_client, source=myhost)

# CompositeReporter takes a list of other reporters and invokes them one by one
# Use ConsoleReporter to output span data to console
#composite_reporter = CompositeReporter(proxy_reporter, ConsoleReporter())
#composite_reporter = CompositeReporter(ConsoleReporter())
composite_reporter = CompositeReporter(proxy_reporter)

tracer = WavefrontTracer(reporter=composite_reporter,
                         application_tags=application_tag)

# Create span1, return a newly started and activated Scope.
global_tags = [('Showroom', 'France')]
scope = tracer.start_active_span(operation_name='Google API calls',
                                 tags=global_tags,
                                 ignore_active_span=True,
                                 finish_on_close=True)
span1 = scope.span

# waiting for timeDelta in order to reproduce the Google API call duration
time.sleep(timeDelta)  # en sec, accepte des floats

# Create span2, child of span1
span2 = tracer.start_span(operation_name='Ingest data',
                          references=opentracing.child_of(span1.context),
 def test_custom_red_metrics_tags(self, wf_sender):
     """Test custom RED metrics tags."""
     operation_name = 'dummy_op'
     source = 'wavefront_source'
     wf_sender = wf_sender()
     tracer = WavefrontTracer(WavefrontSpanReporter(wf_sender, source),
                              self.application_tags,
                              samplers=[ConstantSampler(True)],
                              report_frequency_millis=500,
                              red_metrics_custom_tag_keys={'env', 'tenant'})
     with freezegun.freeze_time(datetime.datetime(
             year=1, month=1, day=1)) as frozen_datetime:
         span = tracer.start_active_span(operation_name=operation_name,
                                         tags=[('tenant', 'tenant1'),
                                               ('env', 'staging')])
         span.close()
         frozen_datetime.tick(delta=datetime.timedelta(seconds=61))
         time.sleep(1)
         tracer.close()
     wf_sender.assert_has_calls([
         mock.call.send_span(operation_name,
                             mock.ANY,
                             0,
                             source,
                             mock.ANY,
                             mock.ANY, [], [], [('tenant', 'tenant1'),
                                                ('env', 'staging'),
                                                ('application', 'app'),
                                                ('service', 'service'),
                                                ('cluster', 'us-west-1'),
                                                ('shard', 'primary'),
                                                ('custom_k', 'custom_v'),
                                                ('component', 'none')],
                             span_logs=[]),
         mock.call.send_metric(
             name='tracing.derived.app.service.{}.invocation.'
             'count'.format(operation_name),
             source=source,
             tags={
                 'application': 'app',
                 'service': 'service',
                 'cluster': 'us-west-1',
                 'shard': 'primary',
                 'component': 'none',
                 'custom_k': 'custom_v',
                 'operationName': operation_name,
                 'tenant': 'tenant1',
                 'env': 'staging',
                 'span.kind': NULL_TAG_VAL
             },
             timestamp=None,
             value=1),
         mock.call.send_metric(
             name='tracing.derived.app.service.{}.total_time.millis.'
             'count'.format(operation_name),
             source=source,
             tags={
                 'application': 'app',
                 'service': 'service',
                 'cluster': 'us-west-1',
                 'shard': 'primary',
                 'component': 'none',
                 'custom_k': 'custom_v',
                 'operationName': 'dummy_op',
                 'tenant': 'tenant1',
                 'env': 'staging',
                 'span.kind': NULL_TAG_VAL
             },
             timestamp=None,
             value=mock.ANY),
         mock.call.send_metric(
             '~component.heartbeat', 1.0, mock.ANY, source, {
                 'application': 'app',
                 'cluster': 'us-west-1',
                 'service': 'service',
                 'shard': 'primary',
                 'custom_k': 'custom_v',
                 'component': 'wavefront-generated'
             }),
         mock.call.send_distribution(
             centroids=mock.ANY,
             histogram_granularities={'!M'},
             name='tracing.derived.app.service.{}.duration.'
             'micros'.format(operation_name),
             source=source,
             tags={
                 'application': 'app',
                 'service': 'service',
                 'cluster': 'us-west-1',
                 'shard': 'primary',
                 'component': 'none',
                 'custom_k': 'custom_v',
                 'operationName': operation_name,
                 'tenant': 'tenant1',
                 'env': 'staging',
                 'span.kind': NULL_TAG_VAL
             },
             timestamp=mock.ANY)
     ],
                                any_order=True)
Example #23
0
    metrics_port=2878,
    distribution_port=40000,
    tracing_port=30000
    # internal_flush=2  not working
)

proxy_reporter = WavefrontSpanReporter(client=proxy_client,
                                       source='ALEXH_tracing-example')

# Create Composite reporter.
# Create Tracer with Composite Reporter.
# CompositeReporter takes a list of other reporters and invokes them one by one
# Use ConsoleReporter to output span data to console
composite_reporter = CompositeReporter(proxy_reporter, ConsoleReporter())

tracer = WavefrontTracer(reporter=composite_reporter,
                         application_tags=application_tag)

global_tags = [('global_key', 'global_val')]

# Create span1, return a newly started and activated Scope.
scope = tracer.start_active_span(operation_name='span1',
                                 tags=global_tags,
                                 ignore_active_span=True,
                                 finish_on_close=True)
span1 = scope.span
time.sleep(0.1)

# Create span2, span3 child of span1.
span2 = tracer.start_span(operation_name='span2',
                          references=opentracing.child_of(span1.context),
                          tags=[('span2_key', 'span2_val')])
Example #24
0
        distribution_port=40000,
        tracing_port=30000
        # internal_flush=2  not working 
)

proxy_reporter = WavefrontSpanReporter(client=proxy_client, source='ALEXH_tracing-example')

# Create Composite reporter.
# Create Tracer with Composite Reporter.
# CompositeReporter takes a list of other reporters and invokes them one by one
# Use ConsoleReporter to output span data to console
composite_reporter = CompositeReporter(proxy_reporter, ConsoleReporter())   



tracer = WavefrontTracer(reporter=composite_reporter, application_tags=application_tag)


global_tags = [('global_key', 'global_val')]


scope = tracer.start_active_span(
    	operation_name='span1',
        tags=global_tags,
        ignore_active_span=True,
        finish_on_close=True
)
span1 = scope.span