Skip to content

Commit

Permalink
feat: Record the encoding in a metric if there is an encrypted payload (
Browse files Browse the repository at this point in the history
#166)

This improves parity with Python autoendpoint.
  • Loading branch information
AzureMarker authored Jun 29, 2020
1 parent 04fee7f commit 8451d3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions autoendpoint/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ impl From<&HttpRequest> for Metrics {
}
}

impl From<&StatsdClient> for Metrics {
fn from(client: &StatsdClient) -> Self {
impl From<StatsdClient> for Metrics {
fn from(client: StatsdClient) -> Self {
Metrics {
client: Some(client.clone()),
client: Some(client),
tags: None,
timer: None,
}
Expand Down
11 changes: 11 additions & 0 deletions autoendpoint/src/server/extractors/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use actix_web::dev::{Payload, PayloadStream};
use actix_web::web::Data;
use actix_web::{FromRequest, HttpRequest};
use autopush_common::util::sec_since_epoch;
use cadence::Counted;
use futures::{future, FutureExt, StreamExt};

/// Extracts notification data from `Subscription` and request data
Expand Down Expand Up @@ -52,6 +53,16 @@ impl FromRequest for Notification {

let headers = NotificationHeaders::from_request(&req, data.is_some())?;

// Record the encoding if we have an encrypted payload
if let Some(encoding) = &headers.content_encoding {
if data.is_some() {
state
.metrics
.incr(&format!("updates.notification.encoding.{}", encoding))
.ok();
}
}

Ok(Notification {
subscription,
headers,
Expand Down

0 comments on commit 8451d3f

Please sign in to comment.