-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add instructions to send traces in SPM Dev Env #3996
Changes from 4 commits
c811a31
1b47246
9f4f8a2
44fb655
ab3dd6b
a668db7
af1a170
5c65564
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.venv |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,7 @@ services: | |
- METRICS_STORAGE_TYPE=prometheus | ||
- PROMETHEUS_SERVER_URL=http://prometheus:9090 | ||
ports: | ||
- "14250:14250" | ||
- "14268:14268" | ||
- "6831:6831/udp" | ||
- "16686:16686" | ||
- "16685:16685" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't one of these ports still needed to receive data from OTEL collector? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, all ports are accessible between containers. Only the ports that need to be exposed to the "outside world" should be listed under |
||
otel_collector: | ||
networks: | ||
- backend | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# jaeger_example.py | ||
from opentelemetry import trace | ||
from opentelemetry.exporter.jaeger.thrift import JaegerExporter | ||
from opentelemetry.trace import SpanKind | ||
from opentelemetry.sdk.trace import TracerProvider | ||
from opentelemetry.sdk.trace.export import BatchSpanProcessor | ||
from opentelemetry.sdk.resources import Resource | ||
|
||
resource = Resource(attributes={ | ||
"service.name": "my_service" | ||
}) | ||
|
||
trace.set_tracer_provider(TracerProvider(resource=resource)) | ||
|
||
jaeger_exporter = JaegerExporter( | ||
collector_endpoint="http://localhost:14278/api/traces", | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest using OTLP exporter instead and exposing OTLP port in the OTEL Collector. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my learning, why the preference for OTLP over Jaeger formatted spans? Done in ab3dd6b. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because jaeger SDKs are deprecated, the recommended path is native OTEL |
||
|
||
trace.get_tracer_provider().add_span_processor( | ||
BatchSpanProcessor(jaeger_exporter) | ||
) | ||
|
||
tracer = trace.get_tracer(__name__) | ||
|
||
with tracer.start_as_current_span("foo", kind=SpanKind.SERVER): | ||
with tracer.start_as_current_span("bar", kind=SpanKind.SERVER): | ||
with tracer.start_as_current_span("baz", kind=SpanKind.SERVER): | ||
print("Hello world from OpenTelemetry Python!") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Deprecated==1.2.13 | ||
googleapis-common-protos==1.56.2 | ||
grpcio==1.50.0 | ||
opentelemetry-api==1.13.0 | ||
opentelemetry-exporter-jaeger==1.13.0 | ||
opentelemetry-exporter-jaeger-proto-grpc==1.13.0 | ||
opentelemetry-exporter-jaeger-thrift==1.13.0 | ||
opentelemetry-sdk==1.13.0 | ||
opentelemetry-semantic-conventions==0.34b0 | ||
protobuf==3.20.3 | ||
six==1.16.0 | ||
thrift==0.16.0 | ||
typing_extensions==4.4.0 | ||
wrapt==1.14.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered defining this as a swagger spec, but given its only "user" is Jaeger UI, I don't think it's worth the effort.