Skip to content
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

feat(protocol): Add scraping_attempts field #2575

Merged
merged 8 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -26,6 +26,7 @@
- Add `profile_id` to spans. ([#2569](https://github.com/getsentry/relay/pull/2569))
- Introduce a dedicated usage metric for transactions that replaces the duration metric. ([#2571](https://github.com/getsentry/relay/pull/2571))
- Restore the profiling killswitch. ([#2573](https://github.com/getsentry/relay/pull/2573))
- Add `scraping_attempts` field to the event schema. ([#2575](https://github.com/getsentry/relay/pull/2575))

## 23.9.1

Expand Down
4 changes: 4 additions & 0 deletions py/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Add `scraping_attempts` field to the event schema. ([#2575](https://github.com/getsentry/relay/pull/2575))

## 0.8.31

- Add `Reservoir` variant to `SamplingRule`. ([#2550](https://github.com/getsentry/relay/pull/2550))
Expand Down
21 changes: 20 additions & 1 deletion relay-event-normalization/src/remove_other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Processor for RemoveOtherProcessor {
mod tests {
use relay_event_schema::processor::process_value;
use relay_event_schema::protocol::{Context, Contexts, OsContext, User, Values};
use relay_protocol::get_value;
use relay_protocol::{get_value, FromValue};
use similar_asserts::assert_eq;

use super::*;
Expand Down Expand Up @@ -228,4 +228,23 @@ mod tests {
Annotated::from_error(ErrorKind::InvalidAttribute, None)
);
}

#[test]
fn test_scrape_attempts() {
let json = serde_json::json!({
"scraping_attempts": [
{"status": "not_attempted", "url": "http://example.com/embedded.js"},
{"status": "not_attempted", "url": "http://example.com/embedded.js.map"},
]
});

let mut event = Event::from_value(json.into());
process_value(
&mut event,
&mut RemoveOtherProcessor,
ProcessingState::root(),
)
.unwrap();
assert!(event.value().unwrap().other.is_empty());
}
}
18 changes: 18 additions & 0 deletions relay-event-schema/src/protocol/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ pub struct Event {
#[metastructure(omit_from_schema)] // we only document error events for now
pub breakdowns: Annotated<Breakdowns>,

/// Information about attempts to scrape a JS source or sourcemap file from the web.
/// This field is populated by sentry.
#[metastructure(omit_from_schema)] // not part of external schema
pub scraping_attempts: Annotated<Array<Value>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this a Value instead of Array instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good call. Then Relay dies not even have to be updated if the sentry-side schema ever changed to an object to include more metadata, for example. Updated now.


/// Internal ingestion and processing metrics.
///
/// This value should not be ingested and will be overwritten by the store normalizer.
Expand Down Expand Up @@ -969,6 +974,19 @@ mod tests {
assert_eq!(None, event.extra_at("c.f"));
}

#[test]
fn test_scrape_attempts() {
let json = serde_json::json!({
"scraping_attempts": [
{"status": "not_attempted", "url": "http://example.com/embedded.js"},
{"status": "not_attempted", "url": "http://example.com/embedded.js.map"},
]
});

let event = Event::from_value(json.into());
assert!(!event.value().unwrap().scraping_attempts.meta().has_errors());
}

#[test]
fn test_field_value_provider_event_filled() {
let event = Event {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: relay-general/src/pii/processor.rs
source: relay-pii/src/processor.rs
expression: "&data"
---
Event {
Expand Down Expand Up @@ -105,6 +105,7 @@ Event {
spans: ~,
measurements: ~,
breakdowns: ~,
scraping_attempts: ~,
_metrics: ~,
other: {},
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: relay-general/src/pii/processor.rs
source: relay-pii/src/processor.rs
expression: "&data"
---
Event {
Expand Down Expand Up @@ -105,6 +105,7 @@ Event {
spans: ~,
measurements: ~,
breakdowns: ~,
scraping_attempts: ~,
_metrics: ~,
other: {},
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: relay-general/src/pii/processor.rs
source: relay-pii/src/processor.rs
expression: "&data"
---
Event {
Expand Down Expand Up @@ -86,6 +86,7 @@ Event {
spans: ~,
measurements: ~,
breakdowns: ~,
scraping_attempts: ~,
_metrics: ~,
other: {},
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: relay-general/src/pii/processor.rs
source: relay-pii/src/processor.rs
expression: "&data"
---
Event {
Expand Down Expand Up @@ -116,6 +116,7 @@ Event {
spans: ~,
measurements: ~,
breakdowns: ~,
scraping_attempts: ~,
_metrics: ~,
other: {},
}
Loading