Add Tracing Capabilities - #38
Draft
Amirutha (Amirutha) wants to merge 7 commits into
Draft
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Pull request overview
This PR introduces optional distributed tracing hooks to eventbusk, enabling trace context propagation via broker message headers from EventBus.send() to EventBus.receive(), and allowing receiver executions to be wrapped in user-provided spans without coupling to a specific tracing vendor.
Changes:
- Added a
TracingConfigAPI and plumbed tracing header injection/extraction throughEventBus.send()/receive(). - Extended broker producer interfaces (base, Kafka, dummy) to accept optional message
headers. - Added documentation and tests covering tracing behavior and header propagation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| eventbusk/bus.py | Introduces TracingConfig and integrates tracing into send/receive flows. |
| eventbusk/init.py | Exports TracingConfig as part of the public package API. |
| eventbusk/brokers/base.py | Extends producer interface docs/signature to support optional headers. |
| eventbusk/brokers/kafka.py | Passes headers through to the underlying Confluent Kafka producer. |
| eventbusk/brokers/dummy.py | Records headers in dummy producer calls for testing/inspection. |
| tests/test_bus.py | Adds focused tracing hook tests and adjusts send assertions for new kwargs. |
| tests/test_brokers.py | Updates Kafka producer test expectations to include headers=None. |
| README.md | Documents tracing hooks, usage examples, and updates lint command wording. |
| pyproject.toml | Aligns Ruff pylint max-args to match pylint config expectations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+26
to
+30
| Callable[[list[tuple[str, bytes]] | None], list[tuple[str, bytes]]] | None | ||
| ) | ||
| type TraceExtractor = Callable[[Any], dict[str, str] | None] | None | ||
| # Returns a context manager wrapping one receiver invocation. | ||
| type SpanManager = Callable[[str, str, dict[str, str] | None], Any] | None |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Amirutha <6166984+Amirutha@users.noreply.github.com>
…sk into ami/tracing-capabilities
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.
What
This PR adds optional tracing capabilities to
eventbuskso trace context can flow fromsend()toreceive()via broker headers, and receiver execution can be wrapped in spans.Changes
TracingConfigineventbusk/bus.pyand exported it fromeventbusk/__init__.py.headers:eventbusk/brokers/base.pyeventbusk/brokers/kafka.pyeventbusk/brokers/dummy.pyEventBus.send()to inject tracing headers when configured.EventBus.receive()to:README.md.tests/test_bus.pyandtests/test_brokers.py.pyproject.toml(ruffpylintmax-args).Why
Producer and consumer run in separate processes. Without explicit propagation, tracing tools cannot reliably correlate produced events with downstream receiver execution. This PR introduces integration hooks while keeping
eventbuskvendor-agnostic.Behavior
Compatibility
EventBususers.headersargument is optional and does not break existing producer calls.