-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
config.go
67 lines (57 loc) · 2.38 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package awss3exporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awss3exporter"
import (
"errors"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configcompression"
"go.uber.org/multierr"
)
// S3UploaderConfig contains aws s3 uploader related config to controls things
// like bucket, prefix, batching, connections, retries, etc.
type S3UploaderConfig struct {
Region string `mapstructure:"region"`
S3Bucket string `mapstructure:"s3_bucket"`
S3Prefix string `mapstructure:"s3_prefix"`
S3Partition string `mapstructure:"s3_partition"`
FilePrefix string `mapstructure:"file_prefix"`
Endpoint string `mapstructure:"endpoint"`
RoleArn string `mapstructure:"role_arn"`
S3ForcePathStyle bool `mapstructure:"s3_force_path_style"`
DisableSSL bool `mapstructure:"disable_ssl"`
Compression configcompression.Type `mapstructure:"compression"`
}
type MarshalerType string
const (
OtlpProtobuf MarshalerType = "otlp_proto"
OtlpJSON MarshalerType = "otlp_json"
SumoIC MarshalerType = "sumo_ic"
Body MarshalerType = "body"
)
// Config contains the main configuration options for the s3 exporter
type Config struct {
S3Uploader S3UploaderConfig `mapstructure:"s3uploader"`
MarshalerName MarshalerType `mapstructure:"marshaler"`
// Encoding to apply. If present, overrides the marshaler configuration option.
Encoding *component.ID `mapstructure:"encoding"`
EncodingFileExtension string `mapstructure:"encoding_file_extension"`
}
func (c *Config) Validate() error {
var errs error
if c.S3Uploader.Region == "" {
errs = multierr.Append(errs, errors.New("region is required"))
}
if c.S3Uploader.S3Bucket == "" {
errs = multierr.Append(errs, errors.New("bucket is required"))
}
compression := c.S3Uploader.Compression
if compression.IsCompressed() {
if compression != configcompression.TypeGzip {
errs = multierr.Append(errs, errors.New("unknown compression type"))
}
if c.MarshalerName == SumoIC {
errs = multierr.Append(errs, errors.New("marshaler does not support compression"))
}
}
return errs
}