Skip to content

makes tracing easier#6

Merged
seun-ja merged 3 commits into
mainfrom
3-tracing-and-logging
Apr 7, 2026
Merged

makes tracing easier#6
seun-ja merged 3 commits into
mainfrom
3-tracing-and-logging

Conversation

@seun-ja

@seun-ja seun-ja commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Fixes #3

Signed-off-by: Aminu Oluwaseun Joshua <seun.aminujoshua@gmail.com>

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 tracing instrumentation across key execution paths (provider chat calls, JWT decoding, and agent message handling) to improve observability, and replaces a startup println! with a structured log event.

Changes:

  • Add #[tracing::instrument] spans to chat() implementations (OpenAI/Ollama), JWT decoding, and agent message handling.
  • Replace server startup println! with tracing::info!.
  • Add tracing as a dependency (and update Cargo.lock accordingly).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/providers/openai.rs Adds a tracing span around OpenAI::chat.
src/providers/ollama.rs Adds a tracing span around OllamaAI::chat.
src/jwt.rs Adds a tracing span around decode_jwt.
src/agent.rs Uses tracing::info! for startup logging and instruments AgentWorker::message.
Cargo.toml Adds tracing dependency.
Cargo.lock Captures dependency graph update for tracing.
Comments suppressed due to low confidence (1)

src/agent.rs:35

  • Switching from println! to tracing::info! changes default behavior: without a global tracing subscriber, this message will be dropped and users won’t see the listening address anymore. If you want to keep the previous UX while still supporting tracing, consider either documenting/initializing a subscriber in the runnable example(s), or gating this log behind an optional feature (or falling back to println!).
        tracing::info!("Listening on: {}", listener.local_addr());

        listener
            .map_err(|e| eprintln!("{}", e)) // TODO: Improve error handling.
            .filter_map(|r| future::ready(r.ok()))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Cargo.toml
Comment thread src/agent.rs
Comment thread src/providers/openai.rs Outdated
Comment thread src/providers/ollama.rs Outdated
Comment thread src/jwt.rs Outdated
Signed-off-by: Aminu Oluwaseun Joshua <seun.aminujoshua@gmail.com>

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

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/agent.rs

println!("Listening on: {}", listener.local_addr());
#[cfg(feature = "tracing")]
tracing::info!("Listening on: {}", listener.local_addr());

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

AgentServer::run no longer prints the listening address when the tracing feature is disabled (previously println! ran unconditionally). This makes the default binary/library behavior less observable. Consider keeping a non-tracing fallback (e.g., println! under cfg(not(feature = "tracing"))) or emitting the message via a logging facade that works without requiring the tracing feature.

Suggested change
tracing::info!("Listening on: {}", listener.local_addr());
tracing::info!("Listening on: {}", listener.local_addr());
#[cfg(not(feature = "tracing"))]
println!("Listening on: {}", listener.local_addr());

Copilot uses AI. Check for mistakes.
Comment thread src/lib.rs Outdated
//!
//! ## Feature Flags
//!
//! **`tracing`**: Enables tracing for logging request/response traces. It requires a `RUST_LOG` environment variable to be set.

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

The docs claim the tracing feature "requires a RUST_LOG environment variable". This crate only adds tracing instrumentation and does not set up a subscriber/EnvFilter, so RUST_LOG is not inherently required and won’t have any effect unless the consumer configures a subscriber (e.g., tracing-subscriber with EnvFilter). Please reword to describe that users must install/initialize a tracing subscriber, and mention RUST_LOG only as an optional filter mechanism when using EnvFilter.

Suggested change
//! **`tracing`**: Enables tracing for logging request/response traces. It requires a `RUST_LOG` environment variable to be set.
//! **`tracing`**: Enables `tracing` instrumentation for request/response traces.
//! To collect or display these traces, applications must install and initialize a
//! tracing subscriber (for example, via `tracing-subscriber`). If the subscriber is
//! configured with an `EnvFilter`, `RUST_LOG` may be used as an optional filtering
//! mechanism.

Copilot uses AI. Check for mistakes.
Comment thread README.md

## Feature Flag

**`tracing`**: Enables tracing for logging request/response traces. It requires a `RUST_LOG` environment variable to be set.

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

The README states the tracing feature "requires a RUST_LOG environment variable". Since the crate does not configure a tracing subscriber, RUST_LOG is not required and won’t do anything unless the user sets up a subscriber with filtering (e.g., tracing-subscriber + EnvFilter). Please update this section to explain the need to initialize a subscriber and treat RUST_LOG as optional/config-dependent.

Suggested change
**`tracing`**: Enables tracing for logging request/response traces. It requires a `RUST_LOG` environment variable to be set.
**`tracing`**: Enables tracing instrumentation for request/response traces. To see tracing output, your application must initialize a tracing subscriber (for example, with `tracing-subscriber`). A `RUST_LOG` environment variable is not required by this crate itself; it is optional and only has an effect if your subscriber is configured to read environment-based filters (for example, via `tracing-subscriber::EnvFilter`).

Copilot uses AI. Check for mistakes.
Signed-off-by: Aminu Oluwaseun Joshua <seun.aminujoshua@gmail.com>
@seun-ja
seun-ja merged commit ac56e99 into main Apr 7, 2026
1 check passed
@seun-ja
seun-ja deleted the 3-tracing-and-logging branch April 7, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracing and Logging

2 participants