Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awss3exporter: Add Protocol Buf storage format #30682

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is binpb a good term here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did have to look up what a binary protocol buffer file extension should be, according to the Protocol Buf site:
https://protobuf.dev/programming-guides/techniques/#suffixes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for the link! :)

}
{
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]
Loading