Skip to content

Commit

Permalink
awss3exporter: Add Protocol Buf storage format (#30682)
Browse files Browse the repository at this point in the history
**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 <antoine@toulme.name>
  • Loading branch information
adcharre and atoulme committed Jan 29, 2024
1 parent 21bee24 commit a76c319
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .chloggen/awss3-add-protobuf-marshaller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: awss3exporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add the ability to export trace/log/metrics in OTLP ProtoBuf format."

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [30682]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
1 change: 1 addition & 0 deletions exporter/awss3exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The following exporter configuration parameters are supported.
Marshaler determines the format of data sent to AWS S3. Currently, the following marshalers are implemented:

- `otlp_json` (default): the [OpenTelemetry Protocol format](https://github.com/open-telemetry/opentelemetry-proto), represented as json.
- `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.
- `sumo_ic`: the [Sumo Logic Installed Collector Archive format](https://help.sumologic.com/docs/manage/data-archiving/archive/).
**This format is supported only for logs.**

Expand Down
5 changes: 3 additions & 2 deletions exporter/awss3exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ type S3UploaderConfig struct {
type MarshalerType string

const (
OtlpJSON MarshalerType = "otlp_json"
SumoIC MarshalerType = "sumo_ic"
OtlpProtobuf MarshalerType = "otlp_proto"
OtlpJSON MarshalerType = "otlp_json"
SumoIC MarshalerType = "sumo_ic"
)

// Config contains the main configuration options for the s3 exporter
Expand Down
14 changes: 14 additions & 0 deletions exporter/awss3exporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,18 @@ func TestMarshallerName(t *testing.T) {
MarshalerName: "sumo_ic",
},
)

e = cfg.Exporters[component.NewIDWithName("awss3", "proto")].(*Config)

assert.Equal(t, e,
&Config{
S3Uploader: S3UploaderConfig{
Region: "us-east-1",
S3Bucket: "bar",
S3Partition: "minute",
},
MarshalerName: "otlp_proto",
},
)

}
5 changes: 5 additions & 0 deletions exporter/awss3exporter/marshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ var (
func newMarshaler(mType MarshalerType, logger *zap.Logger) (marshaler, error) {
marshaler := &s3Marshaler{logger: logger}
switch mType {
case OtlpProtobuf:
marshaler.logsMarshaler = &plog.ProtoMarshaler{}
marshaler.tracesMarshaler = &ptrace.ProtoMarshaler{}
marshaler.metricsMarshaler = &pmetric.ProtoMarshaler{}
marshaler.fileFormat = "binpb"
case OtlpJSON:
marshaler.logsMarshaler = &plog.JSONMarshaler{}
marshaler.tracesMarshaler = &ptrace.JSONMarshaler{}
Expand Down
6 changes: 6 additions & 0 deletions exporter/awss3exporter/marshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ func TestMarshaler(t *testing.T) {
require.NotNil(t, m)
assert.Equal(t, m.format(), "json")
}
{
m, err := newMarshaler("otlp_proto", zap.NewNop())
assert.NoError(t, err)
require.NotNil(t, m)
assert.Equal(t, m.format(), "binpb")
}
{
m, err := newMarshaler("sumo_ic", zap.NewNop())
assert.NoError(t, err)
Expand Down
8 changes: 7 additions & 1 deletion exporter/awss3exporter/testdata/marshaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ exporters:
s3_bucket: "foo"
marshaler: sumo_ic

awss3/proto:
s3uploader:
s3_bucket: "bar"
marshaler: otlp_proto


processors:
nop:

Expand All @@ -15,4 +21,4 @@ service:
traces:
receivers: [nop]
processors: [nop]
exporters: [awss3]
exporters: [awss3, awss3/proto]

0 comments on commit a76c319

Please sign in to comment.