Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Extract OTLP spans' client sample rate from TraceState. ([#6312](https://github.com/getsentry/relay/pull/6312))
- Raise the size limit for the flags context to 128 KiB. ([#6310](https://github.com/getsentry/relay/pull/6310))
- Add support for more inbound filters for logs, trace metrics and spans. ([#6306](https://github.com/getsentry/relay/pull/6306))
- Raise the size limit for logs to 2 MiB. ([#6316](https://github.com/getsentry/relay/pull/6316))
- Include the environment in the cron check-in routing key so a monitor's environments no longer share a single Kafka partition. ([#6331](https://github.com/getsentry/relay/pull/6331))

Expand Down
76 changes: 35 additions & 41 deletions relay-filter/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,6 @@ impl Filterable for Span {
}
}

impl Filterable for SpanV2 {
fn release(&self) -> Option<&str> {
self.attributes
.value()?
.get_value(SENTRY__RELEASE)?
.as_str()
}

fn transaction(&self) -> Option<&str> {
self.attributes
.value()?
.get_value(SENTRY__SEGMENT__NAME)?
.as_str()
}

fn user_agent(&self) -> UserAgent<'_> {
user_agent_from_attributes(&self.attributes)
}
}

impl Filterable for SessionUpdate {
fn ip_addr(&self) -> Option<&str> {
self.attributes
Expand Down Expand Up @@ -256,32 +236,46 @@ impl Filterable for SessionAggregates {
}
}

impl Filterable for OurLog {
fn release(&self) -> Option<&str> {
self.attributes
.value()?
.get_value(SENTRY__RELEASE)?
.as_str()
}
macro_rules! impl_for_attributes {
($ty:ty) => {
impl Filterable for $ty {
fn ip_addr(&self) -> Option<&str> {
self.attributes
.value()?
.get_value(CLIENT__ADDRESS)?
.as_str()
}

fn user_agent(&self) -> UserAgent<'_> {
user_agent_from_attributes(&self.attributes)
}
}
fn release(&self) -> Option<&str> {
self.attributes
.value()?
.get_value(SENTRY__RELEASE)?
.as_str()
}

impl Filterable for TraceMetric {
fn release(&self) -> Option<&str> {
self.attributes
.value()?
.get_value(SENTRY__RELEASE)?
.as_str()
}
fn transaction(&self) -> Option<&str> {
self.attributes
.value()?
.get_value(SENTRY__SEGMENT__NAME)?
.as_str()
}

fn user_agent(&self) -> UserAgent<'_> {
user_agent_from_attributes(&self.attributes)
}
fn url(&self) -> Option<Url> {
let url = self.attributes.value()?.get_value(URL__FULL)?.as_str()?;
Url::parse(url).ok()
}

fn user_agent(&self) -> UserAgent<'_> {
user_agent_from_attributes(&self.attributes)
}
}
};
}

impl_for_attributes!(SpanV2);
impl_for_attributes!(OurLog);
impl_for_attributes!(TraceMetric);

fn user_agent_from_attributes(attributes: &relay_protocol::Annotated<Attributes>) -> UserAgent<'_> {
let parsed = (|| {
let attributes = attributes.value()?;
Expand Down
44 changes: 44 additions & 0 deletions tests/integration/test_ourlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,42 @@ def test_browser_name_version_extraction(
{},
id="release",
),
pytest.param(
"filtered-transaction",
{"ignoreTransactions": {"isEnabled": True, "patterns": ["*health*"]}},
{
"attributes": {
"sentry.segment.name": {
"value": "/foo/healthz",
"type": "string",
}
}
},
id="transaction",
),
pytest.param(
"localhost",
{"localhost": {"isEnabled": True}},
{
"attributes": {
"client.address": {"value": "127.0.0.1", "type": "string"}
}
},
id="localhost-ip",
),
pytest.param(
"localhost",
{"localhost": {"isEnabled": True}},
{
"attributes": {
"url.full": {
"value": "http://localhost:8000/foo",
"type": "string",
}
}
},
id="localhost-url",
),
pytest.param(
"legacy-browsers",
{"legacyBrowsers": {"isEnabled": True, "options": ["ie9"]}},
Expand Down Expand Up @@ -1021,6 +1057,14 @@ def test_filters_are_applied_to_logs(
"attributes": {
"some_integer": {"value": 123, "type": "integer"},
"sentry.release": {"value": "foobar@1.0", "type": "string"},
**args.get("attributes", {}),
},
},
metadata={
"version": 2,
"ingest_settings": {
"infer_ip": "never",
"infer_user_agent": "auto",
},
},
)
Expand Down
25 changes: 25 additions & 0 deletions tests/integration/test_spansv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,29 @@ def test_spansv2_ds_root_in_different_org(
{},
id="transaction",
),
pytest.param(
"localhost",
{"localhost": {"isEnabled": True}},
{
"attributes": {
"client.address": {"value": "127.0.0.1", "type": "string"}
}
},
id="localhost-ip",
),
pytest.param(
"localhost",
{"localhost": {"isEnabled": True}},
{
"attributes": {
"url.full": {
"value": "http://localhost:8000/foo",
"type": "string",
}
}
},
id="localhost-url",
),
pytest.param(
"legacy-browsers",
{"legacyBrowsers": {"isEnabled": True, "options": ["ie9"]}},
Expand Down Expand Up @@ -1081,11 +1104,13 @@ def test_spanv2_inbound_filters(
"some_integer": {"value": 123, "type": "integer"},
"sentry.release": {"value": "foobar@1.0", "type": "string"},
"sentry.segment.name": {"value": "/foo/healthz", "type": "string"},
**args.get("attributes", {}),
},
},
metadata={
"version": 2,
"ingest_settings": {
"infer_ip": "never",
"infer_user_agent": "auto",
},
},
Expand Down
39 changes: 38 additions & 1 deletion tests/integration/test_trace_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,42 @@ def test_trace_metric_container_metadata(
{},
id="release",
),
pytest.param(
"filtered-transaction",
{"ignoreTransactions": {"isEnabled": True, "patterns": ["*health*"]}},
{
"attributes": {
"sentry.segment.name": {
"value": "/foo/healthz",
"type": "string",
}
}
},
id="transaction",
),
pytest.param(
"localhost",
{"localhost": {"isEnabled": True}},
{
"attributes": {
"client.address": {"value": "127.0.0.1", "type": "string"}
}
},
id="localhost-ip",
),
pytest.param(
"localhost",
{"localhost": {"isEnabled": True}},
{
"attributes": {
"url.full": {
"value": "http://localhost:8000/foo",
"type": "string",
}
}
},
id="localhost-url",
),
pytest.param(
"legacy-browsers",
{"legacyBrowsers": {"isEnabled": True, "options": ["ie9"]}},
Expand Down Expand Up @@ -1102,7 +1138,7 @@ def test_filters_are_applied_to_trace_metrics(

metadata = {
"version": 2,
"ingest_settings": {"infer_ip": "auto", "infer_user_agent": "auto"},
"ingest_settings": {"infer_ip": "never", "infer_user_agent": "auto"},
}

envelope = envelope_with_trace_metrics(
Expand All @@ -1115,6 +1151,7 @@ def test_filters_are_applied_to_trace_metrics(
"attributes": {
"http.status_code": {"value": 500, "type": "integer"},
"sentry.release": {"value": "foobar@1.0", "type": "string"},
**args.get("attributes", {}),
},
},
metadata=metadata,
Expand Down
Loading