Skip to content

Commit a9df6b2

Browse files
committed
wip
1 parent 72ef7bc commit a9df6b2

File tree

4 files changed

+67
-66
lines changed

4 files changed

+67
-66
lines changed

relay-server/src/processing/logs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl processing::Processor for LogsProcessor {
121121
mut logs: Managed<Self::UnitOfWork>,
122122
ctx: Context<'_>,
123123
) -> Result<Output<Self::Output>, Rejected<Error>> {
124-
validate::container(&logs, ctx)?;
124+
validate::container(&logs)?;
125125

126126
// If running in a non managed mode, skip all processing and just forward the data
127127
// to the next layer, where eventually it will be processed.
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
use crate::processing::logs::{Error, SerializedLogs};
2-
use crate::processing::{Context, Managed, Rejected};
2+
use crate::processing::{Managed, Rejected};
33

44
/// Validates that there is only a single log container processed at a time.
55
///
66
/// The `Log` item must always be sent as an `ItemContainer`, currently it is not allowed to
77
/// send multiple containers for logs.
88
///
9-
/// This restriction may be lifted in the future, this is why this validation only happens
10-
/// when processing is enabled, allowing it to be changed easily in the future.
9+
/// This restriction may be lifted in the future.
1110
///
1211
/// This limit mostly exists to incentivise SDKs to batch multiple logs into a single container,
1312
/// technically it can be removed without issues.
14-
pub fn container(logs: &Managed<SerializedLogs>, ctx: Context<'_>) -> Result<(), Rejected<Error>> {
15-
if ctx.is_processing() {
16-
// It's fine if there was no log container, as we still accept OTel logs.
17-
if logs.logs.len() > 1 {
18-
return Err(logs.reject_err(Error::DuplicateContainer));
19-
}
20-
};
13+
pub fn container(logs: &Managed<SerializedLogs>) -> Result<(), Rejected<Error>> {
14+
// It's fine if there was no log container, as we still accept OTel logs.
15+
if logs.logs.len() > 1 {
16+
return Err(logs.reject_err(Error::DuplicateContainer));
17+
}
2118

2219
Ok(())
2320
}

relay-server/src/processing/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ pub struct Context<'a> {
6666
}
6767

6868
impl Context<'_> {
69-
/// Returns `true` if Relay is running in processing mode.
70-
pub fn is_processing(&self) -> bool {
71-
self.config.processing_enabled()
72-
}
73-
7469
/// Returns `true` if Relay is running in a managed mode.
7570
pub fn is_managed(&self) -> bool {
7671
matches!(self.config.relay_mode(), relay_config::RelayMode::Managed)

tests/integration/test_ourlogs.py

Lines changed: 59 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,19 @@
1212

1313

1414
TEST_CONFIG = {
15+
"outcomes": {
16+
"emit_outcomes": True,
17+
"batch_size": 1,
18+
"batch_interval": 1,
19+
"aggregator": {
20+
"bucket_interval": 1,
21+
"flush_interval": 1,
22+
},
23+
},
1524
"aggregator": {
1625
"bucket_interval": 1,
1726
"initial_delay": 0,
18-
}
27+
},
1928
}
2029

2130

@@ -77,12 +86,12 @@ def timestamps(ts: datetime):
7786
},
7887
"sentry.timestamp_nanos": {
7988
"stringValue": time_within_delta(
80-
ts, delta=timedelta(seconds=0), expect_resolution="ns", precision="us"
89+
ts, delta=timedelta(seconds=1), expect_resolution="ns", precision="us"
8190
)
8291
},
8392
"sentry.timestamp_precise": {
8493
"intValue": time_within_delta(
85-
ts, delta=timedelta(seconds=0), expect_resolution="ns", precision="us"
94+
ts, delta=timedelta(seconds=1), expect_resolution="ns", precision="us"
8695
)
8796
},
8897
}
@@ -151,7 +160,7 @@ def test_ourlog_multiple_containers_not_allowed(
151160
"organizations:ourlogs-ingestion",
152161
]
153162

154-
relay = relay(relay_with_processing(options=TEST_CONFIG))
163+
relay = relay(relay_with_processing(options=TEST_CONFIG), options=TEST_CONFIG)
155164
start = datetime.now(timezone.utc)
156165
envelope = Envelope()
157166

@@ -387,7 +396,7 @@ def test_ourlog_extraction_with_sentry_logs(
387396
},
388397
]
389398

390-
outcomes = outcomes_consumer.get_aggregated_outcomes(n=4)
399+
outcomes = outcomes_consumer.get_aggregated_outcomes(n=2)
391400
assert outcomes == [
392401
{
393402
"category": DataCategory.LOG_ITEM.value,
@@ -482,51 +491,51 @@ def test_ourlog_extraction_is_disabled_without_feature(
482491
"Chrome",
483492
"131.0.0",
484493
),
485-
# (
486-
# "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
487-
# "Chrome",
488-
# "120.0.0",
489-
# ),
490-
# # Firefox desktop
491-
# (
492-
# "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0",
493-
# "Firefox",
494-
# "121.0",
495-
# ),
496-
# (
497-
# "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0",
498-
# "Firefox",
499-
# "120.0",
500-
# ),
501-
# # Safari desktop
502-
# (
503-
# "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15",
504-
# "Safari",
505-
# "17.1",
506-
# ),
507-
# # Edge desktop
508-
# (
509-
# "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0",
510-
# "Edge",
511-
# "120.0.0",
512-
# ),
513-
# # Chrome mobile
514-
# (
515-
# "Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119.0.6045.169 Mobile/15E148 Safari/604.1",
516-
# "Chrome Mobile iOS",
517-
# "119.0.6045",
518-
# ),
519-
# (
520-
# "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36",
521-
# "Chrome Mobile",
522-
# "119.0.0",
523-
# ),
524-
# # Safari mobile
525-
# (
526-
# "Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1",
527-
# "Mobile Safari",
528-
# "17.1",
529-
# ),
494+
(
495+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
496+
"Chrome",
497+
"120.0.0",
498+
),
499+
# Firefox desktop
500+
(
501+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0",
502+
"Firefox",
503+
"121.0",
504+
),
505+
(
506+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0",
507+
"Firefox",
508+
"120.0",
509+
),
510+
# Safari desktop
511+
(
512+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15",
513+
"Safari",
514+
"17.1",
515+
),
516+
# Edge desktop
517+
(
518+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0",
519+
"Edge",
520+
"120.0.0",
521+
),
522+
# Chrome mobile
523+
(
524+
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119.0.6045.169 Mobile/15E148 Safari/604.1",
525+
"Chrome Mobile iOS",
526+
"119.0.6045",
527+
),
528+
(
529+
"Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36",
530+
"Chrome Mobile",
531+
"119.0.0",
532+
),
533+
# Safari mobile
534+
(
535+
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1",
536+
"Mobile Safari",
537+
"17.1",
538+
),
530539
],
531540
)
532541
def test_browser_name_version_extraction(

0 commit comments

Comments
 (0)