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
99
100
101
//! Trait definition for trace context extraction from Lambda events.
use Context as LambdaContext;
use Context;
use Link;
use Span;
/// Extracts trace context from Lambda event payloads.
///
/// Different event sources carry trace context in different locations:
/// - HTTP: `traceparent` header using W3C Trace Context
/// - SQS: `AWSTraceHeader` in message system attributes
/// - SNS: Similar to SQS
///
/// Implementations of this trait provide event-specific extraction logic
/// and semantic attributes following OpenTelemetry conventions.
///
/// # Type Parameters
///
/// * `T` - The Lambda event payload type (e.g., `ApiGatewayV2httpRequest`, `SqsEvent`)
///
/// # Example
///
/// ```ignore
/// use opentelemetry_lambda_tower::TraceContextExtractor;
///
/// struct MyExtractor;
///
/// impl TraceContextExtractor<MyEvent> for MyExtractor {
/// fn extract_context(&self, _payload: &MyEvent) -> opentelemetry::Context {
/// opentelemetry::Context::current()
/// }
///
/// fn trigger_type(&self) -> &'static str {
/// "other"
/// }
///
/// fn span_name(&self, _payload: &MyEvent, ctx: &LambdaContext) -> String {
/// ctx.env_config.function_name.clone()
/// }
///
/// fn record_attributes(&self, _payload: &MyEvent, _span: &tracing::Span) {}
/// }
/// ```