Conversation
ZohebShaikh
left a comment
There was a problem hiding this comment.
Looks good only few minor things
src/logging.rs
Outdated
| if errors.0.is_empty() { | ||
| error!("Failed to connect to graylog - address lookup failed"); | ||
| } else { | ||
| warn!( | ||
| "Connection to graylog {:?} closed: {:?}", | ||
| handle.address(), | ||
| errors | ||
| ); |
There was a problem hiding this comment.
errors.0 give Vec<SocketAddr,Error> docs
If there are errors you get a warning which I find difficult to understand
This is just a question to understand the code.
I don't know will it be very difficult to write unit test to check all the error cases
There was a problem hiding this comment.
The gelf library is odd. There is a bit more explanation in the amygdala version here.
I'm not sure if the warn should also be an error but the no errors == error case caught me out as well so it might be worth including a similar comment here.
There was a problem hiding this comment.
Adding a similar error message to errors.0 , to provide context.
bda4336 to
831a990
Compare
- Extract GraylogOptions into its own struct, independent of TracingOptions - Remove .vscode/launch.json (to be added in a separate PR) - Remove version/build additional_field calls from Graylog logger - Switch let-else to if-let in init_graylog - Warn when Graylog URL has no port rather than silently defaulting - Add reconnect loop so dropped connections recover automatically - Improve connection error messages to distinguish DNS failure from TCP errors
831a990 to
0a86a82
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #264 +/- ##
==========================================
+ Coverage 76.35% 76.53% +0.18%
==========================================
Files 13 13
Lines 1937 2033 +96
==========================================
+ Hits 1479 1556 +77
- Misses 458 477 +19 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tpoliaw
left a comment
There was a problem hiding this comment.
Looks pretty good, thanks for looking at it. A couple of changes could make the error handling a bit cleaner and keep it more consistent with what is already there though.
| async fn main() -> Result<(), Box<dyn Error>> { | ||
| let args = Cli::init(); | ||
| let _ = logging::init(args.log_level(), args.tracing()); | ||
| let _ = logging::init(args.log_level(), args.tracing(), &args.graylog); |
There was a problem hiding this comment.
We should probably handle errors here. Currently if any log setup fails you get no output and debugging why is a pain.
| openidconnect = { version = "4.0.0", optional = true } | ||
| toml = { version = "1.0.0", optional = true } | ||
| tracing-gelf = "0.9.0" | ||
| thiserror = "2.0.18" |
There was a problem hiding this comment.
Bringing in thiserror for a single error type might be an overkill. Implementing the error manually is not too much boilerplate.
| trackers/ | ||
|
|
||
| # Local IDE settings | ||
| .vscode/settings.json |
There was a problem hiding this comment.
Shouldn't be part of this PR - it's a good change but can go in at the same time as the launch.json, maybe as .vscode/ and then manually add the specific files.
src/logging.rs
Outdated
| if errors.0.is_empty() { | ||
| error!("Failed to connect to graylog - address lookup failed"); | ||
| } else { | ||
| warn!( | ||
| "Connection to graylog {:?} closed: {:?}", | ||
| handle.address(), | ||
| errors | ||
| ); |
There was a problem hiding this comment.
The gelf library is odd. There is a bit more explanation in the amygdala version here.
I'm not sure if the warn should also be an error but the no errors == error case caught me out as well so it might be worth including a similar comment here.
#252
Summary
tracing-gelflayer to ship structured logs to a Graylog instance via GELF TCP--graylog <URL>and--logging-level <LEVEL>CLI flags (also viaNUMTRACKER_GRAYLOG/NUMTRACKER_GRAYLOG_LOG_LEVELenv vars)numtracker.graylog.enabled/host/levelvalues