Add OpenTelemetry and basic tracing + dev infra#7163
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Greptile SummaryThis PR adds OpenTelemetry distributed tracing support to Fides, including:
Key Issues Found:
Confidence Score: 3/5
Important Files Changed
|
| # OpenTelemetry imports are optional - app should work without them | ||
| try: | ||
| from opentelemetry import trace | ||
| from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter |
There was a problem hiding this comment.
style: Unused import - OTLPSpanExporter is imported here but local imports are used inside _create_otlp_exporter instead.
| ConsoleSpanExporter, | ||
| SpanExporter, | ||
| ) | ||
| from opentelemetry.sdk.trace.sampling import ParentBasedTraceIdRatio |
There was a problem hiding this comment.
style: Unused import - ParentBasedTraceIdRatio is imported but never used (commented-out code on line 110).
| # Determine if we're using gRPC or HTTP based on the endpoint | ||
| endpoint = config.tracing.otlp_endpoint | ||
| protocol = config.tracing.otlp_protocol | ||
| exporter = config.tracing.otlp_exporter |
There was a problem hiding this comment.
style: exporter variable is assigned but never used.
Remove temporary increased sample rate Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Moved grafana to port 3010 to not conflict with fides-ui Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7163 +/- ##
==========================================
- Coverage 87.17% 85.49% -1.69%
==========================================
Files 534 536 +2
Lines 35312 35515 +203
Branches 4113 4142 +29
==========================================
- Hits 30783 30362 -421
- Misses 3638 4221 +583
- Partials 891 932 +41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
We're missing the Prometheus dependencies
prometheus-client==0.19.0
prometheus-fastapi-instrumentator==6.1.0
| ) | ||
|
|
||
| fastapi_app = FastAPI(title="fides", version=app_version, lifespan=lifespan, separate_input_output_schemas=False) # type: ignore | ||
| Instrumentator().instrument(fastapi_app).expose(fastapi_app, endpoint="/metrics") |
There was a problem hiding this comment.
We should remove this from the Swagger docs since this is just for Prometheus and not meant to be human-readable.
| Instrumentator().instrument(fastapi_app).expose(fastapi_app, endpoint="/metrics") | |
| Instrumentator().instrument(fastapi_app).expose(fastapi_app, endpoint="/metrics", include_in_schema=False) |
| workers_enabled=False, workers=[], queue_counts={} | ||
| ).model_dump(mode="json") | ||
|
|
||
| with add_span_event("workers_health_check"): |
There was a problem hiding this comment.
add_span_event isn't a context manager, should this be trace_span?
| with add_span_event("workers_health_check"): | |
| with trace_span("workers_health_check"): |
| @@ -0,0 +1,2 @@ | |||
| #!/bin/env sh | |||
| influx bucket create -n k6_tests -o ethyca -r 120d No newline at end of file | |||
| otlp_exporter: Optional[str] = Field( | ||
| default="otlp", | ||
| description="OTLP exporter to use for exporting traces (otlp or console).", | ||
| ) |
There was a problem hiding this comment.
Is this used anywhere?
| otlp_exporter: Optional[str] = Field( | |
| default="otlp", | |
| description="OTLP exporter to use for exporting traces (otlp or console).", | |
| ) |
| otlp_protocol: Optional[str] = Field( | ||
| default="http/protobuf", | ||
| description="OTLP protocol to use for exporting traces (http/protobuf or grpc).", | ||
| ) |
There was a problem hiding this comment.
| otlp_protocol: Optional[str] = Field( | |
| default="http/protobuf", | |
| description="OTLP protocol to use for exporting traces (http/protobuf or grpc).", | |
| ) | |
| otlp_protocol: Literal["http/protobuf", "grpc"] = Field( | |
| default="http/protobuf", | |
| description="OTLP protocol to use for exporting traces.", | |
| ) |
Adds Open Telemetry along with basic tracing of FastAPI, httpx and sqlalchemy, a convenience tracing module to start new spans, and also adds the following to
nox -s dev: Prometheus (for scraping metrics later), tempo (for collecting OTel traces), memcached (for tempo), and grafana (to view metrics/traces). When your dev setup is running, you can hithttp://localhost:3000and see Grafana. On the left is 'Drilldown > Traces' which will take you to the traces view; down at the bottom is a traces tab that will show you all the traces for the service.