-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathlib.rs
More file actions
68 lines (61 loc) · 2.01 KB
/
lib.rs
File metadata and controls
68 lines (61 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Crate for the `bottlecap` project
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
#![deny(clippy::unwrap_used)]
#![deny(unused_extern_crates)]
#![deny(unused_allocation)]
#![deny(unused_assignments)]
#![deny(unused_comparisons)]
#![deny(unreachable_pub)]
#![deny(missing_copy_implementations)]
// #![deny(missing_debug_implementations)]
// TODO rmove these over time
#![allow(missing_docs)]
#![allow(clippy::missing_panics_doc)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::cast_precision_loss)]
#![allow(clippy::needless_pass_by_value)]
pub mod config;
pub mod event_bus;
pub mod events;
pub mod http_client;
pub mod lifecycle;
pub mod logger;
pub mod logs;
pub mod lwa;
pub mod metrics;
pub mod proc;
pub mod secrets;
pub mod tags;
pub mod telemetry;
pub mod traces;
use std::{env, io};
pub const EXTENSION_HOST: &str = "0.0.0.0";
pub const EXTENSION_NAME: &str = "datadog-agent";
pub const EXTENSION_FEATURES: &str = "accountId";
pub const EXTENSION_NAME_HEADER: &str = "Lambda-Extension-Name";
pub const EXTENSION_ID_HEADER: &str = "Lambda-Extension-Identifier";
pub const EXTENSION_ACCEPT_FEATURE_HEADER: &str = "Lambda-Extension-Accept-Feature";
pub const EXTENSION_ROUTE: &str = "2020-01-01/extension";
pub const LAMBDA_RUNTIME_SLUG: &str = "lambda";
// todo: make sure we can override those with environment variables
pub const DOGSTATSD_PORT: u16 = 8125;
pub const TELEMETRY_SUBSCRIPTION_ROUTE: &str = "2022-07-01/telemetry";
// todo(astuyve) should be 8124 on /lambda/logs but
// telemetry is implemented on a raw socket now and
// does not multiplex routes on the same port.
pub const TELEMETRY_PORT: u16 = 8999;
/// Return the base URL for the lambda runtime API
///
/// # Errors
///
/// Function will error if the envar `AWS_LAMBDA_RUNTIME_API` is not set in the
/// environment.
pub fn base_url(route: &str) -> io::Result<String> {
Ok(format!(
"http://{}/{}",
env::var("AWS_LAMBDA_RUNTIME_API")
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e.to_string()))?,
route
))
}