Merged
Conversation
Serialize W3C trace context (traceparent, baggage) into a nullable JSONField on tasks at enqueue time, then extract and activate it as a parent span at execution time. This links task processor spans back to the originating HTTP request trace. - Add `trace_context` JSONField to AbstractBaseTask (migration 0014) - Inject via `propagate.inject()` in `TaskHandler.delay()` - Extract via `propagate.extract()` + span in `_run_task()` - Derive default service.name from entrypoint (flagsmith-task-processor) - Add `opentelemetry-api` to task-processor extras - Promote `span_exporter` fixture to root conftest Closes #184 beep boop
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #197 +/- ##
==========================================
+ Coverage 96.95% 97.05% +0.09%
==========================================
Files 101 102 +1
Lines 4008 4140 +132
==========================================
+ Hits 3886 4018 +132
Misses 122 122 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
emyller
previously approved these changes
Apr 10, 2026
Contributor
emyller
left a comment
There was a problem hiding this comment.
Approving because it looks great, my comments are not blocking.
There is one coverage failure I'm suspicious about, but other tests add enough confidence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributes to #184.
trace_contextJSONField on tasks at enqueue time viapropagate.inject()inTaskHandler.delay()_run_task(), linking task execution spans back to the originating HTTP request traceservice.namefrom entrypoint:flagsmith-task-processorwhen running the task processor,flagsmith-apiotherwise (OTEL_SERVICE_NAMEoverrides both)opentelemetry-apitotask-processorextras,TraceContexttype alias, and span attributes matching Prometheus metric labels for cross-signal correlationHow to review
Review complexity: 2/5
Start with the model layer (
models.py,types.py, migration) — a newtrace_contextnullable JSONField. Then follow the write path indecorators.py. Next, the read path inprocessor.py. Finally,main.pyhas one conditional for the defaultservice.namebased onsys.argv.Tests mirror the above order: model, decorator, processor, main. The processor tests use static
traceparentstrings with known hex IDs for parametrisation.span_exporterfixture was promoted from integration test to root conftest, andRunTasksFixtureprotocol was updated with a defaultnum_tasks.Test plan
task_identifier,task_type,result) are presentservice.nameshowsflagsmith-task-processorfor task processor spans andflagsmith-apifor API spanstrace_id/span_id