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

Add a ThreadLocal metrics aggregator #1379

Merged
merged 6 commits into from
Feb 29, 2024
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
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

146 changes: 86 additions & 60 deletions crates/symbolicator-js/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//! Should be `0`, as we should find/use files from within bundles or as individual artifacts.

use symbolic::debuginfo::sourcebundle::SourceFileType;
use symbolicator_service::metric;
use symbolicator_service::metrics;

use crate::interface::ResolvedWith;

Expand Down Expand Up @@ -117,86 +117,112 @@ impl JsMetrics {
}

pub fn submit_metrics(&self, artifact_bundles: u64) {
metric!(time_raw("js.needed_files") = self.needed_files);
metric!(time_raw("js.api_requests") = self.api_requests);
metric!(time_raw("js.queried_bundles") = self.queried_bundles);
metric!(time_raw("js.fetched_bundles") = artifact_bundles);
metric!(time_raw("js.queried_artifacts") = self.queried_artifacts);
metric!(time_raw("js.fetched_artifacts") = self.fetched_artifacts);
metric!(time_raw("js.scraped_files") = self.scraped_files);
metrics::with_client(|aggregator| self.submit_local_metrics(aggregator, artifact_bundles))
}

// TODO: we are currently getting these as counters. maybe we want to use `time_raw` to also
// have a per-event avg, etc.
fn submit_local_metrics(
&self,
aggregator: &mut metrics::LocalAggregator,
artifact_bundles: u64,
) {
// per-event distribution, emitted as `time_raw`
use symbolicator_service::metrics::IntoDistributionValue;
aggregator.emit_timer("js.needed_files", self.needed_files.into_value(), &[]);
aggregator.emit_timer("js.api_requests", self.api_requests.into_value(), &[]);
aggregator.emit_timer("js.queried_bundles", self.queried_bundles.into_value(), &[]);
aggregator.emit_timer("js.fetched_bundles", artifact_bundles.into_value(), &[]);
aggregator.emit_timer(
"js.queried_artifacts",
self.queried_artifacts.into_value(),
&[],
);
aggregator.emit_timer(
"js.fetched_artifacts",
self.fetched_artifacts.into_value(),
&[],
);
aggregator.emit_timer("js.scraped_files", self.scraped_files.into_value(), &[]);

// Sources:
metric!(
counter("js.found_via_bundle_debugid") += self.found_source_via_debugid,
"type" => "source",
aggregator.emit_count(
"js.found_via_bundle_debugid",
self.found_source_via_debugid,
&[("type", "source")],
);
metric!(
counter("js.found_via_bundle_url") += self.found_source_via_release,
"type" => "source",
"lookup" => "release",
aggregator.emit_count(
"js.found_via_bundle_url",
self.found_source_via_release,
&[("type", "source"), ("lookup", "release")],
);
metric!(
counter("js.found_via_bundle_url") += self.found_source_via_release_old,
"type" => "source",
"lookup" => "release-old",
aggregator.emit_count(
"js.found_via_bundle_url",
self.found_source_via_release_old,
&[("type", "source"), ("lookup", "release-old")],
);
metric!(
counter("js.found_via_scraping") += self.found_source_via_scraping,
"type" => "source",
aggregator.emit_count(
"js.found_via_scraping",
self.found_source_via_scraping,
&[("type", "source")],
);
metric!(
counter("js.file_not_found") += self.source_not_found,
"type" => "source",
aggregator.emit_count(
"js.file_not_found",
self.source_not_found,
&[("type", "source")],
);

// SourceMaps:
metric!(
counter("js.found_via_bundle_debugid") += self.found_sourcemap_via_debugid,
"type" => "sourcemap",
aggregator.emit_count(
"js.found_via_bundle_debugid",
self.found_sourcemap_via_debugid,
&[("type", "sourcemap")],
);
metric!(
counter("js.found_via_bundle_url") += self.found_sourcemap_via_release,
"type" => "sourcemap",
"lookup" => "release",
aggregator.emit_count(
"js.found_via_bundle_url",
self.found_sourcemap_via_release,
&[("type", "sourcemap"), ("lookup", "release")],
);
metric!(
counter("js.found_via_bundle_url") += self.found_sourcemap_via_release_old,
"type" => "sourcemap",
"lookup" => "release-old",
aggregator.emit_count(
"js.found_via_bundle_url",
self.found_sourcemap_via_release_old,
&[("type", "sourcemap"), ("lookup", "release-old")],
);
metric!(
counter("js.found_via_scraping") += self.found_sourcemap_via_scraping,
"type" => "sourcemap",
aggregator.emit_count(
"js.found_via_scraping",
self.found_sourcemap_via_scraping,
&[("type", "sourcemap")],
);
metric!(
counter("js.file_not_found") += self.sourcemap_not_found,
"type" => "sourcemap",
aggregator.emit_count(
"js.file_not_found",
self.sourcemap_not_found,
&[("type", "sourcemap")],
);
metric!(counter("js.sourcemap_not_needed") += self.sourcemap_not_needed);
aggregator.emit_count("js.sourcemap_not_needed", self.sourcemap_not_needed, &[]);

// Lookup Method:
metric!(
counter("js.bundle_lookup") += self.found_bundle_via_bundleindex,
"method" => "bundleindex"
aggregator.emit_count(
"js.bundle_lookup",
self.found_bundle_via_bundleindex,
&[("method", "bundleindex")],
);
metric!(
counter("js.bundle_lookup") += self.found_bundle_via_debugid,
"method" => "debugid"
aggregator.emit_count(
"js.bundle_lookup",
self.found_bundle_via_debugid,
&[("method", "debugid")],
);
metric!(
counter("js.bundle_lookup") += self.found_bundle_via_index,
"method" => "index"
aggregator.emit_count(
"js.bundle_lookup",
self.found_bundle_via_index,
&[("method", "index")],
);
metric!(
counter("js.bundle_lookup") += self.found_bundle_via_release,
"method" => "release"
aggregator.emit_count(
"js.bundle_lookup",
self.found_bundle_via_release,
&[("method", "release")],
);
metric!(
counter("js.bundle_lookup") += self.found_bundle_via_release_old,
"method" => "release-old"
aggregator.emit_count(
"js.bundle_lookup",
self.found_bundle_via_release_old,
&[("method", "release-old")],
);
}
}
3 changes: 3 additions & 0 deletions crates/symbolicator-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ aws-sdk-s3 = "1.4.0"
aws-types = "1.0.1"
cadence = "1.0.0"
chrono = { version = "0.4.19", features = ["serde"] }
crossbeam-utils = "0.8.19"
filetime = "0.2.16"
flate2 = "1.0.23"
futures = "0.3.12"
Expand All @@ -29,6 +30,7 @@ moka = { version = "0.12.1", features = ["future", "sync"] }
once_cell = "1.17.1"
rand = "0.8.5"
reqwest = { version = "0.11.0", features = ["gzip", "brotli", "deflate", "json", "stream", "trust-dns"] }
rustc-hash = "1.1.0"
sentry = { version = "0.32.1", features = ["tracing"] }
serde = { version = "1.0.137", features = ["derive", "rc"] }
serde_json = "1.0.81"
Expand All @@ -38,6 +40,7 @@ symbolic = { version = "12.7.1", features = ["cfi", "common-serde", "debuginfo",
symbolicator-sources = { path = "../symbolicator-sources" }
tempfile = "3.2.0"
thiserror = "1.0.31"
thread_local = "1.1.7"
tokio = { version = "1.24.2", features = ["rt", "macros", "fs"] }
tokio-util = { version = "0.7.1", features = ["io"] }
tracing = "0.1.34"
Expand Down
Loading
Loading