Skip to content

Commit 549cdd4

Browse files
authored
fix(ourlogs): Make referer optional in vercel log drain transform (#5273)
ref getsentry/sentry#91728 resolves https://linear.app/getsentry/issue/LOGS-434/investigate-why-logs-from-vercel-log-drain-are-being-marked-as-invalid I've been testing the vercel log drain internally and I found that we were dropping quite a few logs, 40% of which were marked as invalid. <img width="1317" height="520" alt="image" src="https://github.com/user-attachments/assets/a1da3afb-ecd7-467a-8da9-217c66441ea2" /> When testing locally, I found that we were hitting an error where the log drain was sending us logs that did not have a `proxy.referer` field, which the vercel docs do say [is required](https://vercel.com/docs/drains/reference/logs): <img width="607" height="101" alt="image" src="https://github.com/user-attachments/assets/f8440212-30b9-4397-974f-a9a91e354aed" /> ``` TRACE relay_server::services::processor: Processing log group DEBUG relay_server::processing::logs::integrations::vercel: Failed to parse logs data as JSON error=missing field `referer` at line 1 column 564 ``` This PR just makes `referer` optional just to unblock ourselves. I'm also following up with Vercel separately to see if what is going on.
1 parent fb66b73 commit 549cdd4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
**Bug Fixes**:
6+
7+
- Make referer optional in Vercel Log Drain Transform. ([#5273](https://github.com/getsentry/relay/pull/5273))
8+
59
**Internal**:
610

711
- Switch default allocator from jemalloc to mimalloc. ([#5239](https://github.com/getsentry/relay/pull/5239))

relay-ourlogs/src/vercel_to_sentry.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ pub struct VercelProxy {
118118
pub path: String,
119119
/// User agent strings of the request.
120120
pub user_agent: Vec<String>,
121-
/// Referer of the request.
122-
pub referer: String,
123121
/// Region where the request is processed.
124122
pub region: String,
123+
/// Referer of the request.
124+
pub referer: Option<String>,
125125
/// HTTP status code of the proxy request.
126126
pub status_code: Option<i64>,
127127
/// Client IP address.
@@ -282,13 +282,13 @@ pub fn vercel_log_to_sentry_log(vercel_log: VercelLog) -> OurLog {
282282
add_attribute!("vercel.proxy.method", method);
283283
add_attribute!("vercel.proxy.host", host);
284284
add_attribute!("vercel.proxy.path", path);
285-
add_attribute!("vercel.proxy.referer", referer);
286285
add_attribute!("vercel.proxy.region", region);
287286

288287
if let Ok(user_agent_string) = serde_json::to_string(&user_agent) {
289288
attributes.insert("vercel.proxy.user_agent", user_agent_string);
290289
}
291290

291+
add_optional_attribute!("vercel.proxy.referer", referer);
292292
add_optional_attribute!("vercel.proxy.status_code", status_code);
293293
add_optional_attribute!("vercel.proxy.client_ip", client_ip);
294294
add_optional_attribute!("vercel.proxy.scheme", scheme);
@@ -363,8 +363,8 @@ mod tests {
363363
host: "my-app.vercel.app".to_owned(),
364364
path: "/api/users?page=1".to_owned(),
365365
user_agent: vec!["Mozilla/5.0...".to_owned()],
366-
referer: "https://my-app.vercel.app".to_owned(),
367366
region: "sfo1".to_owned(),
367+
referer: Some("https://my-app.vercel.app".to_owned()),
368368
status_code: Some(200),
369369
client_ip: Some("120.75.16.101".to_owned()),
370370
scheme: Some("https".to_owned()),

0 commit comments

Comments
 (0)