diff --git a/CHANGELOG.md b/CHANGELOG.md index c282dbff84f..e6019a59494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `Severitier` and `SeverityVar` types are added to `go.opentelemetry.io/contrib/processors/minsev` allowing dynamic configuration of the severity used by the `LogProcessor`. (#6116) - Move examples from `go.opentelemetry.io/otel` to this repository under `examples` directory. (#6158) +- Support yaml/json struct tags for generated code in `go.opentelemetry.io/contrib/config`. (#5433) +- Add support for parsing YAML configuration via `ParseYAML` in `go.opentelemetry.io/contrib/config`. (#5433) ### Changed diff --git a/Makefile b/Makefile index 751a68f81ab..5489e46e065 100644 --- a/Makefile +++ b/Makefile @@ -326,7 +326,6 @@ genjsonschema: genjsonschema-cleanup $(GOJSONSCHEMA) --capitalization OTLP \ --struct-name-from-title \ --package config \ - --tags mapstructure \ --output ${GENERATED_CONFIG} \ ${OPENTELEMETRY_CONFIGURATION_JSONSCHEMA_SRC_DIR}/schema/opentelemetry_configuration.json @echo Modify jsonschema generated files. diff --git a/config/config.go b/config/config.go index 6b8d43cd468..052052cb658 100644 --- a/config/config.go +++ b/config/config.go @@ -7,6 +7,8 @@ import ( "context" "errors" + "gopkg.in/yaml.v3" + "go.opentelemetry.io/otel/log" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/trace" @@ -128,5 +130,15 @@ func WithOpenTelemetryConfiguration(cfg OpenTelemetryConfiguration) Configuratio } // TODO: implement parsing functionality: -// - https://github.com/open-telemetry/opentelemetry-go-contrib/issues/4373 // - https://github.com/open-telemetry/opentelemetry-go-contrib/issues/4412 + +// ParseYAML parses a YAML configuration file into an OpenTelemetryConfiguration. +func ParseYAML(file []byte) (*OpenTelemetryConfiguration, error) { + var cfg OpenTelemetryConfiguration + err := yaml.Unmarshal(file, &cfg) + if err != nil { + return nil, err + } + + return &cfg, nil +} diff --git a/config/config_test.go b/config/config_test.go index 66c1448d603..f69a2dcdf9a 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -5,6 +5,10 @@ package config import ( "context" + "encoding/json" + "errors" + "os" + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -59,6 +63,306 @@ func TestNewSDK(t *testing.T) { } } +var v02OpenTelemetryConfig = OpenTelemetryConfiguration{ + Disabled: ptr(false), + FileFormat: "0.2", + AttributeLimits: &AttributeLimits{ + AttributeCountLimit: ptr(128), + AttributeValueLengthLimit: ptr(4096), + }, + LoggerProvider: &LoggerProvider{ + Limits: &LogRecordLimits{ + AttributeCountLimit: ptr(128), + AttributeValueLengthLimit: ptr(4096), + }, + Processors: []LogRecordProcessor{ + { + Batch: &BatchLogRecordProcessor{ + ExportTimeout: ptr(30000), + Exporter: LogRecordExporter{ + OTLP: &OTLP{ + Certificate: ptr("/app/cert.pem"), + ClientCertificate: ptr("/app/cert.pem"), + ClientKey: ptr("/app/cert.pem"), + Compression: ptr("gzip"), + Endpoint: "http://localhost:4318", + Headers: Headers{ + "api-key": "1234", + }, + Insecure: ptr(false), + Protocol: "http/protobuf", + Timeout: ptr(10000), + }, + }, + MaxExportBatchSize: ptr(512), + MaxQueueSize: ptr(2048), + ScheduleDelay: ptr(5000), + }, + }, + { + Simple: &SimpleLogRecordProcessor{ + Exporter: LogRecordExporter{ + Console: Console{}, + }, + }, + }, + }, + }, + MeterProvider: &MeterProvider{ + Readers: []MetricReader{ + { + Pull: &PullMetricReader{ + Exporter: MetricExporter{ + Prometheus: &Prometheus{ + Host: ptr("localhost"), + Port: ptr(9464), + WithResourceConstantLabels: &IncludeExclude{ + Excluded: []string{"service.attr1"}, + Included: []string{"service*"}, + }, + WithoutScopeInfo: ptr(false), + WithoutTypeSuffix: ptr(false), + WithoutUnits: ptr(false), + }, + }, + }, + }, + { + Periodic: &PeriodicMetricReader{ + Exporter: MetricExporter{ + OTLP: &OTLPMetric{ + Certificate: ptr("/app/cert.pem"), + ClientCertificate: ptr("/app/cert.pem"), + ClientKey: ptr("/app/cert.pem"), + Compression: ptr("gzip"), + DefaultHistogramAggregation: ptr(OTLPMetricDefaultHistogramAggregationBase2ExponentialBucketHistogram), + Endpoint: "http://localhost:4318", + Headers: Headers{ + "api-key": "1234", + }, + Insecure: ptr(false), + Protocol: "http/protobuf", + TemporalityPreference: ptr("delta"), + Timeout: ptr(10000), + }, + }, + Interval: ptr(5000), + Timeout: ptr(30000), + }, + }, + { + Periodic: &PeriodicMetricReader{ + Exporter: MetricExporter{ + Console: Console{}, + }, + }, + }, + }, + Views: []View{ + { + Selector: &ViewSelector{ + InstrumentName: ptr("my-instrument"), + InstrumentType: ptr(ViewSelectorInstrumentTypeHistogram), + MeterName: ptr("my-meter"), + MeterSchemaUrl: ptr("https://opentelemetry.io/schemas/1.16.0"), + MeterVersion: ptr("1.0.0"), + Unit: ptr("ms"), + }, + Stream: &ViewStream{ + Aggregation: &ViewStreamAggregation{ + ExplicitBucketHistogram: &ViewStreamAggregationExplicitBucketHistogram{ + Boundaries: []float64{0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000}, + RecordMinMax: ptr(true), + }, + }, + AttributeKeys: []string{"key1", "key2"}, + Description: ptr("new_description"), + Name: ptr("new_instrument_name"), + }, + }, + }, + }, + Propagator: &Propagator{ + Composite: []string{"tracecontext", "baggage", "b3", "b3multi", "jaeger", "xray", "ottrace"}, + }, + Resource: &Resource{ + Attributes: Attributes{ + "service.name": "unknown_service", + }, + Detectors: &Detectors{ + Attributes: &DetectorsAttributes{ + Excluded: []string{"process.command_args"}, + Included: []string{"process.*"}, + }, + }, + SchemaUrl: ptr("https://opentelemetry.io/schemas/1.16.0"), + }, + TracerProvider: &TracerProvider{ + Limits: &SpanLimits{ + AttributeCountLimit: ptr(128), + AttributeValueLengthLimit: ptr(4096), + EventCountLimit: ptr(128), + EventAttributeCountLimit: ptr(128), + LinkCountLimit: ptr(128), + LinkAttributeCountLimit: ptr(128), + }, + Processors: []SpanProcessor{ + { + Batch: &BatchSpanProcessor{ + ExportTimeout: ptr(30000), + Exporter: SpanExporter{ + OTLP: &OTLP{ + Certificate: ptr("/app/cert.pem"), + ClientCertificate: ptr("/app/cert.pem"), + ClientKey: ptr("/app/cert.pem"), + Compression: ptr("gzip"), + Endpoint: "http://localhost:4318", + Headers: Headers{ + "api-key": "1234", + }, + Insecure: ptr(false), + Protocol: "http/protobuf", + Timeout: ptr(10000), + }, + }, + MaxExportBatchSize: ptr(512), + MaxQueueSize: ptr(2048), + ScheduleDelay: ptr(5000), + }, + }, + { + Batch: &BatchSpanProcessor{ + Exporter: SpanExporter{ + Zipkin: &Zipkin{ + Endpoint: "http://localhost:9411/api/v2/spans", + Timeout: ptr(10000), + }, + }, + }, + }, + { + Simple: &SimpleSpanProcessor{ + Exporter: SpanExporter{ + Console: Console{}, + }, + }, + }, + }, + Sampler: &Sampler{ + ParentBased: &SamplerParentBased{ + LocalParentNotSampled: &Sampler{ + AlwaysOff: SamplerAlwaysOff{}, + }, + LocalParentSampled: &Sampler{ + AlwaysOn: SamplerAlwaysOn{}, + }, + RemoteParentNotSampled: &Sampler{ + AlwaysOff: SamplerAlwaysOff{}, + }, + RemoteParentSampled: &Sampler{ + AlwaysOn: SamplerAlwaysOn{}, + }, + Root: &Sampler{ + TraceIDRatioBased: &SamplerTraceIDRatioBased{ + Ratio: ptr(0.0001), + }, + }, + }, + }, + }, +} + +func TestParseYAML(t *testing.T) { + tests := []struct { + name string + input string + wantErr error + wantType interface{} + }{ + { + name: "valid YAML config", + input: `valid_empty.yaml`, + wantErr: nil, + wantType: &OpenTelemetryConfiguration{ + Disabled: ptr(false), + FileFormat: "0.1", + }, + }, + { + name: "invalid config", + input: "invalid_bool.yaml", + wantErr: errors.New(`yaml: unmarshal errors: + line 2: cannot unmarshal !!str ` + "`notabool`" + ` into bool`), + }, + { + name: "valid v0.2 config", + input: "v0.2.yaml", + wantType: &v02OpenTelemetryConfig, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + b, err := os.ReadFile(filepath.Join("testdata", tt.input)) + require.NoError(t, err) + + got, err := ParseYAML(b) + if tt.wantErr != nil { + require.Equal(t, tt.wantErr.Error(), err.Error()) + } else { + require.NoError(t, err) + assert.Equal(t, tt.wantType, got) + } + }) + } +} + +func TestSerializeJSON(t *testing.T) { + tests := []struct { + name string + input string + wantErr error + wantType interface{} + }{ + { + name: "valid JSON config", + input: `valid_empty.json`, + wantErr: nil, + wantType: OpenTelemetryConfiguration{ + Disabled: ptr(false), + FileFormat: "0.1", + }, + }, + { + name: "invalid config", + input: "invalid_bool.json", + wantErr: errors.New(`json: cannot unmarshal string into Go struct field Plain.disabled of type bool`), + }, + { + name: "valid v0.2 config", + input: "v0.2.json", + wantType: v02OpenTelemetryConfig, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + b, err := os.ReadFile(filepath.Join("testdata", tt.input)) + require.NoError(t, err) + + var got OpenTelemetryConfiguration + err = json.Unmarshal(b, &got) + + if tt.wantErr != nil { + require.Equal(t, tt.wantErr.Error(), err.Error()) + } else { + require.NoError(t, err) + assert.Equal(t, tt.wantType, got) + } + }) + } +} + func ptr[T any](v T) *T { return &v } diff --git a/config/generated_config.go b/config/generated_config.go index 244a9756899..2315641db64 100644 --- a/config/generated_config.go +++ b/config/generated_config.go @@ -9,11 +9,11 @@ import "reflect" type AttributeLimits struct { // AttributeCountLimit corresponds to the JSON schema field // "attribute_count_limit". - AttributeCountLimit *int `mapstructure:"attribute_count_limit,omitempty"` + AttributeCountLimit *int `json:"attribute_count_limit,omitempty" yaml:"attribute_count_limit,omitempty" mapstructure:"attribute_count_limit,omitempty"` // AttributeValueLengthLimit corresponds to the JSON schema field // "attribute_value_length_limit". - AttributeValueLengthLimit *int `mapstructure:"attribute_value_length_limit,omitempty"` + AttributeValueLengthLimit *int `json:"attribute_value_length_limit,omitempty" yaml:"attribute_value_length_limit,omitempty" mapstructure:"attribute_value_length_limit,omitempty"` AdditionalProperties interface{} } @@ -22,20 +22,20 @@ type Attributes map[string]interface{} type BatchLogRecordProcessor struct { // ExportTimeout corresponds to the JSON schema field "export_timeout". - ExportTimeout *int `mapstructure:"export_timeout,omitempty"` + ExportTimeout *int `json:"export_timeout,omitempty" yaml:"export_timeout,omitempty" mapstructure:"export_timeout,omitempty"` // Exporter corresponds to the JSON schema field "exporter". - Exporter LogRecordExporter `mapstructure:"exporter"` + Exporter LogRecordExporter `json:"exporter" yaml:"exporter" mapstructure:"exporter"` // MaxExportBatchSize corresponds to the JSON schema field // "max_export_batch_size". - MaxExportBatchSize *int `mapstructure:"max_export_batch_size,omitempty"` + MaxExportBatchSize *int `json:"max_export_batch_size,omitempty" yaml:"max_export_batch_size,omitempty" mapstructure:"max_export_batch_size,omitempty"` // MaxQueueSize corresponds to the JSON schema field "max_queue_size". - MaxQueueSize *int `mapstructure:"max_queue_size,omitempty"` + MaxQueueSize *int `json:"max_queue_size,omitempty" yaml:"max_queue_size,omitempty" mapstructure:"max_queue_size,omitempty"` // ScheduleDelay corresponds to the JSON schema field "schedule_delay". - ScheduleDelay *int `mapstructure:"schedule_delay,omitempty"` + ScheduleDelay *int `json:"schedule_delay,omitempty" yaml:"schedule_delay,omitempty" mapstructure:"schedule_delay,omitempty"` } // UnmarshalJSON implements json.Unmarshaler. @@ -58,20 +58,20 @@ func (j *BatchLogRecordProcessor) UnmarshalJSON(b []byte) error { type BatchSpanProcessor struct { // ExportTimeout corresponds to the JSON schema field "export_timeout". - ExportTimeout *int `mapstructure:"export_timeout,omitempty"` + ExportTimeout *int `json:"export_timeout,omitempty" yaml:"export_timeout,omitempty" mapstructure:"export_timeout,omitempty"` // Exporter corresponds to the JSON schema field "exporter". - Exporter SpanExporter `mapstructure:"exporter"` + Exporter SpanExporter `json:"exporter" yaml:"exporter" mapstructure:"exporter"` // MaxExportBatchSize corresponds to the JSON schema field // "max_export_batch_size". - MaxExportBatchSize *int `mapstructure:"max_export_batch_size,omitempty"` + MaxExportBatchSize *int `json:"max_export_batch_size,omitempty" yaml:"max_export_batch_size,omitempty" mapstructure:"max_export_batch_size,omitempty"` // MaxQueueSize corresponds to the JSON schema field "max_queue_size". - MaxQueueSize *int `mapstructure:"max_queue_size,omitempty"` + MaxQueueSize *int `json:"max_queue_size,omitempty" yaml:"max_queue_size,omitempty" mapstructure:"max_queue_size,omitempty"` // ScheduleDelay corresponds to the JSON schema field "schedule_delay". - ScheduleDelay *int `mapstructure:"schedule_delay,omitempty"` + ScheduleDelay *int `json:"schedule_delay,omitempty" yaml:"schedule_delay,omitempty" mapstructure:"schedule_delay,omitempty"` } // UnmarshalJSON implements json.Unmarshaler. @@ -98,33 +98,33 @@ type Console map[string]interface{} type Detectors struct { // Attributes corresponds to the JSON schema field "attributes". - Attributes *DetectorsAttributes `mapstructure:"attributes,omitempty"` + Attributes *DetectorsAttributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"` } type DetectorsAttributes struct { // Excluded corresponds to the JSON schema field "excluded". - Excluded []string `mapstructure:"excluded,omitempty"` + Excluded []string `json:"excluded,omitempty" yaml:"excluded,omitempty" mapstructure:"excluded,omitempty"` // Included corresponds to the JSON schema field "included". - Included []string `mapstructure:"included,omitempty"` + Included []string `json:"included,omitempty" yaml:"included,omitempty" mapstructure:"included,omitempty"` } type Headers map[string]string type IncludeExclude struct { // Excluded corresponds to the JSON schema field "excluded". - Excluded []string `mapstructure:"excluded,omitempty"` + Excluded []string `json:"excluded,omitempty" yaml:"excluded,omitempty" mapstructure:"excluded,omitempty"` // Included corresponds to the JSON schema field "included". - Included []string `mapstructure:"included,omitempty"` + Included []string `json:"included,omitempty" yaml:"included,omitempty" mapstructure:"included,omitempty"` } type LogRecordExporter struct { // Console corresponds to the JSON schema field "console". - Console Console `mapstructure:"console,omitempty"` + Console Console `json:"console,omitempty" yaml:"console,omitempty" mapstructure:"console,omitempty"` // OTLP corresponds to the JSON schema field "otlp". - OTLP *OTLP `mapstructure:"otlp,omitempty"` + OTLP *OTLP `json:"otlp,omitempty" yaml:"otlp,omitempty" mapstructure:"otlp,omitempty"` AdditionalProperties interface{} } @@ -132,124 +132,124 @@ type LogRecordExporter struct { type LogRecordLimits struct { // AttributeCountLimit corresponds to the JSON schema field // "attribute_count_limit". - AttributeCountLimit *int `mapstructure:"attribute_count_limit,omitempty"` + AttributeCountLimit *int `json:"attribute_count_limit,omitempty" yaml:"attribute_count_limit,omitempty" mapstructure:"attribute_count_limit,omitempty"` // AttributeValueLengthLimit corresponds to the JSON schema field // "attribute_value_length_limit". - AttributeValueLengthLimit *int `mapstructure:"attribute_value_length_limit,omitempty"` + AttributeValueLengthLimit *int `json:"attribute_value_length_limit,omitempty" yaml:"attribute_value_length_limit,omitempty" mapstructure:"attribute_value_length_limit,omitempty"` } type LogRecordProcessor struct { // Batch corresponds to the JSON schema field "batch". - Batch *BatchLogRecordProcessor `mapstructure:"batch,omitempty"` + Batch *BatchLogRecordProcessor `json:"batch,omitempty" yaml:"batch,omitempty" mapstructure:"batch,omitempty"` // Simple corresponds to the JSON schema field "simple". - Simple *SimpleLogRecordProcessor `mapstructure:"simple,omitempty"` + Simple *SimpleLogRecordProcessor `json:"simple,omitempty" yaml:"simple,omitempty" mapstructure:"simple,omitempty"` AdditionalProperties interface{} } type LoggerProvider struct { // Limits corresponds to the JSON schema field "limits". - Limits *LogRecordLimits `mapstructure:"limits,omitempty"` + Limits *LogRecordLimits `json:"limits,omitempty" yaml:"limits,omitempty" mapstructure:"limits,omitempty"` // Processors corresponds to the JSON schema field "processors". - Processors []LogRecordProcessor `mapstructure:"processors,omitempty"` + Processors []LogRecordProcessor `json:"processors,omitempty" yaml:"processors,omitempty" mapstructure:"processors,omitempty"` } type MeterProvider struct { // Readers corresponds to the JSON schema field "readers". - Readers []MetricReader `mapstructure:"readers,omitempty"` + Readers []MetricReader `json:"readers,omitempty" yaml:"readers,omitempty" mapstructure:"readers,omitempty"` // Views corresponds to the JSON schema field "views". - Views []View `mapstructure:"views,omitempty"` + Views []View `json:"views,omitempty" yaml:"views,omitempty" mapstructure:"views,omitempty"` } type MetricExporter struct { // Console corresponds to the JSON schema field "console". - Console Console `mapstructure:"console,omitempty"` + Console Console `json:"console,omitempty" yaml:"console,omitempty" mapstructure:"console,omitempty"` // OTLP corresponds to the JSON schema field "otlp". - OTLP *OTLPMetric `mapstructure:"otlp,omitempty"` + OTLP *OTLPMetric `json:"otlp,omitempty" yaml:"otlp,omitempty" mapstructure:"otlp,omitempty"` // Prometheus corresponds to the JSON schema field "prometheus". - Prometheus *Prometheus `mapstructure:"prometheus,omitempty"` + Prometheus *Prometheus `json:"prometheus,omitempty" yaml:"prometheus,omitempty" mapstructure:"prometheus,omitempty"` AdditionalProperties interface{} } type MetricReader struct { // Periodic corresponds to the JSON schema field "periodic". - Periodic *PeriodicMetricReader `mapstructure:"periodic,omitempty"` + Periodic *PeriodicMetricReader `json:"periodic,omitempty" yaml:"periodic,omitempty" mapstructure:"periodic,omitempty"` // Pull corresponds to the JSON schema field "pull". - Pull *PullMetricReader `mapstructure:"pull,omitempty"` + Pull *PullMetricReader `json:"pull,omitempty" yaml:"pull,omitempty" mapstructure:"pull,omitempty"` } type OTLP struct { // Certificate corresponds to the JSON schema field "certificate". - Certificate *string `mapstructure:"certificate,omitempty"` + Certificate *string `json:"certificate,omitempty" yaml:"certificate,omitempty" mapstructure:"certificate,omitempty"` // ClientCertificate corresponds to the JSON schema field "client_certificate". - ClientCertificate *string `mapstructure:"client_certificate,omitempty"` + ClientCertificate *string `json:"client_certificate,omitempty" yaml:"client_certificate,omitempty" mapstructure:"client_certificate,omitempty"` // ClientKey corresponds to the JSON schema field "client_key". - ClientKey *string `mapstructure:"client_key,omitempty"` + ClientKey *string `json:"client_key,omitempty" yaml:"client_key,omitempty" mapstructure:"client_key,omitempty"` // Compression corresponds to the JSON schema field "compression". - Compression *string `mapstructure:"compression,omitempty"` + Compression *string `json:"compression,omitempty" yaml:"compression,omitempty" mapstructure:"compression,omitempty"` // Endpoint corresponds to the JSON schema field "endpoint". - Endpoint string `mapstructure:"endpoint"` + Endpoint string `json:"endpoint" yaml:"endpoint" mapstructure:"endpoint"` // Headers corresponds to the JSON schema field "headers". - Headers Headers `mapstructure:"headers,omitempty"` + Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty" mapstructure:"headers,omitempty"` // Insecure corresponds to the JSON schema field "insecure". - Insecure *bool `mapstructure:"insecure,omitempty"` + Insecure *bool `json:"insecure,omitempty" yaml:"insecure,omitempty" mapstructure:"insecure,omitempty"` // Protocol corresponds to the JSON schema field "protocol". - Protocol string `mapstructure:"protocol"` + Protocol string `json:"protocol" yaml:"protocol" mapstructure:"protocol"` // Timeout corresponds to the JSON schema field "timeout". - Timeout *int `mapstructure:"timeout,omitempty"` + Timeout *int `json:"timeout,omitempty" yaml:"timeout,omitempty" mapstructure:"timeout,omitempty"` } type OTLPMetric struct { // Certificate corresponds to the JSON schema field "certificate". - Certificate *string `mapstructure:"certificate,omitempty"` + Certificate *string `json:"certificate,omitempty" yaml:"certificate,omitempty" mapstructure:"certificate,omitempty"` // ClientCertificate corresponds to the JSON schema field "client_certificate". - ClientCertificate *string `mapstructure:"client_certificate,omitempty"` + ClientCertificate *string `json:"client_certificate,omitempty" yaml:"client_certificate,omitempty" mapstructure:"client_certificate,omitempty"` // ClientKey corresponds to the JSON schema field "client_key". - ClientKey *string `mapstructure:"client_key,omitempty"` + ClientKey *string `json:"client_key,omitempty" yaml:"client_key,omitempty" mapstructure:"client_key,omitempty"` // Compression corresponds to the JSON schema field "compression". - Compression *string `mapstructure:"compression,omitempty"` + Compression *string `json:"compression,omitempty" yaml:"compression,omitempty" mapstructure:"compression,omitempty"` // DefaultHistogramAggregation corresponds to the JSON schema field // "default_histogram_aggregation". - DefaultHistogramAggregation *OTLPMetricDefaultHistogramAggregation `mapstructure:"default_histogram_aggregation,omitempty"` + DefaultHistogramAggregation *OTLPMetricDefaultHistogramAggregation `json:"default_histogram_aggregation,omitempty" yaml:"default_histogram_aggregation,omitempty" mapstructure:"default_histogram_aggregation,omitempty"` // Endpoint corresponds to the JSON schema field "endpoint". - Endpoint string `mapstructure:"endpoint"` + Endpoint string `json:"endpoint" yaml:"endpoint" mapstructure:"endpoint"` // Headers corresponds to the JSON schema field "headers". - Headers Headers `mapstructure:"headers,omitempty"` + Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty" mapstructure:"headers,omitempty"` // Insecure corresponds to the JSON schema field "insecure". - Insecure *bool `mapstructure:"insecure,omitempty"` + Insecure *bool `json:"insecure,omitempty" yaml:"insecure,omitempty" mapstructure:"insecure,omitempty"` // Protocol corresponds to the JSON schema field "protocol". - Protocol string `mapstructure:"protocol"` + Protocol string `json:"protocol" yaml:"protocol" mapstructure:"protocol"` // TemporalityPreference corresponds to the JSON schema field // "temporality_preference". - TemporalityPreference *string `mapstructure:"temporality_preference,omitempty"` + TemporalityPreference *string `json:"temporality_preference,omitempty" yaml:"temporality_preference,omitempty" mapstructure:"temporality_preference,omitempty"` // Timeout corresponds to the JSON schema field "timeout". - Timeout *int `mapstructure:"timeout,omitempty"` + Timeout *int `json:"timeout,omitempty" yaml:"timeout,omitempty" mapstructure:"timeout,omitempty"` } type OTLPMetricDefaultHistogramAggregation string @@ -326,28 +326,28 @@ func (j *OTLP) UnmarshalJSON(b []byte) error { type OpenTelemetryConfiguration struct { // AttributeLimits corresponds to the JSON schema field "attribute_limits". - AttributeLimits *AttributeLimits `mapstructure:"attribute_limits,omitempty"` + AttributeLimits *AttributeLimits `json:"attribute_limits,omitempty" yaml:"attribute_limits,omitempty" mapstructure:"attribute_limits,omitempty"` // Disabled corresponds to the JSON schema field "disabled". - Disabled *bool `mapstructure:"disabled,omitempty"` + Disabled *bool `json:"disabled,omitempty" yaml:"disabled,omitempty" mapstructure:"disabled,omitempty"` // FileFormat corresponds to the JSON schema field "file_format". - FileFormat string `mapstructure:"file_format"` + FileFormat string `json:"file_format" yaml:"file_format" mapstructure:"file_format"` // LoggerProvider corresponds to the JSON schema field "logger_provider". - LoggerProvider *LoggerProvider `mapstructure:"logger_provider,omitempty"` + LoggerProvider *LoggerProvider `json:"logger_provider,omitempty" yaml:"logger_provider,omitempty" mapstructure:"logger_provider,omitempty"` // MeterProvider corresponds to the JSON schema field "meter_provider". - MeterProvider *MeterProvider `mapstructure:"meter_provider,omitempty"` + MeterProvider *MeterProvider `json:"meter_provider,omitempty" yaml:"meter_provider,omitempty" mapstructure:"meter_provider,omitempty"` // Propagator corresponds to the JSON schema field "propagator". - Propagator *Propagator `mapstructure:"propagator,omitempty"` + Propagator *Propagator `json:"propagator,omitempty" yaml:"propagator,omitempty" mapstructure:"propagator,omitempty"` // Resource corresponds to the JSON schema field "resource". - Resource *Resource `mapstructure:"resource,omitempty"` + Resource *Resource `json:"resource,omitempty" yaml:"resource,omitempty" mapstructure:"resource,omitempty"` // TracerProvider corresponds to the JSON schema field "tracer_provider". - TracerProvider *TracerProvider `mapstructure:"tracer_provider,omitempty"` + TracerProvider *TracerProvider `json:"tracer_provider,omitempty" yaml:"tracer_provider,omitempty" mapstructure:"tracer_provider,omitempty"` AdditionalProperties interface{} } @@ -372,13 +372,13 @@ func (j *OpenTelemetryConfiguration) UnmarshalJSON(b []byte) error { type PeriodicMetricReader struct { // Exporter corresponds to the JSON schema field "exporter". - Exporter MetricExporter `mapstructure:"exporter"` + Exporter MetricExporter `json:"exporter" yaml:"exporter" mapstructure:"exporter"` // Interval corresponds to the JSON schema field "interval". - Interval *int `mapstructure:"interval,omitempty"` + Interval *int `json:"interval,omitempty" yaml:"interval,omitempty" mapstructure:"interval,omitempty"` // Timeout corresponds to the JSON schema field "timeout". - Timeout *int `mapstructure:"timeout,omitempty"` + Timeout *int `json:"timeout,omitempty" yaml:"timeout,omitempty" mapstructure:"timeout,omitempty"` } // UnmarshalJSON implements json.Unmarshaler. @@ -401,35 +401,35 @@ func (j *PeriodicMetricReader) UnmarshalJSON(b []byte) error { type Prometheus struct { // Host corresponds to the JSON schema field "host". - Host *string `mapstructure:"host,omitempty"` + Host *string `json:"host,omitempty" yaml:"host,omitempty" mapstructure:"host,omitempty"` // Port corresponds to the JSON schema field "port". - Port *int `mapstructure:"port,omitempty"` + Port *int `json:"port,omitempty" yaml:"port,omitempty" mapstructure:"port,omitempty"` // WithResourceConstantLabels corresponds to the JSON schema field // "with_resource_constant_labels". - WithResourceConstantLabels *IncludeExclude `mapstructure:"with_resource_constant_labels,omitempty"` + WithResourceConstantLabels *IncludeExclude `json:"with_resource_constant_labels,omitempty" yaml:"with_resource_constant_labels,omitempty" mapstructure:"with_resource_constant_labels,omitempty"` // WithoutScopeInfo corresponds to the JSON schema field "without_scope_info". - WithoutScopeInfo *bool `mapstructure:"without_scope_info,omitempty"` + WithoutScopeInfo *bool `json:"without_scope_info,omitempty" yaml:"without_scope_info,omitempty" mapstructure:"without_scope_info,omitempty"` // WithoutTypeSuffix corresponds to the JSON schema field "without_type_suffix". - WithoutTypeSuffix *bool `mapstructure:"without_type_suffix,omitempty"` + WithoutTypeSuffix *bool `json:"without_type_suffix,omitempty" yaml:"without_type_suffix,omitempty" mapstructure:"without_type_suffix,omitempty"` // WithoutUnits corresponds to the JSON schema field "without_units". - WithoutUnits *bool `mapstructure:"without_units,omitempty"` + WithoutUnits *bool `json:"without_units,omitempty" yaml:"without_units,omitempty" mapstructure:"without_units,omitempty"` } type Propagator struct { // Composite corresponds to the JSON schema field "composite". - Composite []string `mapstructure:"composite,omitempty"` + Composite []string `json:"composite,omitempty" yaml:"composite,omitempty" mapstructure:"composite,omitempty"` AdditionalProperties interface{} } type PullMetricReader struct { // Exporter corresponds to the JSON schema field "exporter". - Exporter MetricExporter `mapstructure:"exporter"` + Exporter MetricExporter `json:"exporter" yaml:"exporter" mapstructure:"exporter"` } // UnmarshalJSON implements json.Unmarshaler. @@ -452,30 +452,30 @@ func (j *PullMetricReader) UnmarshalJSON(b []byte) error { type Resource struct { // Attributes corresponds to the JSON schema field "attributes". - Attributes Attributes `mapstructure:"attributes,omitempty"` + Attributes Attributes `json:"attributes,omitempty" yaml:"attributes,omitempty" mapstructure:"attributes,omitempty"` // Detectors corresponds to the JSON schema field "detectors". - Detectors *Detectors `mapstructure:"detectors,omitempty"` + Detectors *Detectors `json:"detectors,omitempty" yaml:"detectors,omitempty" mapstructure:"detectors,omitempty"` // SchemaUrl corresponds to the JSON schema field "schema_url". - SchemaUrl *string `mapstructure:"schema_url,omitempty"` + SchemaUrl *string `json:"schema_url,omitempty" yaml:"schema_url,omitempty" mapstructure:"schema_url,omitempty"` } type Sampler struct { // AlwaysOff corresponds to the JSON schema field "always_off". - AlwaysOff SamplerAlwaysOff `mapstructure:"always_off,omitempty"` + AlwaysOff SamplerAlwaysOff `json:"always_off,omitempty" yaml:"always_off,omitempty" mapstructure:"always_off,omitempty"` // AlwaysOn corresponds to the JSON schema field "always_on". - AlwaysOn SamplerAlwaysOn `mapstructure:"always_on,omitempty"` + AlwaysOn SamplerAlwaysOn `json:"always_on,omitempty" yaml:"always_on,omitempty" mapstructure:"always_on,omitempty"` // JaegerRemote corresponds to the JSON schema field "jaeger_remote". - JaegerRemote *SamplerJaegerRemote `mapstructure:"jaeger_remote,omitempty"` + JaegerRemote *SamplerJaegerRemote `json:"jaeger_remote,omitempty" yaml:"jaeger_remote,omitempty" mapstructure:"jaeger_remote,omitempty"` // ParentBased corresponds to the JSON schema field "parent_based". - ParentBased *SamplerParentBased `mapstructure:"parent_based,omitempty"` + ParentBased *SamplerParentBased `json:"parent_based,omitempty" yaml:"parent_based,omitempty" mapstructure:"parent_based,omitempty"` // TraceIDRatioBased corresponds to the JSON schema field "trace_id_ratio_based". - TraceIDRatioBased *SamplerTraceIDRatioBased `mapstructure:"trace_id_ratio_based,omitempty"` + TraceIDRatioBased *SamplerTraceIDRatioBased `json:"trace_id_ratio_based,omitempty" yaml:"trace_id_ratio_based,omitempty" mapstructure:"trace_id_ratio_based,omitempty"` AdditionalProperties interface{} } @@ -486,43 +486,43 @@ type SamplerAlwaysOn map[string]interface{} type SamplerJaegerRemote struct { // Endpoint corresponds to the JSON schema field "endpoint". - Endpoint *string `mapstructure:"endpoint,omitempty"` + Endpoint *string `json:"endpoint,omitempty" yaml:"endpoint,omitempty" mapstructure:"endpoint,omitempty"` // InitialSampler corresponds to the JSON schema field "initial_sampler". - InitialSampler *Sampler `mapstructure:"initial_sampler,omitempty"` + InitialSampler *Sampler `json:"initial_sampler,omitempty" yaml:"initial_sampler,omitempty" mapstructure:"initial_sampler,omitempty"` // Interval corresponds to the JSON schema field "interval". - Interval *int `mapstructure:"interval,omitempty"` + Interval *int `json:"interval,omitempty" yaml:"interval,omitempty" mapstructure:"interval,omitempty"` } type SamplerParentBased struct { // LocalParentNotSampled corresponds to the JSON schema field // "local_parent_not_sampled". - LocalParentNotSampled *Sampler `mapstructure:"local_parent_not_sampled,omitempty"` + LocalParentNotSampled *Sampler `json:"local_parent_not_sampled,omitempty" yaml:"local_parent_not_sampled,omitempty" mapstructure:"local_parent_not_sampled,omitempty"` // LocalParentSampled corresponds to the JSON schema field "local_parent_sampled". - LocalParentSampled *Sampler `mapstructure:"local_parent_sampled,omitempty"` + LocalParentSampled *Sampler `json:"local_parent_sampled,omitempty" yaml:"local_parent_sampled,omitempty" mapstructure:"local_parent_sampled,omitempty"` // RemoteParentNotSampled corresponds to the JSON schema field // "remote_parent_not_sampled". - RemoteParentNotSampled *Sampler `mapstructure:"remote_parent_not_sampled,omitempty"` + RemoteParentNotSampled *Sampler `json:"remote_parent_not_sampled,omitempty" yaml:"remote_parent_not_sampled,omitempty" mapstructure:"remote_parent_not_sampled,omitempty"` // RemoteParentSampled corresponds to the JSON schema field // "remote_parent_sampled". - RemoteParentSampled *Sampler `mapstructure:"remote_parent_sampled,omitempty"` + RemoteParentSampled *Sampler `json:"remote_parent_sampled,omitempty" yaml:"remote_parent_sampled,omitempty" mapstructure:"remote_parent_sampled,omitempty"` // Root corresponds to the JSON schema field "root". - Root *Sampler `mapstructure:"root,omitempty"` + Root *Sampler `json:"root,omitempty" yaml:"root,omitempty" mapstructure:"root,omitempty"` } type SamplerTraceIDRatioBased struct { // Ratio corresponds to the JSON schema field "ratio". - Ratio *float64 `mapstructure:"ratio,omitempty"` + Ratio *float64 `json:"ratio,omitempty" yaml:"ratio,omitempty" mapstructure:"ratio,omitempty"` } type SimpleLogRecordProcessor struct { // Exporter corresponds to the JSON schema field "exporter". - Exporter LogRecordExporter `mapstructure:"exporter"` + Exporter LogRecordExporter `json:"exporter" yaml:"exporter" mapstructure:"exporter"` } // UnmarshalJSON implements json.Unmarshaler. @@ -545,7 +545,7 @@ func (j *SimpleLogRecordProcessor) UnmarshalJSON(b []byte) error { type SimpleSpanProcessor struct { // Exporter corresponds to the JSON schema field "exporter". - Exporter SpanExporter `mapstructure:"exporter"` + Exporter SpanExporter `json:"exporter" yaml:"exporter" mapstructure:"exporter"` } // UnmarshalJSON implements json.Unmarshaler. @@ -568,13 +568,13 @@ func (j *SimpleSpanProcessor) UnmarshalJSON(b []byte) error { type SpanExporter struct { // Console corresponds to the JSON schema field "console". - Console Console `mapstructure:"console,omitempty"` + Console Console `json:"console,omitempty" yaml:"console,omitempty" mapstructure:"console,omitempty"` // OTLP corresponds to the JSON schema field "otlp". - OTLP *OTLP `mapstructure:"otlp,omitempty"` + OTLP *OTLP `json:"otlp,omitempty" yaml:"otlp,omitempty" mapstructure:"otlp,omitempty"` // Zipkin corresponds to the JSON schema field "zipkin". - Zipkin *Zipkin `mapstructure:"zipkin,omitempty"` + Zipkin *Zipkin `json:"zipkin,omitempty" yaml:"zipkin,omitempty" mapstructure:"zipkin,omitempty"` AdditionalProperties interface{} } @@ -582,74 +582,74 @@ type SpanExporter struct { type SpanLimits struct { // AttributeCountLimit corresponds to the JSON schema field // "attribute_count_limit". - AttributeCountLimit *int `mapstructure:"attribute_count_limit,omitempty"` + AttributeCountLimit *int `json:"attribute_count_limit,omitempty" yaml:"attribute_count_limit,omitempty" mapstructure:"attribute_count_limit,omitempty"` // AttributeValueLengthLimit corresponds to the JSON schema field // "attribute_value_length_limit". - AttributeValueLengthLimit *int `mapstructure:"attribute_value_length_limit,omitempty"` + AttributeValueLengthLimit *int `json:"attribute_value_length_limit,omitempty" yaml:"attribute_value_length_limit,omitempty" mapstructure:"attribute_value_length_limit,omitempty"` // EventAttributeCountLimit corresponds to the JSON schema field // "event_attribute_count_limit". - EventAttributeCountLimit *int `mapstructure:"event_attribute_count_limit,omitempty"` + EventAttributeCountLimit *int `json:"event_attribute_count_limit,omitempty" yaml:"event_attribute_count_limit,omitempty" mapstructure:"event_attribute_count_limit,omitempty"` // EventCountLimit corresponds to the JSON schema field "event_count_limit". - EventCountLimit *int `mapstructure:"event_count_limit,omitempty"` + EventCountLimit *int `json:"event_count_limit,omitempty" yaml:"event_count_limit,omitempty" mapstructure:"event_count_limit,omitempty"` // LinkAttributeCountLimit corresponds to the JSON schema field // "link_attribute_count_limit". - LinkAttributeCountLimit *int `mapstructure:"link_attribute_count_limit,omitempty"` + LinkAttributeCountLimit *int `json:"link_attribute_count_limit,omitempty" yaml:"link_attribute_count_limit,omitempty" mapstructure:"link_attribute_count_limit,omitempty"` // LinkCountLimit corresponds to the JSON schema field "link_count_limit". - LinkCountLimit *int `mapstructure:"link_count_limit,omitempty"` + LinkCountLimit *int `json:"link_count_limit,omitempty" yaml:"link_count_limit,omitempty" mapstructure:"link_count_limit,omitempty"` } type SpanProcessor struct { // Batch corresponds to the JSON schema field "batch". - Batch *BatchSpanProcessor `mapstructure:"batch,omitempty"` + Batch *BatchSpanProcessor `json:"batch,omitempty" yaml:"batch,omitempty" mapstructure:"batch,omitempty"` // Simple corresponds to the JSON schema field "simple". - Simple *SimpleSpanProcessor `mapstructure:"simple,omitempty"` + Simple *SimpleSpanProcessor `json:"simple,omitempty" yaml:"simple,omitempty" mapstructure:"simple,omitempty"` AdditionalProperties interface{} } type TracerProvider struct { // Limits corresponds to the JSON schema field "limits". - Limits *SpanLimits `mapstructure:"limits,omitempty"` + Limits *SpanLimits `json:"limits,omitempty" yaml:"limits,omitempty" mapstructure:"limits,omitempty"` // Processors corresponds to the JSON schema field "processors". - Processors []SpanProcessor `mapstructure:"processors,omitempty"` + Processors []SpanProcessor `json:"processors,omitempty" yaml:"processors,omitempty" mapstructure:"processors,omitempty"` // Sampler corresponds to the JSON schema field "sampler". - Sampler *Sampler `mapstructure:"sampler,omitempty"` + Sampler *Sampler `json:"sampler,omitempty" yaml:"sampler,omitempty" mapstructure:"sampler,omitempty"` } type View struct { // Selector corresponds to the JSON schema field "selector". - Selector *ViewSelector `mapstructure:"selector,omitempty"` + Selector *ViewSelector `json:"selector,omitempty" yaml:"selector,omitempty" mapstructure:"selector,omitempty"` // Stream corresponds to the JSON schema field "stream". - Stream *ViewStream `mapstructure:"stream,omitempty"` + Stream *ViewStream `json:"stream,omitempty" yaml:"stream,omitempty" mapstructure:"stream,omitempty"` } type ViewSelector struct { // InstrumentName corresponds to the JSON schema field "instrument_name". - InstrumentName *string `mapstructure:"instrument_name,omitempty"` + InstrumentName *string `json:"instrument_name,omitempty" yaml:"instrument_name,omitempty" mapstructure:"instrument_name,omitempty"` // InstrumentType corresponds to the JSON schema field "instrument_type". - InstrumentType *ViewSelectorInstrumentType `mapstructure:"instrument_type,omitempty"` + InstrumentType *ViewSelectorInstrumentType `json:"instrument_type,omitempty" yaml:"instrument_type,omitempty" mapstructure:"instrument_type,omitempty"` // MeterName corresponds to the JSON schema field "meter_name". - MeterName *string `mapstructure:"meter_name,omitempty"` + MeterName *string `json:"meter_name,omitempty" yaml:"meter_name,omitempty" mapstructure:"meter_name,omitempty"` // MeterSchemaUrl corresponds to the JSON schema field "meter_schema_url". - MeterSchemaUrl *string `mapstructure:"meter_schema_url,omitempty"` + MeterSchemaUrl *string `json:"meter_schema_url,omitempty" yaml:"meter_schema_url,omitempty" mapstructure:"meter_schema_url,omitempty"` // MeterVersion corresponds to the JSON schema field "meter_version". - MeterVersion *string `mapstructure:"meter_version,omitempty"` + MeterVersion *string `json:"meter_version,omitempty" yaml:"meter_version,omitempty" mapstructure:"meter_version,omitempty"` // Unit corresponds to the JSON schema field "unit". - Unit *string `mapstructure:"unit,omitempty"` + Unit *string `json:"unit,omitempty" yaml:"unit,omitempty" mapstructure:"unit,omitempty"` } type ViewSelectorInstrumentType string @@ -692,49 +692,49 @@ func (j *ViewSelectorInstrumentType) UnmarshalJSON(b []byte) error { type ViewStream struct { // Aggregation corresponds to the JSON schema field "aggregation". - Aggregation *ViewStreamAggregation `mapstructure:"aggregation,omitempty"` + Aggregation *ViewStreamAggregation `json:"aggregation,omitempty" yaml:"aggregation,omitempty" mapstructure:"aggregation,omitempty"` // AttributeKeys corresponds to the JSON schema field "attribute_keys". - AttributeKeys []string `mapstructure:"attribute_keys,omitempty"` + AttributeKeys []string `json:"attribute_keys,omitempty" yaml:"attribute_keys,omitempty" mapstructure:"attribute_keys,omitempty"` // Description corresponds to the JSON schema field "description". - Description *string `mapstructure:"description,omitempty"` + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` // Name corresponds to the JSON schema field "name". - Name *string `mapstructure:"name,omitempty"` + Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` } type ViewStreamAggregation struct { // Base2ExponentialBucketHistogram corresponds to the JSON schema field // "base2_exponential_bucket_histogram". - Base2ExponentialBucketHistogram *ViewStreamAggregationBase2ExponentialBucketHistogram `mapstructure:"base2_exponential_bucket_histogram,omitempty"` + Base2ExponentialBucketHistogram *ViewStreamAggregationBase2ExponentialBucketHistogram `json:"base2_exponential_bucket_histogram,omitempty" yaml:"base2_exponential_bucket_histogram,omitempty" mapstructure:"base2_exponential_bucket_histogram,omitempty"` // Default corresponds to the JSON schema field "default". - Default ViewStreamAggregationDefault `mapstructure:"default,omitempty"` + Default ViewStreamAggregationDefault `json:"default,omitempty" yaml:"default,omitempty" mapstructure:"default,omitempty"` // Drop corresponds to the JSON schema field "drop". - Drop ViewStreamAggregationDrop `mapstructure:"drop,omitempty"` + Drop ViewStreamAggregationDrop `json:"drop,omitempty" yaml:"drop,omitempty" mapstructure:"drop,omitempty"` // ExplicitBucketHistogram corresponds to the JSON schema field // "explicit_bucket_histogram". - ExplicitBucketHistogram *ViewStreamAggregationExplicitBucketHistogram `mapstructure:"explicit_bucket_histogram,omitempty"` + ExplicitBucketHistogram *ViewStreamAggregationExplicitBucketHistogram `json:"explicit_bucket_histogram,omitempty" yaml:"explicit_bucket_histogram,omitempty" mapstructure:"explicit_bucket_histogram,omitempty"` // LastValue corresponds to the JSON schema field "last_value". - LastValue ViewStreamAggregationLastValue `mapstructure:"last_value,omitempty"` + LastValue ViewStreamAggregationLastValue `json:"last_value,omitempty" yaml:"last_value,omitempty" mapstructure:"last_value,omitempty"` // Sum corresponds to the JSON schema field "sum". - Sum ViewStreamAggregationSum `mapstructure:"sum,omitempty"` + Sum ViewStreamAggregationSum `json:"sum,omitempty" yaml:"sum,omitempty" mapstructure:"sum,omitempty"` } type ViewStreamAggregationBase2ExponentialBucketHistogram struct { // MaxScale corresponds to the JSON schema field "max_scale". - MaxScale *int `mapstructure:"max_scale,omitempty"` + MaxScale *int `json:"max_scale,omitempty" yaml:"max_scale,omitempty" mapstructure:"max_scale,omitempty"` // MaxSize corresponds to the JSON schema field "max_size". - MaxSize *int `mapstructure:"max_size,omitempty"` + MaxSize *int `json:"max_size,omitempty" yaml:"max_size,omitempty" mapstructure:"max_size,omitempty"` // RecordMinMax corresponds to the JSON schema field "record_min_max". - RecordMinMax *bool `mapstructure:"record_min_max,omitempty"` + RecordMinMax *bool `json:"record_min_max,omitempty" yaml:"record_min_max,omitempty" mapstructure:"record_min_max,omitempty"` } type ViewStreamAggregationDefault map[string]interface{} @@ -743,10 +743,10 @@ type ViewStreamAggregationDrop map[string]interface{} type ViewStreamAggregationExplicitBucketHistogram struct { // Boundaries corresponds to the JSON schema field "boundaries". - Boundaries []float64 `mapstructure:"boundaries,omitempty"` + Boundaries []float64 `json:"boundaries,omitempty" yaml:"boundaries,omitempty" mapstructure:"boundaries,omitempty"` // RecordMinMax corresponds to the JSON schema field "record_min_max". - RecordMinMax *bool `mapstructure:"record_min_max,omitempty"` + RecordMinMax *bool `json:"record_min_max,omitempty" yaml:"record_min_max,omitempty" mapstructure:"record_min_max,omitempty"` } type ViewStreamAggregationLastValue map[string]interface{} @@ -755,10 +755,10 @@ type ViewStreamAggregationSum map[string]interface{} type Zipkin struct { // Endpoint corresponds to the JSON schema field "endpoint". - Endpoint string `mapstructure:"endpoint"` + Endpoint string `json:"endpoint" yaml:"endpoint" mapstructure:"endpoint"` // Timeout corresponds to the JSON schema field "timeout". - Timeout *int `mapstructure:"timeout,omitempty"` + Timeout *int `json:"timeout,omitempty" yaml:"timeout,omitempty" mapstructure:"timeout,omitempty"` } // UnmarshalJSON implements json.Unmarshaler. diff --git a/config/go.mod b/config/go.mod index 006640c461c..394500d7e86 100644 --- a/config/go.mod +++ b/config/go.mod @@ -21,6 +21,7 @@ require ( go.opentelemetry.io/otel/sdk/log v0.6.0 go.opentelemetry.io/otel/sdk/metric v1.30.0 go.opentelemetry.io/otel/trace v1.30.0 + gopkg.in/yaml.v3 v3.0.1 ) require ( @@ -47,5 +48,4 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect google.golang.org/grpc v1.67.1 // indirect google.golang.org/protobuf v1.34.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/config/testdata/invalid_bool.json b/config/testdata/invalid_bool.json new file mode 100644 index 00000000000..979233b54fc --- /dev/null +++ b/config/testdata/invalid_bool.json @@ -0,0 +1 @@ +{"file_format": "yaml", "disabled": "notabool"} \ No newline at end of file diff --git a/config/testdata/invalid_bool.yaml b/config/testdata/invalid_bool.yaml new file mode 100644 index 00000000000..837b3e0c2cb --- /dev/null +++ b/config/testdata/invalid_bool.yaml @@ -0,0 +1,2 @@ +file_format: yaml +disabled: notabool \ No newline at end of file diff --git a/config/testdata/v0.2.json b/config/testdata/v0.2.json new file mode 100644 index 00000000000..d26ca8b5826 --- /dev/null +++ b/config/testdata/v0.2.json @@ -0,0 +1,243 @@ +{ + "file_format": "0.2", + "disabled": false, + "attribute_limits": { + "attribute_value_length_limit": 4096, + "attribute_count_limit": 128 + }, + "logger_provider": { + "processors": [ + { + "batch": { + "schedule_delay": 5000, + "export_timeout": 30000, + "max_queue_size": 2048, + "max_export_batch_size": 512, + "exporter": { + "otlp": { + "protocol": "http/protobuf", + "endpoint": "http://localhost:4318", + "certificate": "/app/cert.pem", + "client_key": "/app/cert.pem", + "client_certificate": "/app/cert.pem", + "headers": { + "api-key": "1234" + }, + "compression": "gzip", + "timeout": 10000, + "insecure": false + } + } + } + }, + { + "simple": { + "exporter": { + "console": {} + } + } + } + ], + "limits": { + "attribute_value_length_limit": 4096, + "attribute_count_limit": 128 + } + }, + "meter_provider": { + "readers": [ + { + "pull": { + "exporter": { + "prometheus": { + "host": "localhost", + "port": 9464, + "without_units": false, + "without_type_suffix": false, + "without_scope_info": false, + "with_resource_constant_labels": { + "included": [ + "service*" + ], + "excluded": [ + "service.attr1" + ] + } + } + } + } + }, + { + "periodic": { + "interval": 5000, + "timeout": 30000, + "exporter": { + "otlp": { + "protocol": "http/protobuf", + "endpoint": "http://localhost:4318", + "certificate": "/app/cert.pem", + "client_key": "/app/cert.pem", + "client_certificate": "/app/cert.pem", + "headers": { + "api-key": "1234" + }, + "compression": "gzip", + "timeout": 10000, + "insecure": false, + "temporality_preference": "delta", + "default_histogram_aggregation": "base2_exponential_bucket_histogram" + } + } + } + }, + { + "periodic": { + "exporter": { + "console": {} + } + } + } + ], + "views": [ + { + "selector": { + "instrument_name": "my-instrument", + "instrument_type": "histogram", + "unit": "ms", + "meter_name": "my-meter", + "meter_version": "1.0.0", + "meter_schema_url": "https://opentelemetry.io/schemas/1.16.0" + }, + "stream": { + "name": "new_instrument_name", + "description": "new_description", + "aggregation": { + "explicit_bucket_histogram": { + "boundaries": [ + 0, + 5, + 10, + 25, + 50, + 75, + 100, + 250, + 500, + 750, + 1000, + 2500, + 5000, + 7500, + 10000 + ], + "record_min_max": true + } + }, + "attribute_keys": [ + "key1", + "key2" + ] + } + } + ] + }, + "propagator": { + "composite": [ + "tracecontext", + "baggage", + "b3", + "b3multi", + "jaeger", + "xray", + "ottrace" + ] + }, + "tracer_provider": { + "processors": [ + { + "batch": { + "schedule_delay": 5000, + "export_timeout": 30000, + "max_queue_size": 2048, + "max_export_batch_size": 512, + "exporter": { + "otlp": { + "protocol": "http/protobuf", + "endpoint": "http://localhost:4318", + "certificate": "/app/cert.pem", + "client_key": "/app/cert.pem", + "client_certificate": "/app/cert.pem", + "headers": { + "api-key": "1234" + }, + "compression": "gzip", + "timeout": 10000, + "insecure": false + } + } + } + }, + { + "batch": { + "exporter": { + "zipkin": { + "endpoint": "http://localhost:9411/api/v2/spans", + "timeout": 10000 + } + } + } + }, + { + "simple": { + "exporter": { + "console": {} + } + } + } + ], + "limits": { + "attribute_value_length_limit": 4096, + "attribute_count_limit": 128, + "event_count_limit": 128, + "link_count_limit": 128, + "event_attribute_count_limit": 128, + "link_attribute_count_limit": 128 + }, + "sampler": { + "parent_based": { + "root": { + "trace_id_ratio_based": { + "ratio": 0.0001 + } + }, + "remote_parent_sampled": { + "always_on": {} + }, + "remote_parent_not_sampled": { + "always_off": {} + }, + "local_parent_sampled": { + "always_on": {} + }, + "local_parent_not_sampled": { + "always_off": {} + } + } + } + }, + "resource": { + "attributes": { + "service.name": "unknown_service" + }, + "detectors": { + "attributes": { + "included": [ + "process.*" + ], + "excluded": [ + "process.command_args" + ] + } + }, + "schema_url": "https://opentelemetry.io/schemas/1.16.0" + } +} \ No newline at end of file diff --git a/config/testdata/v0.2.yaml b/config/testdata/v0.2.yaml new file mode 100644 index 00000000000..0ef5c87f825 --- /dev/null +++ b/config/testdata/v0.2.yaml @@ -0,0 +1,428 @@ +# kitchen-sink.yaml demonstrates all configurable surface area, including explanatory comments. +# +# It DOES NOT represent expected real world configuration, as it makes strange configuration +# choices in an effort to exercise the full surface area. +# +# Configuration values are set to their defaults when default values are defined. + +# The file format version +file_format: "0.2" + +# Configure if the SDK is disabled or not. This is not required to be provided +# to ensure the SDK isn't disabled, the default value when this is not provided +# is for the SDK to be enabled. +# +# Environment variable: OTEL_SDK_DISABLED +disabled: false + +# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits. +attribute_limits: + # Configure max attribute value size. + # + # Environment variable: OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT + attribute_value_length_limit: 4096 + # Configure max attribute count. + # + # Environment variable: OTEL_ATTRIBUTE_COUNT_LIMIT + attribute_count_limit: 128 + +# Configure logger provider. +logger_provider: + # Configure log record processors. + processors: + # Configure a batch log record processor. + - batch: + # Configure delay interval (in milliseconds) between two consecutive exports. + # + # Environment variable: OTEL_BLRP_SCHEDULE_DELAY + schedule_delay: 5000 + # Configure maximum allowed time (in milliseconds) to export data. + # + # Environment variable: OTEL_BLRP_EXPORT_TIMEOUT + export_timeout: 30000 + # Configure maximum queue size. + # + # Environment variable: OTEL_BLRP_MAX_QUEUE_SIZE + max_queue_size: 2048 + # Configure maximum batch size. + # + # Environment variable: OTEL_BLRP_MAX_EXPORT_BATCH_SIZE + max_export_batch_size: 512 + # Configure exporter. + # + # Environment variable: OTEL_LOGS_EXPORTER + exporter: + # Configure exporter to be OTLP. + otlp: + # Configure protocol. + # + # Environment variable: OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_LOGS_PROTOCOL + protocol: http/protobuf + # Configure endpoint. + # + # Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT + endpoint: http://localhost:4318 + # Configure certificate. + # + # Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE + certificate: /app/cert.pem + # Configure mTLS private client key. + # + # Environment variable: OTEL_EXPORTER_OTLP_CLIENT_KEY, OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY + client_key: /app/cert.pem + # Configure mTLS client certificate. + # + # Environment variable: OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE, OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE + client_certificate: /app/cert.pem + # Configure headers. + # + # Environment variable: OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_LOGS_HEADERS + headers: + api-key: "1234" + # Configure compression. + # + # Environment variable: OTEL_EXPORTER_OTLP_COMPRESSION, OTEL_EXPORTER_OTLP_LOGS_COMPRESSION + compression: gzip + # Configure max time (in milliseconds) to wait for each export. + # + # Environment variable: OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_LOGS_TIMEOUT + timeout: 10000 + # Configure client transport security for the exporter's connection. + # + # Environment variable: OTEL_EXPORTER_OTLP_INSECURE, OTEL_EXPORTER_OTLP_LOGS_INSECURE + insecure: false + # Configure a simple span processor. + - simple: + # Configure exporter. + exporter: + # Configure exporter to be console. + console: {} + # Configure log record limits. See also attribute_limits. + limits: + # Configure max log record attribute value size. Overrides attribute_limits.attribute_value_length_limit. + # + # Environment variable: OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT + attribute_value_length_limit: 4096 + # Configure max log record attribute count. Overrides attribute_limits.attribute_count_limit. + # + # Environment variable: OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT + attribute_count_limit: 128 + +# Configure meter provider. +meter_provider: + # Configure metric readers. + readers: + # Configure a pull-based metric reader. + - pull: + # Configure exporter. + # + # Environment variable: OTEL_METRICS_EXPORTER + exporter: + # Configure exporter to be prometheus. + prometheus: + # Configure host. + # + # Environment variable: OTEL_EXPORTER_PROMETHEUS_HOST + host: localhost + # Configure port. + # + # Environment variable: OTEL_EXPORTER_PROMETHEUS_PORT + port: 9464 + # Configure Prometheus Exporter to produce metrics without a unit suffix or UNIT metadata. + without_units: false + # Configure Prometheus Exporter to produce metrics without a type suffix. + without_type_suffix: false + # Configure Prometheus Exporter to produce metrics without a scope info metric. + without_scope_info: false + # Configure Prometheus Exporter to add resource attributes as metrics attributes. + with_resource_constant_labels: + # Configure resource attributes to be included, in this example attributes starting with service. + included: + - "service*" + # Configure resource attributes to be excluded, in this example attribute service.attr1. + excluded: + - "service.attr1" + # Configure a periodic metric reader. + - periodic: + # Configure delay interval (in milliseconds) between start of two consecutive exports. + # + # Environment variable: OTEL_METRIC_EXPORT_INTERVAL + interval: 5000 + # Configure maximum allowed time (in milliseconds) to export data. + # + # Environment variable: OTEL_METRIC_EXPORT_TIMEOUT + timeout: 30000 + # Configure exporter. + # + # Environment variable: OTEL_METRICS_EXPORTER + exporter: + # Configure exporter to be OTLP. + otlp: + # Configure protocol. + # + # Environment variable: OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_METRICS_PROTOCOL + protocol: http/protobuf + # Configure endpoint. + # + # Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT + endpoint: http://localhost:4318 + # Configure certificate. + # + # Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE + certificate: /app/cert.pem + # Configure mTLS private client key. + # + # Environment variable: OTEL_EXPORTER_OTLP_CLIENT_KEY, OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY + client_key: /app/cert.pem + # Configure mTLS client certificate. + # + # Environment variable: OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE, OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE + client_certificate: /app/cert.pem + # Configure headers. + # + # Environment variable: OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_METRICS_HEADERS + headers: + api-key: !!str 1234 + # Configure compression. + # + # Environment variable: OTEL_EXPORTER_OTLP_COMPRESSION, OTEL_EXPORTER_OTLP_METRICS_COMPRESSION + compression: gzip + # Configure max time (in milliseconds) to wait for each export. + # + # Environment variable: OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_METRICS_TIMEOUT + timeout: 10000 + # Configure client transport security for the exporter's connection. + # + # Environment variable: OTEL_EXPORTER_OTLP_INSECURE, OTEL_EXPORTER_OTLP_METRICS_INSECURE + insecure: false + # Configure temporality preference. + # + # Environment variable: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + temporality_preference: delta + # Configure default histogram aggregation. + # + # Environment variable: OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION + default_histogram_aggregation: base2_exponential_bucket_histogram + # Configure a periodic metric reader. + - periodic: + # Configure exporter. + exporter: + # Configure exporter to be console. + console: {} + # Configure views. Each view has a selector which determines the instrument(s) it applies to, and a configuration for the resulting stream(s). + views: + # Configure a view. + - selector: + # Configure instrument name selection criteria. + instrument_name: my-instrument + # Configure instrument type selection criteria. + instrument_type: histogram + # Configure the instrument unit selection criteria. + unit: ms + # Configure meter name selection criteria. + meter_name: my-meter + # Configure meter version selection criteria. + meter_version: 1.0.0 + # Configure meter schema url selection criteria. + meter_schema_url: https://opentelemetry.io/schemas/1.16.0 + # Configure stream. + stream: + # Configure metric name of the resulting stream(s). + name: new_instrument_name + # Configure metric description of the resulting stream(s). + description: new_description + # Configure aggregation of the resulting stream(s). Known values include: default, drop, explicit_bucket_histogram, base2_exponential_bucket_histogram, last_value, sum. + aggregation: + # Configure aggregation to be explicit_bucket_histogram. + explicit_bucket_histogram: + # Configure bucket boundaries. + boundaries: [ 0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 750.0, 1000.0, 2500.0, 5000.0, 7500.0, 10000.0 ] + # Configure record min and max. + record_min_max: true + # Configure attribute keys retained in the resulting stream(s). + attribute_keys: + - key1 + - key2 + +# Configure text map context propagators. +# +# Environment variable: OTEL_PROPAGATORS +propagator: + composite: [tracecontext, baggage, b3, b3multi, jaeger, xray, ottrace] + +# Configure tracer provider. +tracer_provider: + # Configure span processors. + processors: + # Configure a batch span processor. + - batch: + # Configure delay interval (in milliseconds) between two consecutive exports. + # + # Environment variable: OTEL_BSP_SCHEDULE_DELAY + schedule_delay: 5000 + # Configure maximum allowed time (in milliseconds) to export data. + # + # Environment variable: OTEL_BSP_EXPORT_TIMEOUT + export_timeout: 30000 + # Configure maximum queue size. + # + # Environment variable: OTEL_BSP_MAX_QUEUE_SIZE + max_queue_size: 2048 + # Configure maximum batch size. + # + # Environment variable: OTEL_BSP_MAX_EXPORT_BATCH_SIZE + max_export_batch_size: 512 + # Configure exporter. + # + # Environment variable: OTEL_TRACES_EXPORTER + exporter: + # Configure exporter to be OTLP. + otlp: + # Configure protocol. + # + # Environment variable: OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_TRACES_PROTOCOL + protocol: http/protobuf + # Configure endpoint. + # + # Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + endpoint: http://localhost:4318 + # Configure certificate. + # + # Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE + certificate: /app/cert.pem + # Configure mTLS private client key. + # + # Environment variable: OTEL_EXPORTER_OTLP_CLIENT_KEY, OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY + client_key: /app/cert.pem + # Configure mTLS client certificate. + # + # Environment variable: OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE, OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE + client_certificate: /app/cert.pem + # Configure headers. + # + # Environment variable: OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_TRACES_HEADERS + headers: + api-key: !!str 1234 + # Configure compression. + # + # Environment variable: OTEL_EXPORTER_OTLP_COMPRESSION, OTEL_EXPORTER_OTLP_TRACES_COMPRESSION + compression: gzip + # Configure max time (in milliseconds) to wait for each export. + # + # Environment variable: OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_TRACES_TIMEOUT + timeout: 10000 + # Configure client transport security for the exporter's connection. + # + # Environment variable: OTEL_EXPORTER_OTLP_INSECURE, OTEL_EXPORTER_OTLP_TRACES_INSECURE + insecure: false + # Configure a batch span processor. + - batch: + # Configure exporter. + # + # Environment variable: OTEL_TRACES_EXPORTER + exporter: + # Configure exporter to be zipkin. + zipkin: + # Configure endpoint. + # + # Environment variable: OTEL_EXPORTER_ZIPKIN_ENDPOINT + endpoint: http://localhost:9411/api/v2/spans + # Configure max time (in milliseconds) to wait for each export. + # + # Environment variable: OTEL_EXPORTER_ZIPKIN_TIMEOUT + timeout: 10000 + # Configure a simple span processor. + - simple: + # Configure exporter. + exporter: + # Configure exporter to be console. + console: {} + # Configure span limits. See also attribute_limits. + limits: + # Configure max span attribute value size. Overrides attribute_limits.attribute_value_length_limit. + # + # Environment variable: OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT + attribute_value_length_limit: 4096 + # Configure max span attribute count. Overrides attribute_limits.attribute_count_limit. + # + # Environment variable: OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT + attribute_count_limit: 128 + # Configure max span event count. + # + # Environment variable: OTEL_SPAN_EVENT_COUNT_LIMIT + event_count_limit: 128 + # Configure max span link count. + # + # Environment variable: OTEL_SPAN_LINK_COUNT_LIMIT + link_count_limit: 128 + # Configure max attributes per span event. + # + # Environment variable: OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT + event_attribute_count_limit: 128 + # Configure max attributes per span link. + # + # Environment variable: OTEL_LINK_ATTRIBUTE_COUNT_LIMIT + link_attribute_count_limit: 128 + # Configure the sampler. + sampler: + # Configure sampler to be parent_based. Known values include: always_off, always_on, jaeger_remote, parent_based, trace_id_ratio_based. + # + # Environment variable: OTEL_TRACES_SAMPLER=parentbased_* + parent_based: + # Configure root sampler. + # + # Environment variable: OTEL_TRACES_SAMPLER=parentbased_traceidratio + root: + # Configure sampler to be trace_id_ratio_based. + trace_id_ratio_based: + # Configure trace_id_ratio. + # + # Environment variable: OTEL_TRACES_SAMPLER_ARG=traceidratio=0.0001 + ratio: 0.0001 + # Configure remote_parent_sampled sampler. + remote_parent_sampled: + # Configure sampler to be always_on. + always_on: {} + # Configure remote_parent_not_sampled sampler. + remote_parent_not_sampled: + # Configure sampler to be always_off. + always_off: {} + # Configure local_parent_sampled sampler. + local_parent_sampled: + # Configure sampler to be always_on. + always_on: {} + # Configure local_parent_not_sampled sampler. + local_parent_not_sampled: + # Configure sampler to be always_off. + always_off: {} + +# Configure resource for all signals. +resource: + # Configure resource attributes. + # + # Environment variable: OTEL_RESOURCE_ATTRIBUTES + attributes: + # Configure `service.name` resource attribute + # + # Environment variable: OTEL_SERVICE_NAME + service.name: !!str "unknown_service" + # Configure resource detectors. + detectors: + # Configure attributes provided by resource detectors. + attributes: + # Configure list of attribute key patterns to include from resource detectors. If not set, all attributes are included. + # + # Attribute keys from resource detectors are evaluated to match as follows: + # * If the value of the attribute key exactly matches. + # * If the value of the attribute key matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. + included: + - process.* + # Configure list of attribute key patterns to exclude from resource detectors. Applies after .resource.detectors.attributes.included (i.e. excluded has higher priority than included). + # + # Attribute keys from resource detectors are evaluated to match as follows: + # * If the value of the attribute key exactly matches. + # * If the value of the attribute key matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. + excluded: + - process.command_args + # Configure the resource schema URL. + schema_url: https://opentelemetry.io/schemas/1.16.0 diff --git a/config/testdata/valid_empty.json b/config/testdata/valid_empty.json new file mode 100644 index 00000000000..45e9de273b0 --- /dev/null +++ b/config/testdata/valid_empty.json @@ -0,0 +1 @@ +{"file_format": "0.1", "disabled": false} \ No newline at end of file diff --git a/config/testdata/valid_empty.yaml b/config/testdata/valid_empty.yaml new file mode 100644 index 00000000000..dbcebaa0ca3 --- /dev/null +++ b/config/testdata/valid_empty.yaml @@ -0,0 +1,2 @@ +file_format: 0.1 +disabled: false \ No newline at end of file