-
Notifications
You must be signed in to change notification settings - Fork 0
Update json logging in mesh. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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 updates the service mesh logging configuration to support JSON-formatted logs. The changes enable environment-based control of log format and verbosity, making the application more suitable for production deployment where structured logging is beneficial for log aggregation systems.
- Adds JSON logging support via
LOG_FORMATenvironment variable (defaults to JSON) - Implements environment-based log level filtering via
RUST_LOGvariable - Adds
tracing-subscriberJSON feature and related dependencies
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| service-mesh/src/main.rs | Replaces static tracing initialization with configurable JSON/pretty format logging based on environment variables |
| service-mesh/Cargo.toml | Adds "json" feature to tracing-subscriber dependency and reformats multi-feature dependencies for better readability |
| Cargo.lock | Updates lock file with new tracing-serde dependency required for JSON logging support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let env_filter = tracing_subscriber::EnvFilter::try_from_default_env() | ||
| .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")); | ||
|
|
||
| if log_format == "json" { |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string comparison for log format is case-sensitive and doesn't handle variations like "JSON", "Json", or invalid values gracefully. Consider using a case-insensitive comparison or matching against known valid values:
if log_format.eq_ignore_ascii_case("json") {
// json format
} else {
// pretty format (default for anything else)
}Alternatively, you could explicitly handle invalid values and log a warning when an unrecognized format is specified.
| .with_max_level(tracing::Level::DEBUG) | ||
| .init(); | ||
| // Initialize tracing from environment (RUST_LOG) | ||
| // Use LOG_FORMAT=json or LOG_FORMAT=pretty (default: json) |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment mentions "LOG_FORMAT=pretty" as an option, but the code doesn't explicitly check for "pretty" - it treats any non-"json" value as pretty format. Consider updating the comment to clarify this behavior:
// Initialize tracing from environment (RUST_LOG)
// Use LOG_FORMAT=json for JSON output, any other value uses pretty format (default: json)| // Use LOG_FORMAT=json or LOG_FORMAT=pretty (default: json) | |
| // Use LOG_FORMAT=json for JSON output, any other value uses pretty format (default: json) |
No description provided.