Skip to content

Commit

Permalink
feat(OTRM): Add validation for otel configuration in the opamp agent (#…
Browse files Browse the repository at this point in the history
…1469)

* feat(OTRM): Add config validation for otel config in the opamp agent

* Added tests and dependencies

* Changes that account for the otel core upgrade to 0.95.0

* Adding support to validate the host and Apache receiver
  • Loading branch information
rnishtala-sumo authored Mar 5, 2024
1 parent f87e50d commit 683a389
Show file tree
Hide file tree
Showing 10 changed files with 1,667 additions and 70 deletions.
1 change: 1 addition & 0 deletions .changelog/1469.added.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat(otrm): Add validation for otel configuration in the opamp agent
69 changes: 69 additions & 0 deletions pkg/extension/opampextension/components.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package opampextension

import (
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/otlpexporter"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/extension/ballastextension"

"go.opentelemetry.io/collector/otelcol"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/batchprocessor"
"go.opentelemetry.io/collector/processor/memorylimiterprocessor"
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/otlpreceiver"
"go.uber.org/multierr"

"github.com/SumoLogic/sumologic-otel-collector/pkg/exporter/sumologicexporter"
"github.com/SumoLogic/sumologic-otel-collector/pkg/extension/sumologicextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachereceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver"
)

// Components returns the set of components for tests
func Components() (
otelcol.Factories,
error,
) {
var errs error

extensions, err := extension.MakeFactoryMap(
ballastextension.NewFactory(),
sumologicextension.NewFactory(),
)
errs = multierr.Append(errs, err)

receivers, err := receiver.MakeFactoryMap(
apachereceiver.NewFactory(),
filelogreceiver.NewFactory(),
hostmetricsreceiver.NewFactory(),
otlpreceiver.NewFactory(),
)
errs = multierr.Append(errs, err)

exporters, err := exporter.MakeFactoryMap(
otlpexporter.NewFactory(),
sumologicexporter.NewFactory(),
)
errs = multierr.Append(errs, err)

processors, err := processor.MakeFactoryMap(
batchprocessor.NewFactory(),
memorylimiterprocessor.NewFactory(),
resourcedetectionprocessor.NewFactory(),
resourceprocessor.NewFactory(),
)
errs = multierr.Append(errs, err)

factories := otelcol.Factories{
Extensions: extensions,
Receivers: receivers,
Processors: processors,
Exporters: exporters,
}

return factories, errs
}
174 changes: 149 additions & 25 deletions pkg/extension/opampextension/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,86 +5,210 @@ go 1.21
toolchain go1.21.4

require (
github.com/SumoLogic/sumologic-otel-collector/pkg/exporter/sumologicexporter v0.93.0-sumo-0
github.com/SumoLogic/sumologic-otel-collector/pkg/extension/sumologicextension v0.91.0-sumo-0
github.com/google/uuid v1.4.0
github.com/google/uuid v1.6.0
github.com/knadh/koanf/parsers/yaml v0.1.0
github.com/knadh/koanf/providers/rawbytes v0.1.0
github.com/knadh/koanf/v2 v2.1.0
github.com/oklog/ulid/v2 v2.1.0
github.com/open-telemetry/opamp-go v0.10.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.95.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.95.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/apachereceiver v0.95.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.95.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.95.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/component v0.95.0
go.opentelemetry.io/collector/config/configauth v0.95.0
go.opentelemetry.io/collector/config/confighttp v0.95.0
go.opentelemetry.io/collector/confmap v0.95.0
go.opentelemetry.io/collector/confmap v0.96.0
go.opentelemetry.io/collector/exporter v0.95.0
go.opentelemetry.io/collector/exporter/otlpexporter v0.95.0
go.opentelemetry.io/collector/extension v0.95.0
go.opentelemetry.io/collector/pdata v1.2.0
go.opentelemetry.io/collector/extension/ballastextension v0.95.0
go.opentelemetry.io/collector/otelcol v0.95.0
go.opentelemetry.io/collector/pdata v1.3.0
go.opentelemetry.io/collector/processor v0.95.0
go.opentelemetry.io/collector/processor/batchprocessor v0.95.0
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.95.0
go.opentelemetry.io/collector/receiver v0.95.0
go.opentelemetry.io/collector/receiver/otlpreceiver v0.95.0
go.opentelemetry.io/collector/semconv v0.95.0
go.uber.org/zap v1.26.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
)

require (
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.4-0.20230617002413-005d2dfb6b68 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.21.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Showmax/go-fqdn v1.0.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/aws/aws-sdk-go v1.50.17 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.9+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/expr-lang/expr v1.16.1 // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/haimrubinstein/go-syslog/v3 v3.0.0 // indirect
github.com/hashicorp/consul/api v1.27.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/klauspost/compress v1.17.6 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
github.com/leodido/ragel-machinery v0.0.0-20181214104525-299bdde78165 // indirect
github.com/leoluk/perflib_exporter v0.2.1 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mostynb/go-grpc-compression v1.2.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.95.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.95.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.95.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.95.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig v0.95.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/metadataproviders v0.95.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza v0.95.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/openshift/api v3.9.0+incompatible // indirect
github.com/openshift/client-go v0.0.0-20210521082421-73d9475a9142 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.46.0 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/shirou/gopsutil/v3 v3.24.1 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/valyala/fastjson v1.6.4 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.95.0 // indirect
go.opentelemetry.io/collector/config/configcompression v0.95.0 // indirect
go.opentelemetry.io/collector/config/configopaque v1.2.0 // indirect
go.opentelemetry.io/collector/config/configgrpc v0.95.0 // indirect
go.opentelemetry.io/collector/config/confignet v0.95.0 // indirect
go.opentelemetry.io/collector/config/configopaque v1.3.0 // indirect
go.opentelemetry.io/collector/config/configretry v0.96.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.95.0 // indirect
go.opentelemetry.io/collector/config/configtls v0.95.0 // indirect
go.opentelemetry.io/collector/config/internal v0.95.0 // indirect
go.opentelemetry.io/collector/confmap/converter/expandconverter v0.95.0 // indirect
go.opentelemetry.io/collector/confmap/provider/envprovider v0.95.0 // indirect
go.opentelemetry.io/collector/confmap/provider/fileprovider v0.95.0 // indirect
go.opentelemetry.io/collector/confmap/provider/httpprovider v0.95.0 // indirect
go.opentelemetry.io/collector/confmap/provider/httpsprovider v0.95.0 // indirect
go.opentelemetry.io/collector/confmap/provider/yamlprovider v0.95.0 // indirect
go.opentelemetry.io/collector/connector v0.95.0 // indirect
go.opentelemetry.io/collector/consumer v0.95.0 // indirect
go.opentelemetry.io/collector/extension/auth v0.95.0 // indirect
go.opentelemetry.io/collector/featuregate v1.2.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect
go.opentelemetry.io/otel v1.23.1 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.45.2 // indirect
go.opentelemetry.io/otel/metric v1.23.1 // indirect
go.opentelemetry.io/otel/sdk v1.23.1 // indirect
go.opentelemetry.io/otel/sdk/metric v1.23.1 // indirect
go.opentelemetry.io/otel/trace v1.23.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.opentelemetry.io/collector/featuregate v1.3.0 // indirect
go.opentelemetry.io/collector/service v0.95.0 // indirect
go.opentelemetry.io/contrib/config v0.4.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.24.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/bridge/opencensus v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.46.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/grpc v1.61.0 // indirect
golang.org/x/time v0.4.0 // indirect
golang.org/x/tools v0.16.1 // indirect
gonum.org/v1/gonum v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.29.1 // indirect
k8s.io/apimachinery v0.29.1 // indirect
k8s.io/client-go v0.29.1 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/SumoLogic/sumologic-otel-collector/pkg/extension/sumologicextension => ./../../extension/sumologicextension

replace github.com/SumoLogic/sumologic-otel-collector/pkg/exporter/sumologicexporter => ./../../exporter/sumologicexporter
Loading

0 comments on commit 683a389

Please sign in to comment.