Skip to content

Commit

Permalink
rename span processor (#1656)
Browse files Browse the repository at this point in the history
  • Loading branch information
alrex authored Mar 1, 2021
1 parent 326b7b0 commit 489a81e
Show file tree
Hide file tree
Showing 35 changed files with 101 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
# Otherwise, set variable to the commit of your branch on
# opentelemetry-python-contrib which is compatible with these Core repo
# changes.
CONTRIB_REPO_SHA: c86562fcddcf8fd037492de3880790776abe79ce
CONTRIB_REPO_SHA: 63a755348c2c9a2b83da85a5c72487ddc507b8b4

jobs:
build:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1652])(https://github.com/open-telemetry/opentelemetry-python/pull/1652)
- Rename Resource's `create_empty` to `get_empty`
([#1653])(https://github.com/open-telemetry/opentelemetry-python/pull/1653)
- Renamed `BatchExportSpanProcessor` to `BatchSpanProcessor` and `SimpleExportSpanProcessor` to
`SimpleSpanProcessor`
([#1656])(https://github.com/open-telemetry/opentelemetry-python/pull/1656)

## [0.18b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.18b0) - 2021-02-16

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/auto-instrumentation/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
SimpleSpanProcessor,
)

trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer_provider().get_tracer(__name__)

trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
SimpleSpanProcessor(ConsoleSpanExporter())
)


Expand Down
4 changes: 2 additions & 2 deletions docs/examples/auto-instrumentation/server_instrumented.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
SimpleSpanProcessor,
)
from opentelemetry.trace.propagation.textmap import DictGetter

Expand All @@ -30,7 +30,7 @@
tracer = trace.get_tracer_provider().get_tracer(__name__)

trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
SimpleSpanProcessor(ConsoleSpanExporter())
)


Expand Down
4 changes: 2 additions & 2 deletions docs/examples/auto-instrumentation/server_uninstrumented.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
SimpleSpanProcessor,
)

app = Flask(__name__)

trace.set_tracer_provider(TracerProvider())

trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
SimpleSpanProcessor(ConsoleSpanExporter())
)


Expand Down
4 changes: 2 additions & 2 deletions docs/examples/basic_tracer/basic_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
SimpleSpanProcessor,
)

trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
SimpleSpanProcessor(ConsoleSpanExporter())
)
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("foo"):
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/basic_tracer/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
SimpleSpanProcessor,
)

resource = Resource.create({"service.name": "basic_service"})

trace.set_tracer_provider(TracerProvider(resource=resource))

trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
SimpleSpanProcessor(ConsoleSpanExporter())
)
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("foo"):
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/django/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
SimpleSpanProcessor,
)

trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer_provider().get_tracer(__name__)

trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
SimpleSpanProcessor(ConsoleSpanExporter())
)


Expand Down
4 changes: 2 additions & 2 deletions docs/examples/django/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
SimpleSpanProcessor,
)

trace.set_tracer_provider(TracerProvider())

trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
SimpleSpanProcessor(ConsoleSpanExporter())
)


Expand Down
4 changes: 2 additions & 2 deletions docs/examples/opencensus-exporter-tracer/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
OpenCensusSpanExporter,
)
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.sdk.trace.export import BatchSpanProcessor

exporter = OpenCensusSpanExporter(
service_name="basic-service", endpoint="localhost:55678"
)

trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
span_processor = BatchExportSpanProcessor(exporter)
span_processor = BatchSpanProcessor(exporter)

trace.get_tracer_provider().add_span_processor(span_processor)
with tracer.start_as_current_span("foo"):
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/opentracing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from opentelemetry import trace
from opentelemetry.exporter.jaeger import JaegerSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.shim import opentracing_shim

# Configure the tracer using the default implementation
Expand All @@ -18,7 +18,7 @@
agent_host_name="localhost",
agent_port=6831,
)
span_processor = SimpleExportSpanProcessor(jaeger_exporter)
span_processor = SimpleSpanProcessor(jaeger_exporter)
tracer_provider.add_span_processor(span_processor)

# Create an OpenTracing shim. This implements the OpenTracing tracer API, but
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/flask_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
SimpleSpanProcessor,
)

trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
SimpleSpanProcessor(ConsoleSpanExporter())
)

app = flask.Flask(__name__)
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/jaeger_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from opentelemetry import trace
from opentelemetry.exporter import jaeger
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.sdk.trace.export import BatchSpanProcessor

trace.set_tracer_provider(TracerProvider())

Expand All @@ -27,7 +27,7 @@
)

trace.get_tracer_provider().add_span_processor(
BatchExportSpanProcessor(jaeger_exporter)
BatchSpanProcessor(jaeger_exporter)
)

tracer = trace.get_tracer(__name__)
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/otlpcollector_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from opentelemetry import trace
from opentelemetry.exporter.otlp.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.sdk.trace.export import BatchSpanProcessor

span_exporter = OTLPSpanExporter(
# optional
Expand All @@ -28,7 +28,7 @@
)
tracer_provider = TracerProvider()
trace.set_tracer_provider(tracer_provider)
span_processor = BatchExportSpanProcessor(span_exporter)
span_processor = BatchSpanProcessor(span_exporter)
tracer_provider.add_span_processor(span_processor)

# Configure the tracer to use the collector exporter
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/tracing_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
SimpleSpanProcessor,
)

trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
SimpleSpanProcessor(ConsoleSpanExporter())
)

tracer = trace.get_tracer(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from opentelemetry import trace
from opentelemetry.exporter import jaeger
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.sdk.trace.export import BatchSpanProcessor

trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
Expand Down Expand Up @@ -35,8 +35,8 @@
# transport_format="protobuf",
# )

# create a BatchExportSpanProcessor and add the exporter to it
span_processor = BatchExportSpanProcessor(jaeger_exporter)
# create a BatchSpanProcessor and add the exporter to it
span_processor = BatchSpanProcessor(jaeger_exporter)

# add to the tracer factory
trace.get_tracer_provider().add_span_processor(span_processor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from opentelemetry import trace
from opentelemetry.exporter import jaeger
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.sdk.trace.export import BatchSpanProcessor
trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
Expand All @@ -50,8 +50,8 @@
# max_tag_value_length=None # optional
)
# Create a BatchExportSpanProcessor and add the exporter to it
span_processor = BatchExportSpanProcessor(jaeger_exporter)
# Create a BatchSpanProcessor and add the exporter to it
span_processor = BatchSpanProcessor(jaeger_exporter)
# add to the tracer
trace.get_tracer_provider().add_span_processor(span_processor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from opentelemetry.exporter.otlp.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.sdk.trace.export import BatchSpanProcessor
# Resource can be required for some backends, e.g. Jaeger
# If resource wouldn't be set - traces wouldn't appears in Jaeger
Expand All @@ -55,7 +55,7 @@
otlp_exporter = OTLPSpanExporter(endpoint="localhost:4317", insecure=True)
span_processor = BatchExportSpanProcessor(otlp_exporter)
span_processor = BatchSpanProcessor(otlp_exporter)
trace.get_tracer_provider().add_span_processor(span_processor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from opentelemetry.exporter.otlp.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider, sampling
from opentelemetry.sdk.trace.export import (
BatchExportSpanProcessor,
SimpleExportSpanProcessor,
BatchSpanProcessor,
SimpleSpanProcessor,
)


Expand All @@ -40,7 +40,7 @@ def __init__(self, channel):
new=MockTraceServiceStub,
)
def test_simple_span_processor(benchmark):
tracer = get_tracer_with_processor(SimpleExportSpanProcessor)
tracer = get_tracer_with_processor(SimpleSpanProcessor)

def create_spans_to_be_exported():
span = tracer.start_span("benchmarkedSpan",)
Expand All @@ -59,14 +59,14 @@ def create_spans_to_be_exported():
new=MockTraceServiceStub,
)
def test_batch_span_processor(benchmark):
"""Runs benchmark tests using BatchExportSpanProcessor.
"""Runs benchmark tests using BatchSpanProcessor.
One particular call by pytest-benchmark will be much more expensive since
the batch export thread will activate and consume a lot of CPU to process
all the spans. For this reason, focus on the average measurement. Do not
focus on the min/max measurements which will be misleading.
"""
tracer = get_tracer_with_processor(BatchExportSpanProcessor)
tracer = get_tracer_with_processor(BatchSpanProcessor)

def create_spans_to_be_exported():
span = tracer.start_span("benchmarkedSpan",)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
from opentelemetry.sdk.trace import StatusCode as SDKStatusCode
from opentelemetry.sdk.trace import TracerProvider, _Span
from opentelemetry.sdk.trace.export import (
SimpleExportSpanProcessor,
SimpleSpanProcessor,
SpanExportResult,
)
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
Expand Down Expand Up @@ -114,9 +114,7 @@ class TestOTLPSpanExporter(TestCase):
def setUp(self):
tracer_provider = TracerProvider()
self.exporter = OTLPSpanExporter(insecure=True)
tracer_provider.add_span_processor(
SimpleExportSpanProcessor(self.exporter)
)
tracer_provider.add_span_processor(SimpleSpanProcessor(self.exporter))
self.tracer = tracer_provider.get_tracer(__name__)

self.server = server(ThreadPoolExecutor(max_workers=10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from opentelemetry import trace
from opentelemetry.exporter import zipkin
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.sdk.trace.export import BatchSpanProcessor
trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
Expand All @@ -50,8 +50,8 @@
# max_tag_value_length=256
)
# Create a BatchExportSpanProcessor and add the exporter to it
span_processor = BatchExportSpanProcessor(zipkin_exporter)
# Create a BatchSpanProcessor and add the exporter to it
span_processor = BatchSpanProcessor(zipkin_exporter)
# add to the tracer
trace.get_tracer_provider().add_span_processor(span_processor)
Expand Down
7 changes: 2 additions & 5 deletions opentelemetry-distro/src/opentelemetry/distro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
from opentelemetry.instrumentation.distro import BaseDistro
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
BatchExportSpanProcessor,
SpanExporter,
)
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SpanExporter
from opentelemetry.sdk.trace.id_generator import IdGenerator

logger = getLogger(__file__)
Expand Down Expand Up @@ -95,7 +92,7 @@ def _init_tracing(
exporter_args["service_name"] = service_name

provider.add_span_processor(
BatchExportSpanProcessor(exporter_class(**exporter_args))
BatchSpanProcessor(exporter_class(**exporter_args))
)


Expand Down
Loading

0 comments on commit 489a81e

Please sign in to comment.