-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathmod.rs
More file actions
98 lines (91 loc) · 2.6 KB
/
mod.rs
File metadata and controls
98 lines (91 loc) · 2.6 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use serde::Serialize;
pub mod processor;
/// Context extracted from an `aws.lambda` span and forwarded to the logs pipeline.
#[derive(Clone)]
pub struct DurableContextUpdate {
pub request_id: String,
pub execution_id: String,
pub execution_name: String,
pub first_invocation: Option<bool>,
pub execution_status: Option<String>,
}
/// Durable execution context stored per `request_id` in `LambdaProcessor::durable_context_map`.
#[derive(Clone, Debug)]
pub struct DurableExecutionContext {
pub execution_id: String,
pub execution_name: String,
pub first_invocation: Option<bool>,
pub execution_status: Option<String>,
}
///
/// Intake Log for AWS Lambda Telemetry Events.
///
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct IntakeLog {
/// Setting it as a struct, allowing us to override fields.
pub message: Message,
pub hostname: String,
pub service: String,
#[serde(rename(serialize = "ddtags"))]
pub tags: String,
#[serde(rename(serialize = "ddsource"))]
pub source: String,
}
///
/// Message for AWS Lambda logs.
///
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct Message {
/// The actual log message.
pub message: String,
pub lambda: Lambda,
/// Override the timestamp with the `TelemetryEvent` timestamp.
pub timestamp: i64,
pub status: String,
}
#[derive(Serialize, Debug, Clone, Default, PartialEq)]
pub struct Lambda {
pub arn: String,
pub request_id: Option<String>,
#[serde(
rename = "durable_function.execution_id",
skip_serializing_if = "Option::is_none"
)]
pub durable_execution_id: Option<String>,
#[serde(
rename = "durable_function.execution_name",
skip_serializing_if = "Option::is_none"
)]
pub durable_execution_name: Option<String>,
#[serde(
rename = "durable_function.first_invocation",
skip_serializing_if = "Option::is_none"
)]
pub first_invocation: Option<bool>,
#[serde(
rename = "durable_function.execution_status",
skip_serializing_if = "Option::is_none"
)]
pub durable_execution_status: Option<String>,
}
impl Message {
#[must_use]
pub fn new(
message: String,
request_id: Option<String>,
function_arn: String,
timestamp: i64,
status: Option<String>,
) -> Message {
Message {
message,
lambda: Lambda {
arn: function_arn,
request_id,
..Lambda::default()
},
timestamp,
status: status.unwrap_or("info".to_string()),
}
}
}