def test_error_on_bad_config(self): with self.assertRaises(Exception): lightstep_streaming.Tracer() with self.assertRaises(Exception): lightstep_streaming.Tracer('abc') with self.assertRaises(Exception): lightstep_streaming.Tracer(xyz='abc')
def build_tracer(): tracer_name = args.tracer if args.trace and tracer_name == "vanilla": logging.info("We're using the python tracer.") import lightstep return lightstep.Tracer( component_name='isaac_service', collector_port=SATELLITE_PORTS[0], collector_host='localhost', collector_encryption='none', use_http=True, access_token='developer', periodic_flush_seconds=REPORTING_PERIOD, max_span_records=MAX_BUFFERED_SPANS, ) elif args.trace and tracer_name == "cpp": logging.info("We're using the python-cpp tracer.") import lightstep_streaming return lightstep_streaming.Tracer( component_name='isaac_service', access_token='developer', use_stream_recorder=True, collector_plaintext=True, satellite_endpoints=[{ 'host': 'localhost', 'port': p } for p in SATELLITE_PORTS], max_buffered_spans=MAX_BUFFERED_SPANS, reporting_period=REPORTING_PERIOD * 10**6, # s --> us ) logging.info("We're using a NoOp tracer.") return opentracing.Tracer()
def test_report_span(self): tracer = lightstep_streaming.Tracer(access_token='abc', use_stream_recorder=True, collector_plaintext=True, satellite_endpoints=[{ 'host': 'locahost', 'port': 123 }]) self.assertEqual(tracer.num_spans_sent, 0) self.assertEqual(tracer.num_spans_dropped, 0)
import sys import lightstep_streaming if len(sys.argv) != 3: print("Usage: span_probe.py <host> <port>") sys.exit(-1) host = sys.argv[1] port = sys.argv[2] tracer = lightstep_streaming.Tracer( component_name = "span_probe", access_token = "abc", collector_plaintext = True, use_stream_recorder = True, satellite_endpoints = [{ 'host': host, 'port': int(port) }] ) span = tracer.start_span('A') span.finish() tracer.close()