Skip to content

Commit a76c319

Browse files
adcharreatoulme
andauthored
awss3exporter: Add Protocol Buf storage format (#30682)
**Description:** Add ProtoBuf output format to the AWS S3 exporter **Link to tracking Issue:** #30681 **Testing:** Additional unit tests have been added for the new format type and I've also exported data to an S3 bucket in Protobuf format and read it back to confirm that it's working end to end. **Documentation:** Added details of the new marshaler format to the README.md --------- Co-authored-by: Antoine Toulme <[email protected]>
1 parent 21bee24 commit a76c319

File tree

7 files changed

+63
-3
lines changed

7 files changed

+63
-3
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: awss3exporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Add the ability to export trace/log/metrics in OTLP ProtoBuf format."
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [30682]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

exporter/awss3exporter/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The following exporter configuration parameters are supported.
4040
Marshaler determines the format of data sent to AWS S3. Currently, the following marshalers are implemented:
4141

4242
- `otlp_json` (default): the [OpenTelemetry Protocol format](https://github.com/open-telemetry/opentelemetry-proto), represented as json.
43+
- `otlp_proto`: the [OpenTelemetry Protocol format](https://github.com/open-telemetry/opentelemetry-proto), represented as Protocol Buffers. A single protobuf message is written into each object.
4344
- `sumo_ic`: the [Sumo Logic Installed Collector Archive format](https://help.sumologic.com/docs/manage/data-archiving/archive/).
4445
**This format is supported only for logs.**
4546

exporter/awss3exporter/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ type S3UploaderConfig struct {
2626
type MarshalerType string
2727

2828
const (
29-
OtlpJSON MarshalerType = "otlp_json"
30-
SumoIC MarshalerType = "sumo_ic"
29+
OtlpProtobuf MarshalerType = "otlp_proto"
30+
OtlpJSON MarshalerType = "otlp_json"
31+
SumoIC MarshalerType = "sumo_ic"
3132
)
3233

3334
// Config contains the main configuration options for the s3 exporter

exporter/awss3exporter/config_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,18 @@ func TestMarshallerName(t *testing.T) {
179179
MarshalerName: "sumo_ic",
180180
},
181181
)
182+
183+
e = cfg.Exporters[component.NewIDWithName("awss3", "proto")].(*Config)
184+
185+
assert.Equal(t, e,
186+
&Config{
187+
S3Uploader: S3UploaderConfig{
188+
Region: "us-east-1",
189+
S3Bucket: "bar",
190+
S3Partition: "minute",
191+
},
192+
MarshalerName: "otlp_proto",
193+
},
194+
)
195+
182196
}

exporter/awss3exporter/marshaler.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ var (
2626
func newMarshaler(mType MarshalerType, logger *zap.Logger) (marshaler, error) {
2727
marshaler := &s3Marshaler{logger: logger}
2828
switch mType {
29+
case OtlpProtobuf:
30+
marshaler.logsMarshaler = &plog.ProtoMarshaler{}
31+
marshaler.tracesMarshaler = &ptrace.ProtoMarshaler{}
32+
marshaler.metricsMarshaler = &pmetric.ProtoMarshaler{}
33+
marshaler.fileFormat = "binpb"
2934
case OtlpJSON:
3035
marshaler.logsMarshaler = &plog.JSONMarshaler{}
3136
marshaler.tracesMarshaler = &ptrace.JSONMarshaler{}

exporter/awss3exporter/marshaler_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ func TestMarshaler(t *testing.T) {
1818
require.NotNil(t, m)
1919
assert.Equal(t, m.format(), "json")
2020
}
21+
{
22+
m, err := newMarshaler("otlp_proto", zap.NewNop())
23+
assert.NoError(t, err)
24+
require.NotNil(t, m)
25+
assert.Equal(t, m.format(), "binpb")
26+
}
2127
{
2228
m, err := newMarshaler("sumo_ic", zap.NewNop())
2329
assert.NoError(t, err)

exporter/awss3exporter/testdata/marshaler.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ exporters:
77
s3_bucket: "foo"
88
marshaler: sumo_ic
99

10+
awss3/proto:
11+
s3uploader:
12+
s3_bucket: "bar"
13+
marshaler: otlp_proto
14+
15+
1016
processors:
1117
nop:
1218

@@ -15,4 +21,4 @@ service:
1521
traces:
1622
receivers: [nop]
1723
processors: [nop]
18-
exporters: [awss3]
24+
exporters: [awss3, awss3/proto]

0 commit comments

Comments
 (0)