OTel trace context not added to stdlib log events
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- python
- Domain
- observability-sre
Research direction
Read setup_logging() in common/core/logging.py, focusing on the foreign_pre_chain passed to ProcessorFormatter. Confirm how stdlib logging records are processed, then add the trace-context processor there and verify that stdlib and structlog events emitted within an active OTel span contain trace_id and span_id.
Written by the indexing model from the issue text.
Description
The add_otel_trace_context structlog processor currently only lives in the structlog.configure() pipeline, not in the foreign_pre_chain used by ProcessorFormatter for standard library logging events.
This means any module using logging.getLogger(__name__) (e.g. task_processor.processor) does not get trace_id / span_id injected into its log output — even when an active OTel span exists.
How to reproduce
- Run the API + task processor with
OTEL_EXPORTER_OTLP_ENDPOINTset andLOG_FORMAT=json. - Trigger a request that enqueues a task.
- Observe that task processor log events (e.g. "Failed to execute task") lack
trace_idandspan_idfields.
Expected
All log events emitted while an OTel span is active — regardless of whether they originate from structlog or stdlib logging — should include trace_id and span_id.
Fix
Add add_otel_trace_context to the foreign_pre_chain in setup_logging() (common/core/logging.py), so that ProcessorFormatter also injects trace context into stdlib log records.
Found while testing #197.
- Dominant language
- Python
- Stars
- 2
- Forks
- 4
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 10
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flagsmith/flagsmith-common
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Flagsmith/flagsmith-common#250 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Flagsmith/flagsmith-common#254 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Flagsmith/flagsmith-common#252 ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Flagsmith/flagsmith-common#245 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Flagsmith/flagsmith-common#222 · 2 reactions ·
All issues in Flagsmith/flagsmith-common
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100