-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This module parses configuration as defined per the opentelemetry-configuration schema. Signed-off-by: Alex Boten <aboten@lightstep.com>
- Loading branch information
Alex Boten
committed
Sep 27, 2023
1 parent
e901cf0
commit fc13fc3
Showing
12 changed files
with
1,130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package config // import "go.opentelemetry.io/contrib/config" | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// Validate checks for a valid batch processor for the SpanProcessor. | ||
func (sp *SpanProcessor) Validate() error { | ||
if sp.Batch != nil { | ||
return sp.Batch.Exporter.Validate() | ||
} | ||
return fmt.Errorf("unsupported span processor type") | ||
} | ||
|
||
// Validate checks for valid exporters to be configured for the SpanExporter. | ||
func (se *SpanExporter) Validate() error { | ||
if se.Console == nil && se.Otlp == nil { | ||
return fmt.Errorf("invalid exporter configuration") | ||
} | ||
return nil | ||
} | ||
|
||
// Validate checks for either a valid pull or periodic exporter for the MetricReader. | ||
func (mr *MetricReader) Validate() error { | ||
if mr.Pull != nil { | ||
return mr.Pull.Validate() | ||
} | ||
if mr.Periodic != nil { | ||
return mr.Periodic.Validate() | ||
} | ||
|
||
return fmt.Errorf("unsupported metric reader type") | ||
} | ||
|
||
// Validate checks for valid exporters to be configured for the PullMetricReader. | ||
func (pmr *PullMetricReader) Validate() error { | ||
if pmr.Exporter.Prometheus == nil { | ||
return fmt.Errorf("invalid exporter configuration") | ||
} | ||
return nil | ||
} | ||
|
||
// Validate checks for valid exporters to be configured for the PeriodicMetricReader. | ||
func (pmr *PeriodicMetricReader) Validate() error { | ||
if pmr.Exporter.Otlp == nil && pmr.Exporter.Console == nil { | ||
return fmt.Errorf("invalid exporter configuration") | ||
} | ||
return nil | ||
} | ||
|
||
// Validate checks for a valid Selector or Stream to be configured for the View. | ||
func (v *View) Validate() error { | ||
if v.Selector == nil || v.Stream == nil { | ||
return fmt.Errorf("invalid view configuration") | ||
} | ||
return nil | ||
} | ||
|
||
func (s *ViewSelector) instrumentNameStr() string { | ||
if s.InstrumentName == nil { | ||
return "" | ||
} | ||
return *s.InstrumentName | ||
} | ||
|
||
func (s *ViewSelector) instrumentTypeStr() string { | ||
if s.InstrumentType == nil { | ||
return "" | ||
} | ||
return string(*s.InstrumentType) | ||
} | ||
|
||
func (s *ViewSelector) meterNameStr() string { | ||
if s.MeterName == nil { | ||
return "" | ||
} | ||
return *s.MeterName | ||
} | ||
|
||
func (s *ViewSelector) meterVersionStr() string { | ||
if s.MeterVersion == nil { | ||
return "" | ||
} | ||
return *s.MeterVersion | ||
} | ||
|
||
func (s *ViewSelector) meterSchemaURLStr() string { | ||
if s.MeterSchemaUrl == nil { | ||
return "" | ||
} | ||
return *s.MeterSchemaUrl | ||
} | ||
|
||
func (s *ViewSelector) unitStr() string { | ||
if s.Unit == nil { | ||
return "" | ||
} | ||
return *s.Unit | ||
} | ||
|
||
func (s *ViewStream) nameStr() string { | ||
if s.Name == nil { | ||
return "" | ||
} | ||
return *s.Name | ||
} | ||
|
||
func (s *ViewStream) descriptionStr() string { | ||
if s.Description == nil { | ||
return "" | ||
} | ||
return *s.Description | ||
} | ||
|
||
func (e *ViewStreamAggregationExplicitBucketHistogram) recordMinMaxBool() bool { | ||
if e.RecordMinMax == nil { | ||
return false | ||
} | ||
return *e.RecordMinMax | ||
} |
Oops, something went wrong.