|
2 | 2 | import os
|
3 | 3 |
|
4 | 4 | from opentelemetry import trace
|
5 |
| -from opentelemetry.sdk.trace import TracerSource |
6 |
| -from opentelemetry.sdk.trace.export import BatchExportSpanProcessor |
7 | 5 | from opentelemetry.ext.lightstep import LightStepSpanExporter
|
| 6 | +from opentelemetry.sdk.trace import TracerProvider |
| 7 | +from opentelemetry.sdk.trace.export import BatchExportSpanProcessor |
| 8 | + |
8 | 9 |
|
9 |
| -trace.set_preferred_tracer_source_implementation(lambda T: TracerSource()) |
10 | 10 | # configure the LightStepSpanExporter as our exporter
|
11 | 11 | exporter = LightStepSpanExporter(
|
12 |
| - name="test-service", token=os.getenv("LIGHTSTEP_TOKEN", ""), verbosity=5 |
| 12 | + name=os.getenv("LIGHTSTEP_SERVICE_NAME", "test-service-name"), |
| 13 | + token=os.getenv("LIGHTSTEP_ACCESS_TOKEN", ""), |
| 14 | + verbosity=5, |
| 15 | + host="ingest.staging.lightstep.com", |
| 16 | + service_version=os.getenv("LIGHTSTEP_SERVICE_VERSION", "0.0.1"), |
13 | 17 | )
|
14 | 18 | span_processor = BatchExportSpanProcessor(exporter)
|
15 |
| -trace.tracer_source().add_span_processor(span_processor) |
| 19 | + |
| 20 | + |
| 21 | +trace.set_tracer_provider(TracerProvider()) |
| 22 | +trace.get_tracer_provider().add_span_processor(span_processor) |
16 | 23 |
|
17 | 24 | tracer = trace.get_tracer("lightstep-exporter-example")
|
18 |
| -with tracer.start_as_current_span("foo"): |
| 25 | +with tracer.start_as_current_span("foo") as span: |
| 26 | + span.set_attribute("platform", "osx") |
| 27 | + span.set_attribute("version", "1.2.3") |
| 28 | + span.add_event("event in foo", {"name": "foo1"}) |
19 | 29 | with tracer.start_as_current_span("bar"):
|
20 | 30 | with tracer.start_as_current_span("baz") as s:
|
21 | 31 | s.set_attribute("test", "bah")
|
|
0 commit comments