Skip to content

Add Tracing Capabilities - #38

Draft
Amirutha (Amirutha) wants to merge 7 commits into
mainfrom
ami/tracing-capabilities
Draft

Add Tracing Capabilities#38
Amirutha (Amirutha) wants to merge 7 commits into
mainfrom
ami/tracing-capabilities

Conversation

@Amirutha

@Amirutha Amirutha (Amirutha) commented Aug 9, 2026

Copy link
Copy Markdown

What

This PR adds optional tracing capabilities to eventbusk so trace context can flow from send() to receive() via broker headers, and receiver execution can be wrapped in spans.

Changes

  • Added TracingConfig in eventbusk/bus.py and exported it from eventbusk/__init__.py.
  • Extended producer interfaces to accept optional headers:
    • eventbusk/brokers/base.py
    • eventbusk/brokers/kafka.py
    • eventbusk/brokers/dummy.py
  • Updated EventBus.send() to inject tracing headers when configured.
  • Updated EventBus.receive() to:
    • extract trace context from incoming messages
    • run receiver handlers inside a configurable span manager
  • Added tracing documentation and usage examples in README.md.
  • Added/updated tests in tests/test_bus.py and tests/test_brokers.py.
  • Aligned lint config in pyproject.toml (ruff pylint max-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 eventbusk vendor-agnostic.

Behavior

  • Tracing is fully optional; existing usage remains unchanged.
  • Event payload/body is untouched; trace data is carried in headers only.
  • Messages without trace headers still work and can still be wrapped in local (unparented) spans.

Compatibility

  • Backward compatible for existing EventBus users.
  • New headers argument is optional and does not break existing producer calls.
Screenshot 2026-08-09 at 5 12 14 PM

@snyk-io

snyk-io Bot commented Aug 9, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TracingConfig API and plumbed tracing header injection/extraction through EventBus.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 thread eventbusk/bus.py Outdated
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ff46b9b.

Comment thread eventbusk/bus.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Amirutha <6166984+Amirutha@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants