Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update opentracing and opencesus docs examples to not use JaegerExporter #4023

Merged
merged 11 commits into from
Jul 9, 2024
8 changes: 4 additions & 4 deletions docs/examples/opencensus-shim/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Start Jaeger
.. code-block:: sh

docker run --rm \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 4317:4317 \
-p 4318:4318 \
-p 16686:16686 \
jaegertracing/all-in-one:1.13 \
jaegertracing/all-in-one:latest \
--log-level=debug

Python Dependencies
Expand All @@ -43,7 +43,7 @@ Alternatively, you can install the Python dependencies separately:
pip install \
opentelemetry-api \
opentelemetry-sdk \
opentelemetry-exporter-jaeger \
opentelemetry-exporter-otlp \
opentelemetry-opencensus-shim \
opentelemetry-instrumentation-sqlite3 \
opencensus \
Expand Down
7 changes: 3 additions & 4 deletions docs/examples/opencensus-shim/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from opencensus.ext.flask.flask_middleware import FlaskMiddleware

from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
arunk1988 marked this conversation as resolved.
Show resolved Hide resolved
from opentelemetry.instrumentation.sqlite3 import SQLite3Instrumentor
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
Expand All @@ -40,9 +40,8 @@
# Configure OTel to export traces to Jaeger
tracer_provider.add_span_processor(
BatchSpanProcessor(
JaegerExporter(
agent_host_name="localhost",
agent_port=6831,
OTLPSpanExporter(
endpoint="localhost:4317",
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/opencensus-shim/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opentelemetry-api
opentelemetry-sdk
opentelemetry-exporter-jaeger
opentelemetry-exporter-otlp
opentelemetry-opencensus-shim
arunk1988 marked this conversation as resolved.
Show resolved Hide resolved
opentelemetry-instrumentation-sqlite3
opencensus
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/opentracing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Start Jaeger
.. code-block:: sh

docker run --rm \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 4317:4317 \
-p 4318:4318 \
-p 16686:16686 \
jaegertracing/all-in-one:1.13 \
jaegertracing/all-in-one:latest \
--log-level=debug

Redis
Expand Down Expand Up @@ -61,7 +61,7 @@ Alternatively, you can install the Python dependencies separately:
pip install \
opentelemetry-api \
opentelemetry-sdk \
opentelemetry-exporter-jaeger \
opentelemetry-exporter-otlp \
opentelemetry-opentracing-shim \
redis \
redis_opentracing
Expand Down
17 changes: 10 additions & 7 deletions docs/examples/opentracing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rediscache import RedisCache

from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
tammy-baylis-swi marked this conversation as resolved.
Show resolved Hide resolved
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.shim import opentracing_shim
Expand All @@ -12,13 +12,16 @@
trace.set_tracer_provider(TracerProvider())
tracer_provider = trace.get_tracer_provider()

# Configure the tracer to export traces to Jaeger
jaeger_exporter = JaegerExporter(
agent_host_name="localhost",
agent_port=6831,
# Create an OTLP gRPC span exporter
otlp_exporter = OTLPSpanExporter(
endpoint="localhost:4317",
arunk1988 marked this conversation as resolved.
Show resolved Hide resolved
# For insecure connection, useful for testing
insecure=True
arunk1988 marked this conversation as resolved.
Show resolved Hide resolved
)
# Add the exporter to the tracer provider
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(otlp_exporter)
)
span_processor = BatchSpanProcessor(jaeger_exporter)
tracer_provider.add_span_processor(span_processor)

# Create an OpenTracing shim. This implements the OpenTracing tracer API, but
# forwards calls to the underlying OpenTelemetry tracer.
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/opentracing/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opentelemetry-api
opentelemetry-sdk
opentelemetry-exporter-jaeger
opentelemetry-exporter-otlp
opentelemetry-opentracing-shim
redis
redis_opentracing
Empty file added test
arunk1988 marked this conversation as resolved.
Show resolved Hide resolved
Empty file.