-
-
Notifications
You must be signed in to change notification settings - Fork 160
chore: improve error logging in ingestion handler #1535
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
chore: improve error logging in ingestion handler #1535
Conversation
add stream name to the error log on ingestion failure
WalkthroughReject OTEL log sources and add pervasive stream-contextual error logging across OTEL ingestion and general ingest paths. Change public error enum variant Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/handlers/http/ingest.rs`:
- Around line 143-155: The error logging currently prints the full
serde_json::Error (which includes JSON snippets) when flatten_and_push_logs
fails; update ingest_internal_stream and handle_raw_logs_internal so
serde_json::Error is redacted before being logged: either detect/match
PostError::SerdeError (or the inner serde_json::Error returned by
serde_json::from_slice) and log a generic message like "malformed JSON" (and, if
needed, emit the full serde error at debug level only), or wrap
serde_json::Error in a custom error type with a Display impl that returns a
redacted string; apply this handling where flatten_and_push_logs is awaited and
where serde_json::from_slice(&body) is called so no JSON snippets are output by
error!().
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/handlers/http/ingest.rs`:
- Around line 554-557: The PostError enum variant OtelNotSupported was changed
from a unit variant to OtelNotSupported(String), so update every site that
constructs or matches against OtelNotSupported to provide and bind the stream
name: replace bare OtelNotSupported with
OtelNotSupported(stream_name.to_string() or an appropriate &str->String
conversion) where the error is created, and update match arms like
`OtelNotSupported => ...` to `OtelNotSupported(name) => ...` (or `_` if the name
is unused); ensure functions that return PostError::OtelNotSupported now pass
the stream identifier (use the same identifier used in that context, e.g.,
`stream` or `stream_name`) and adjust any tests/expectations to accept the tuple
variant.
🧹 Nitpick comments (3)
src/handlers/http/ingest.rs (3)
309-321: Consider extracting duplicated error messages.The error message is duplicated between the
error!()macro and thePostError::Invalidanyhow message. This creates maintenance overhead if the message needs to change.♻️ Optional refactor to reduce duplication
} else if content_type == CONTENT_TYPE_PROTOBUF { + let msg = format!( + "Ingestion failed for stream {stream_name}: Protobuf ingestion is not supported in Parseable OSS" + ); - error!( - "Ingestion failed for stream {stream_name}: Protobuf ingestion is not supported in Parseable OSS" - ); - return Err(PostError::Invalid(anyhow::anyhow!( - "Ingestion failed for stream {stream_name}: Protobuf ingestion is not supported in Parseable OSS" - ))); + error!("{msg}"); + return Err(PostError::Invalid(anyhow::anyhow!("{msg}"))); } else { + let msg = format!( + "Ingestion failed for stream {stream_name}: Unsupported Content-Type: {content_type}. Expected application/json or application/x-protobuf" + ); - error!( - "Ingestion failed for stream {stream_name}: Unsupported Content-Type: {content_type}. Expected application/json or application/x-protobuf" - ); - return Err(PostError::Invalid(anyhow::anyhow!( - "Ingestion failed for stream {stream_name}: Unsupported Content-Type: {content_type}. Expected application/json or application/x-protobuf" - ))); + error!("{msg}"); + return Err(PostError::Invalid(anyhow::anyhow!("{msg}"))); }
325-330: Same duplication pattern as above.Consider applying the same refactoring approach to reduce maintenance overhead.
350-354: Stream name unavailable in setup error logs.When
setup_otel_streamfails, the stream name may have already been extracted but isn't included in the error log since it's part of the returned tuple. For failures that occur after stream name extraction (e.g., duringcreate_stream_if_not_exists), consider logging the stream name withinsetup_otel_streamitself, or restructuring to return partial results on certain failure paths.♻️ Alternative: Add internal logging to setup_otel_stream
// In setup_otel_stream, after extracting stream_name, wrap operations with error logging: let stream_name = stream_name.to_str().unwrap().to_owned(); PARSEABLE .create_stream_if_not_exists(/* ... */) .await .map_err(|e| { error!("OTEL ingestion setup failed for stream {stream_name}: {e}"); e })?;
add stream name to the error log on ingestion failure
Summary by CodeRabbit