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)
Beispiel #2
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))
Beispiel #3
0
else:
    #print('Les deux variables Wavefront existent')

    # Define tags
    application_tag = wavefront_sdk.common.ApplicationTags(application='TITO',
                                                           service='journey')
    global_tags = [('Showroom', 'France'), ('Home_Address', Home_Address),
                   ('Work_Address', Work_Address)]

    # 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)
 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)
Beispiel #5
0

application_tag = wavefront_sdk.common.ApplicationTags(application='ALEXapp',service='ALEXsvc')
    

# Create Wavefront Span Reporter using Wavefront Proxy Client.

proxy_client = wavefront_sdk.WavefrontProxyClient(
        host='localhost',
        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')]

Beispiel #6
0
from opentracing import child_of, follows_from
from wavefront_sdk import WavefrontDirectClient, WavefrontProxyClient
from wavefront_opentracing_sdk import WavefrontTracer
from wavefront_opentracing_sdk.reporting import CompositeReporter, \
    WavefrontSpanReporter, ConsoleReporter

# pylint: disable=invalid-name
if __name__ == "__main__":
    # Create Wavefront Span Reporter using Wavefront Direct Client.
    direct_client = WavefrontDirectClient(
        server="http://localhost:8080",
        token="9ea0d7c3-311a-419b-86b1-7a515f4aff76",
        max_queue_size=50000,
        batch_size=10000,
        flush_interval_seconds=5)
    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)