Commit a23d5ad
feat(otlp-sink): Add support for metrics and logs with configurable SigV4 and headers (#6768)
* feat(otlp-sink): Add support for metrics and logs with configurable SigV4 and headers
Extend the OTLP sink plugin to support all three signal types (traces,
metrics, logs) with full OTLP protocol encoding, configurable SigV4
signing, and custom HTTP headers. Based on the work from @viquer in
#6488, with additional enhancements.
Multi-signal support:
- Extended OTelProtoCodec with convertToResourceMetrics() and
convertToResourceLogs() for encoding all signal types
- Added generic OtlpSignalHandler<T> interface with type-safe
implementations for traces, metrics, and logs
- Per-signal-type buffer architecture for optimal batching
- Signal type determined automatically at runtime from event type
- Generalized sink from Record<Span> to Record<Event>
Configurable SigV4 signing:
- Added service_name field to OtlpSinkConfig (default: xray)
- SigV4Signer uses configurable service name
Additional headers:
- Added additional_headers map config to OtlpSinkConfig
- Protected header blocklist prevents overriding signed headers
- Headers injected after SigV4 signing (not included in signature)
Per-signal metrics:
- Added per-signal counters (rejectedTracesCount, failedMetricsCount, etc.)
- Aggregate counters (rejectedRecordsCount, failedRecordsCount) retained
Region from AWS config:
- getAwsRegion() checks aws.region first, falls back to endpoint parsing
Breaking changes (plugin is @experimental):
- OtlpSink changed from AbstractSink<Record<Span>> to
AbstractSink<Record<Event>>
- Metric counters renamed: rejectedSpansCount to rejectedRecordsCount,
failedSpansCount to failedRecordsCount
Signed-off-by: Roberto Ramirez Vique <viquer@amazon.com>
Signed-off-by: Laszlo Kovacs <laszlokv@amazon.com>
* fix(otlp-sink): Address code review findings
Fix EventHandle leak when encodeEvent() returns null or throws in
OtlpSinkBuffer.runTyped() — release handle in both paths.
Fix SeverityNumber.forNumber() null safety in OTelProtoStandardCodec
to prevent NPE on unrecognized severity numbers.
Cache per-signal metric counters at construction time in
OtlpSinkMetrics to avoid string concatenation and counter lookup on
every increment call in the hot path.
Remove stale OTLP_PATH constant and fallback URI from SigV4Signer
since endpoint is a required config field.
Replace fully-qualified class names with imports in OTelProtoCodec
OTelProtoEncoder interface (ResourceMetrics, ResourceLogs, Log).
Update README: replace stale flush-on-signal-change batching
description with accurate per-signal buffer architecture, add
service_name to configuration options table.
Replace Thread.sleep(300) with Awaitility in OtlpHttpSenderTest for
deterministic async assertions.
Replace OutOfMemoryError with Error in OtlpSinkBufferMultiSignalTest
to avoid triggering JVM OOM handlers in CI.
Signed-off-by: Laszlo Kovacs <laszlokv@amazon.com>
* fix(otlp-sink): Keep rejectedSpansCount/failedSpansCount metric names
Rename TRACE metrics label from 'Traces' to 'Spans' to preserve
backwards compatibility with existing metric allowlists and dashboards.
Per-signal counters now emit rejectedSpansCount, rejectedMetricsCount,
rejectedLogsCount (and corresponding failed* counters).
Remove stale migration note from README since the original metric
names are preserved.
Signed-off-by: Laszlo Kovacs <laszlokv@amazon.com>
---------
Signed-off-by: Roberto Ramirez Vique <viquer@amazon.com>
Signed-off-by: Laszlo Kovacs <laszlokv@amazon.com>1 parent 6ce36ff commit a23d5ad
29 files changed
Lines changed: 3209 additions & 1094 deletions
File tree
- data-prepper-plugins
- otel-proto-common/src
- main/java/org/opensearch/dataprepper/plugins/otel/codec
- test/java/org/opensearch/dataprepper/plugins/otel/codec
- otlp-sink
- src
- main/java/org/opensearch/dataprepper/plugins/sink/otlp
- buffer
- configuration
- http
- metrics
- test/java/org/opensearch/dataprepper/plugins/sink/otlp
- buffer
- configuration
- http
- metrics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
| 9 | + | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
13 | 12 | | |
14 | 13 | | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | | - | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | | - | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
153 | 158 | | |
154 | 159 | | |
155 | 160 | | |
Lines changed: 21 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
| |||
73 | 70 | | |
74 | 71 | | |
75 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
941 | 942 | | |
942 | 943 | | |
943 | 944 | | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
944 | 959 | | |
945 | 960 | | |
946 | 961 | | |
| |||
0 commit comments