-
Notifications
You must be signed in to change notification settings - Fork 103
feat(ourlog): Add vercel log drain transform #5209
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
Conversation
| /// Span identifier for distributed tracing. | ||
| #[serde(rename = "spanId")] | ||
| pub span_id: Option<String>, | ||
| /// Trace identifier for distributed tracing. | ||
| #[serde(rename = "trace.id")] | ||
| pub trace_dot_id: Option<String>, | ||
| /// Span identifier for distributed tracing. | ||
| #[serde(rename = "span.id")] | ||
| pub span_dot_id: Option<String>, |
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.
You can use serde alias to prevent having multiple fields here.
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.
Unfortunately this can't work because the schema allows traceId and trace.id to be sent together, and we still want serialization to work here. Is there a way we can get around that with serde?
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.
In that case having two fields makes sense. But what's the point in keeping both versions on serialization? Shouldn't we normalize the field into the more common name?
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.
I couldn't get this to work without a macro - ec8cfbf. Let me know what you think!
The nice refactor here is that the struct only support deriving Deserialize, which I think communicates intent way better.
define_fallback_field_deserializer!(deserialize_trace_id, "traceId", "trace.id");
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.
Yep only supporting Deserialize makes sense here 👍 . I understand the problem with serde alias now, wasn't even aware that it fails parsing when both fields are present in the input.
| add_attribute!(HTTP_RESPONSE_STATUS_CODE, code); | ||
| } | ||
|
|
||
| add_optional_attribute!(HTTP_RESPONSE_STATUS_CODE, status_code); |
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.
You're already adding this above, I think we should probably restate this as add_optional_attribute!('vercel.status_code',) to include information about -1 where it doesn't conflict with our status code conventions
| /// Span identifier for distributed tracing. | ||
| #[serde(rename = "spanId")] | ||
| pub span_id: Option<String>, | ||
| /// Trace identifier for distributed tracing. | ||
| #[serde(rename = "trace.id")] | ||
| pub trace_dot_id: Option<String>, | ||
| /// Span identifier for distributed tracing. | ||
| #[serde(rename = "span.id")] | ||
| pub span_dot_id: Option<String>, |
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.
In that case having two fields makes sense. But what's the point in keeping both versions on serialization? Shouldn't we normalize the field into the more common name?
58d7af5 to
3810607
Compare
3810607 to
ec8cfbf
Compare
resolves https://linear.app/getsentry/issue/LOGS-389/add-vercel-log-drain-endpoint-to-relay Building on top of the vercel log transform added in #5209, this PR adds an endpoint for the vercel log drain. This endpoint is featured flagged, you can see the options automator PR here: getsentry/sentry-options-automator#5367
When implementing the vercel log drain transform in #5209, I initially used `url.path` to represent the path property. <img width="819" height="136" alt="image" src="https://github.com/user-attachments/assets/37ddda0d-2d8d-47fc-b125-a47701c44385" /> Unfortunately it seems like this also includes some non path like values, like 404, which breaks the semantic convention of `url.path`. <img width="1526" height="301" alt="image" src="https://github.com/user-attachments/assets/5f9c5175-d753-45bf-bb59-2baa2a3db0f7" /> This PR changes the attribute to be `vercel.path` instead.
ref https://linear.app/getsentry/issue/LOGS-389/add-vercel-log-drain-endpoint-to-relay
This PR updates the
relay-ourlogscreate to add aVercelLogstruct and avercel_log_to_sentry_logtransform method.vercel_log_to_sentry_logturns an incomingVercelLogjson payload structure into an instance of Sentry'sOurLog.I haven't hooked up the
vercel_log_to_sentry_logfunction to an endpoint and the rest of the processing pipeline on purpose, I want to take our time to make sure we are all good with the transform taking place.Many of these attributes are new, I've opened a PR in the conventions repo to document them accordingly: getsentry/sentry-conventions#163. See this notion doc for details about the schema and the transform: https://www.notion.so/sentry/Vercel-Log-Drain-2808b10e4b5d808c95f3ebcfe2b8828a. The attribute keys here align in naming as per https://vercel.com/docs/drains/reference/logs.
After this PR merges in, I'll work on exposing this in a new integrations endpoint, gated behind the feature flag introduced in #5208