Skip to content

Commit

Permalink
move context of glean metrics into statsd get_collections metric (#1638)
Browse files Browse the repository at this point in the history
Co-authored-by: JR Conlin <[email protected]>
  • Loading branch information
taddes and jrconlin authored Dec 4, 2024
1 parent 70f101f commit 7f7cfb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

51 changes: 25 additions & 26 deletions syncserver/src/web/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,33 @@ pub async fn get_collections(
request: HttpRequest,
state: Data<ServerState>,
) -> Result<HttpResponse, ApiError> {
if state.glean_enabled {
// Values below are be passed to the Glean logic to emit metrics.
// This is used to measure DAU (Daily Active Use) of Sync.
let user_agent = request
.headers()
.get(header::USER_AGENT)
.and_then(|header| header.to_str().ok())
.unwrap_or("");
let device_info: DeviceInfo = get_device_info(user_agent);

state.glean_logger.record_events_ping(
&RequestInfo {
user_agent: user_agent.to_owned(),
ip_address: "".to_owned(),
},
&EventsPing {
syncstorage_device_family: device_info.device_family.to_string(),
syncstorage_hashed_device_id: meta.user_id.hashed_device_id.clone(),
syncstorage_hashed_fxa_uid: meta.user_id.hashed_fxa_uid.clone(),
syncstorage_platform: device_info.platform.to_string(),
event: Some(Box::new(SyncstorageGetCollectionsEvent {})),
},
);
}

db_pool
.transaction_http(request, |db| async move {
.transaction_http(request.clone(), |db| async move {
meta.emit_api_metric("request.get_collections");
if state.glean_enabled {
// Values below are be passed to the Glean logic to emit metrics.
// This is used to measure DAU (Daily Active Use) of Sync.
let user_agent = request
.headers()
.get(header::USER_AGENT)
.and_then(|header| header.to_str().ok())
.unwrap_or("");
let device_info: DeviceInfo = get_device_info(user_agent);

state.glean_logger.record_events_ping(
&RequestInfo {
user_agent: user_agent.to_owned(),
ip_address: "".to_owned(),
},
&EventsPing {
syncstorage_device_family: device_info.device_family.to_string(),
syncstorage_hashed_device_id: meta.user_id.hashed_device_id.clone(),
syncstorage_hashed_fxa_uid: meta.user_id.hashed_fxa_uid.clone(),
syncstorage_platform: device_info.platform.to_string(),
event: Some(Box::new(SyncstorageGetCollectionsEvent {})),
},
);
}
let result = db.get_collection_timestamps(meta.user_id).await?;

Ok(HttpResponse::build(StatusCode::OK)
Expand Down

0 comments on commit 7f7cfb7

Please sign in to comment.