Skip to content

Commit

Permalink
remove protobuf binary marshaler
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Apr 27, 2023
1 parent 6bf1ecc commit 1d3500f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
18 changes: 9 additions & 9 deletions exporter/awss3exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
<!-- end autogenerated section -->

## Schema supported
This exporter targets to support proto/json and proto/binary format
This exporter targets to support proto/json format.

## Exporter Configuration

The following exporter configuration parameters are supported.

| Name | Description | Default |
| :--------------------- | :--------------------------------------------------------------------------------- | ------- |
| `region` | AWS region. | |
| `s3_bucket` | S3 bucket | |
| `s3_prefix` | prefix for the S3 key (root directory inside bucket). | |
| `s3_partition` | time granularity of S3 key: hour or minute |"minute" |
| `file_prefix` | file prefix defined by user | |
| `marshaler_name` | marshaler used to produce output data otlp_json or otlp_proto | |
| Name | Description | Default |
|:---------------|:------------------------------------------------------|----------|
| `region` | AWS region. | |
| `s3_bucket` | S3 bucket | |
| `s3_prefix` | prefix for the S3 key (root directory inside bucket). | |
| `s3_partition` | time granularity of S3 key: hour or minute | "minute" |
| `file_prefix` | file prefix defined by user | |
| `marshaler` | marshaler used to produce output data otlp_json | |

# Example Configuration

Expand Down
8 changes: 7 additions & 1 deletion exporter/awss3exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ type S3UploaderConfig struct {
FilePrefix string `mapstructure:"file_prefix"`
}

type MarshalerType string

const (
OtlpJSON MarshalerType = "otlp_json"
)

// Config contains the main configuration options for the s3 exporter
type Config struct {
S3Uploader S3UploaderConfig `mapstructure:"s3uploader"`
MarshalerName string `mapstructure:"marshaler_name"`
MarshalerName MarshalerType `mapstructure:"marshaler"`

FileFormat string `mapstructure:"file_format"`
}
1 change: 1 addition & 0 deletions exporter/awss3exporter/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

//go:generate mdatagen metadata.yaml

// Package awss3exporter stores OpenTelemetry data as an AWS S3 exporter.
package awss3exporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awss3exporter"
2 changes: 1 addition & 1 deletion exporter/awss3exporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
// NewFactory creates a factory for S3 exporter.
func NewFactory() exporter.Factory {
return exporter.NewFactory(
"awss3",
metadata.Type,
createDefaultConfig,
exporter.WithTraces(createTracesExporter, metadata.Stability),
exporter.WithLogs(createLogsExporter, metadata.Stability),
Expand Down
11 changes: 3 additions & 8 deletions exporter/awss3exporter/marshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,10 @@ var (
ErrUnknownMarshaler = errors.New("unknown marshaler")
)

func NewMarshaler(name string, logger *zap.Logger) (marshaler, error) {
func NewMarshaler(mType MarshalerType, logger *zap.Logger) (marshaler, error) {
marshaler := &s3Marshaler{logger: logger}
switch name {
case "otlp", "otlp_proto":
marshaler.logsMarshaler = &plog.ProtoMarshaler{}
marshaler.tracesMarshaler = &ptrace.ProtoMarshaler{}
marshaler.metricsMarshaler = &pmetric.ProtoMarshaler{}
marshaler.fileFormat = "proto"
case "otlp_json":
switch mType {
case OtlpJSON:
marshaler.logsMarshaler = &plog.JSONMarshaler{}
marshaler.tracesMarshaler = &ptrace.JSONMarshaler{}
marshaler.metricsMarshaler = &pmetric.JSONMarshaler{}
Expand Down
6 changes: 0 additions & 6 deletions exporter/awss3exporter/marshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ 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(), "proto")
}
{
m, err := NewMarshaler("unknown", zap.NewNop())
assert.Error(t, err)
Expand Down

0 comments on commit 1d3500f

Please sign in to comment.