Skip to content

Commit

Permalink
feat(app-start): Add Android app start-related spans (#2927)
Browse files Browse the repository at this point in the history
These spans are nested operations under the app.start.* spans on
Android necessary for debugging start time operations. This only
adds the application portion of the spans. We are currently awaiting
a new span that tracks the system portion of the app start and I
will add that as another span op afterwards.
  • Loading branch information
narsaynorath authored Jan 11, 2024
1 parent 71621db commit 118cafc
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Normalize metric resource identifiers in `event._metrics_summary` and `span._metrics_summary`. ([#2914](https://github.com/getsentry/relay/pull/2914))
- Validate error_id and trace_id vectors in replay deserializer. ([#2931](https://github.com/getsentry/relay/pull/2931))
- Add a data category for indexed spans. ([#2937](https://github.com/getsentry/relay/pull/2937))
- Add nested Android app start span ops to span ingestion ([#2927](https://github.com/getsentry/relay/pull/2927))

## 23.12.1

Expand Down
18 changes: 15 additions & 3 deletions relay-dynamic-config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ pub fn add_span_metrics(project_config: &mut ProjectConfig) {
return;
}

config.metrics.extend(span_metrics());
let is_extract_all = project_config
.features
.has(Feature::SpanMetricsExtractionAllModules);

config.metrics.extend(span_metrics(is_extract_all));

config._span_metrics_extended = true;
if config.version == 0 {
Expand All @@ -56,14 +60,22 @@ pub fn add_span_metrics(project_config: &mut ProjectConfig) {
}

/// Metrics with tags applied as required.
fn span_metrics() -> impl IntoIterator<Item = MetricSpec> {
fn span_metrics(is_extract_all: bool) -> impl IntoIterator<Item = MetricSpec> {
let flagged_mobile_ops = {
let mut ops = MOBILE_OPS.to_vec();
if is_extract_all {
ops.extend(["contentprovider.load", "application.load", "activity.load"]);
}
ops
};

let is_db = RuleCondition::eq("span.sentry_tags.category", "db")
& !(RuleCondition::eq("span.system", "mongodb")
| RuleCondition::glob("span.op", DISABLED_DATABASES)
| RuleCondition::glob("span.description", MONGODB_QUERIES));
let is_resource = RuleCondition::glob("span.op", RESOURCE_SPAN_OPS);

let is_mobile_op = RuleCondition::glob("span.op", MOBILE_OPS);
let is_mobile_op = RuleCondition::glob("span.op", flagged_mobile_ops);

let is_mobile_sdk = RuleCondition::eq("span.sentry_tags.mobile", "true");

Expand Down
41 changes: 41 additions & 0 deletions relay-event-normalization/src/normalize/span/description/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ pub(crate) fn scrub_span_description(span: &Span) -> Option<String> {
// They are low-cardinality.
Some(description.to_owned())
}
("contentprovider", "load") => {
// `contentprovider.load` spans contain paths of third party framework components
// and their onCreate method such as
// `io.sentry.android.core.SentryPerformanceProvider.onCreate`, which
// _should_ be low-cardinality, on the order of 10s per project.
Some(description.to_owned())
}
("application", "load") => {
// `application.load` spans contain paths of app components and their
// onCreate method such as
// `io.sentry.samples.android.MyApplication.onCreate`, which _should_ be
// low-cardinality.
Some(description.to_owned())
}
("activity", "load") => {
// `activity.load` spans contain paths of app components and their onCreate/onStart
// method such as `io.sentry.samples.android.MainActivity.onCreate`, which
// _should_ be low-cardinality, less than 10 per project.
Some(description.to_owned())
}
("file", _) => scrub_file(description),
_ => None,
})
Expand Down Expand Up @@ -683,6 +703,27 @@ mod tests {
"ListAppViewController"
);

span_description_test!(
contentprovider_load,
"io.sentry.android.core.SentryPerformanceProvider.onCreate",
"contentprovider.load",
"io.sentry.android.core.SentryPerformanceProvider.onCreate"
);

span_description_test!(
application_load,
"io.sentry.samples.android.MyApplication.onCreate",
"application.load",
"io.sentry.samples.android.MyApplication.onCreate"
);

span_description_test!(
activity_load,
"io.sentry.samples.android.MainActivity.onCreate",
"activity.load",
"io.sentry.samples.android.MainActivity.onCreate"
);

span_description_test!(
span_description_file_write_keep_extension_only,
"data.data (42 KB)",
Expand Down
24 changes: 24 additions & 0 deletions relay-server/src/metrics_extraction/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,30 @@ mod tests {
"start_timestamp": 1597976300.0000000,
"timestamp": 1597976303.0000000,
"trace_id": "ff62a8b040f340bda5d830223def1d81"
},
{
"op": "contentprovider.load",
"description": "io.sentry.android.core.SentryPerformanceProvider.onCreate",
"span_id": "bd429c44b67a3eb2",
"start_timestamp": 1597976300.0000000,
"timestamp": 1597976303.0000000,
"trace_id": "ff62a8b040f340bda5d830223def1d81"
},
{
"op": "application.load",
"description": "io.sentry.samples.android.MyApplication.onCreate",
"span_id": "bd429c44b67a3eb2",
"start_timestamp": 1597976300.0000000,
"timestamp": 1597976303.0000000,
"trace_id": "ff62a8b040f340bda5d830223def1d81"
},
{
"op": "activity.load",
"description": "io.sentry.samples.android.MainActivity.onCreate",
"span_id": "bd429c44b67a3eb2",
"start_timestamp": 1597976300.0000000,
"timestamp": 1597976303.0000000,
"trace_id": "ff62a8b040f340bda5d830223def1d81"
}
]
}
Expand Down
Loading

0 comments on commit 118cafc

Please sign in to comment.