Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
f missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jrconlin committed May 19, 2021
1 parent 197a97d commit 6794f50
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub fn parse_user_agent(agent: &str) -> (WootheeResult<'_>, &str, &str) {
(wresult, metrics_os, metrics_browser)
}

/// Tags are a set of meta information passed along with sentry errors and metrics.
///
/// Not all tags are distributed out. `tags` are searchable and may cause cardinality issues.
/// `extra` are not searchable, but may not be sent to [crate::metrics::Metrics].
#[derive(Clone, Debug)]
pub struct Tags {
pub tags: HashMap<String, String>,
Expand Down
9 changes: 8 additions & 1 deletion src/web/dockerflow.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
//! Mozilla Ops dockerflow endpoints.
//!
//! These are common endpoints that are used for process management. These include
//! * `__heartbeat__` - return process status
//! * `__lbheartbeat__` - used for load balancer availability
//! * `__version__` - return the current process version (and github commit)
use std::collections::HashMap;

use actix_web::{web, HttpRequest, HttpResponse};
use serde_json::Value;

use crate::error::HandlerError;

// Known DockerFlow commands for Ops callbacks
/// Well Known DockerFlow commands for Ops callbacks
pub const DOCKER_FLOW_ENDPOINTS: [&str; 4] = [
"/__heartbeat__",
"/__lbheartbeat__",
Expand Down
5 changes: 2 additions & 3 deletions src/web/middleware/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//! Actix middleware wrappers
// pub mod db;
pub mod sentry;

// # Web Middleware
pub mod sentry;
8 changes: 8 additions & 0 deletions src/web/middleware/sentry.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Wrapper for sentry error reporting
//!
//! This sends [crate::error::HandlerError] events to Sentry
use std::task::Context;
use std::{
cell::{RefCell, RefMut},
Expand Down Expand Up @@ -74,6 +78,10 @@ pub fn queue_report(mut ext: RefMut<'_, Extensions>, err: &Error) {
}
}

/// Report an error with [crate::tags::Tags] and [Event] directly to sentry
///
/// And [Event] can be derived using
/// `sentry::event_from_error(err:Error)`
pub fn report(tags: &Tags, mut event: Event<'static>) {
let tags = tags.clone();
event.tags = tags.clone().tag_tree();
Expand Down
5 changes: 5 additions & 0 deletions src/web/user_agent.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//! Simple UserAgent parser/stripper
use std::fmt;

use woothee::{
parser::{Parser, WootheeResult},
woothee::VALUE_UNKNOWN,
};

/// ADM required browser format form
#[allow(dead_code)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum FormFactor {
Expand All @@ -21,6 +24,7 @@ impl fmt::Display for FormFactor {
}
}

/// Simplified Operating System Family
#[allow(dead_code)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum OsFamily {
Expand Down Expand Up @@ -69,6 +73,7 @@ pub fn strip_ua(ua: &str) -> String {
)
}

/// Convert a UserAgent header into a simplified ([OsFamily], [FormFactor])
pub fn get_device_info(ua: &str) -> (OsFamily, FormFactor) {
let wresult = Parser::new().parse(ua).unwrap_or_default();

Expand Down

0 comments on commit 6794f50

Please sign in to comment.