diff --git a/.chloggen/feature_solarwindsapmsettingsetension-impl-2.yaml b/.chloggen/feature_solarwindsapmsettingsetension-impl-2.yaml new file mode 100644 index 000000000000..f1fd9de27134 --- /dev/null +++ b/.chloggen/feature_solarwindsapmsettingsetension-impl-2.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: solarwindsapmsettingsextension + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Added logic for refresh function + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [27668] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/extension/solarwindsapmsettingsextension/README.md b/extension/solarwindsapmsettingsextension/README.md index 0af3f00168b1..07630bf145ed 100644 --- a/extension/solarwindsapmsettingsextension/README.md +++ b/extension/solarwindsapmsettingsextension/README.md @@ -12,7 +12,7 @@ ## Overview -The Solarwinds APM Settings extension gets Solarwinds APM specific settings from Solarwinds APM collector and `/tmp/solarwinds-apm-settings.json` & `/tmp/solarwinds-apm-settings-raw` periodically. +The Solarwinds APM Settings extension gets Solarwinds APM specific settings from Solarwinds APM collector and `/tmp/solarwinds-apm-settings.json` periodically. ## Configuration diff --git a/extension/solarwindsapmsettingsextension/config.go b/extension/solarwindsapmsettingsextension/config.go index 70011b4e65d8..81b0a01c6dbf 100644 --- a/extension/solarwindsapmsettingsextension/config.go +++ b/extension/solarwindsapmsettingsextension/config.go @@ -10,12 +10,13 @@ import ( "time" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configgrpc" ) type Config struct { - Endpoint string `mapstructure:"endpoint"` - Key string `mapstructure:"key"` - Interval time.Duration `mapstructure:"interval"` + ClientConfig configgrpc.ClientConfig `mapstructure:",squash"` + Key string `mapstructure:"key"` + Interval time.Duration `mapstructure:"interval"` } const ( @@ -27,17 +28,19 @@ const ( func createDefaultConfig() component.Config { return &Config{ - Endpoint: DefaultEndpoint, + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, Interval: DefaultInterval, } } func (cfg *Config) Validate() error { // Endpoint - matched, _ := regexp.MatchString(`apm.collector.[a-z]{2,3}-[0-9]{2}.[a-z\-]*.solarwinds.com:443`, cfg.Endpoint) + matched, _ := regexp.MatchString(`apm.collector.[a-z]{2,3}-[0-9]{2}.[a-z\-]*.solarwinds.com:443`, cfg.ClientConfig.Endpoint) if !matched { // Replaced by the default - cfg.Endpoint = DefaultEndpoint + cfg.ClientConfig.Endpoint = DefaultEndpoint } // Key keyArr := strings.Split(cfg.Key, ":") diff --git a/extension/solarwindsapmsettingsextension/config_test.go b/extension/solarwindsapmsettingsextension/config_test.go index a6814ec5b83e..d1ca784893f1 100644 --- a/extension/solarwindsapmsettingsextension/config_test.go +++ b/extension/solarwindsapmsettingsextension/config_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/confmap/confmaptest" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/solarwindsapmsettingsextension/internal/metadata" @@ -31,7 +32,9 @@ func TestLoadConfig(t *testing.T) { { id: component.NewIDWithName(metadata.Type, "1"), expected: &Config{ - Endpoint: "apm.collector.apj-01.cloud.solarwinds.com:443", + ClientConfig: configgrpc.ClientConfig{ + Endpoint: "apm.collector.na-01.cloud.solarwinds.com:443", + }, Key: "something:name", Interval: time.Duration(10) * time.Second, }, @@ -39,17 +42,221 @@ func TestLoadConfig(t *testing.T) { { id: component.NewIDWithName(metadata.Type, "2"), expected: &Config{ - Endpoint: "apm.collector.na-01.cloud.solarwinds.com:443", - Key: "something", - Interval: time.Duration(5) * time.Second, + ClientConfig: configgrpc.ClientConfig{ + Endpoint: "apm.collector.na-02.cloud.solarwinds.com:443", + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, }, }, { id: component.NewIDWithName(metadata.Type, "3"), expected: &Config{ - Endpoint: "apm.collector.na-01.cloud.solarwinds.com:443", + ClientConfig: configgrpc.ClientConfig{ + Endpoint: "apm.collector.eu-01.cloud.solarwinds.com:443", + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "4"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: "apm.collector.apj-01.cloud.solarwinds.com:443", + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "5"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: "apm.collector.na-01.st-ssp.solarwinds.com:443", + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "6"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: "apm.collector.na-01.dev-ssp.solarwinds.com:443", + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "7"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "8"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "9"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "10"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "11"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "12"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, Key: "something:name", - Interval: time.Duration(60) * time.Second, + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "13"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "14"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "15"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "something:name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "16"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "17"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: ":", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "18"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "::", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "19"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: ":name", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "20"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "token:", + Interval: time.Duration(10) * time.Second, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "21"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "token:name", + Interval: MinimumInterval, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "22"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "token:name", + Interval: MaximumInterval, + }, + }, + { + id: component.NewIDWithName(metadata.Type, "23"), + expected: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + Key: "token:name", + Interval: MinimumInterval, }, }, } diff --git a/extension/solarwindsapmsettingsextension/extension.go b/extension/solarwindsapmsettingsextension/extension.go index 04bd1b75cc56..0ec7dd130a2c 100644 --- a/extension/solarwindsapmsettingsextension/extension.go +++ b/extension/solarwindsapmsettingsextension/extension.go @@ -6,6 +6,12 @@ package solarwindsapmsettingsextension // import "github.com/open-telemetry/open import ( "context" "crypto/tls" + "crypto/x509" + "encoding/binary" + "encoding/json" + "math" + "os" + "path" "time" "github.com/solarwindscloud/apm-proto/go/collectorpb" @@ -16,36 +22,45 @@ import ( "google.golang.org/grpc/credentials" ) +const ( + jsonOutputFile = "solarwinds-apm-settings.json" + grpcContextDeadline = 1 * time.Second +) + type solarwindsapmSettingsExtension struct { - logger *zap.Logger - config *Config - cancel context.CancelFunc - conn *grpc.ClientConn - client collectorpb.TraceCollectorClient + config *Config + cancel context.CancelFunc + conn *grpc.ClientConn + client collectorpb.TraceCollectorClient + telemetrySettings component.TelemetrySettings } -func newSolarwindsApmSettingsExtension(extensionCfg *Config, logger *zap.Logger) (extension.Extension, error) { +func newSolarwindsApmSettingsExtension(extensionCfg *Config, settings extension.Settings) (extension.Extension, error) { settingsExtension := &solarwindsapmSettingsExtension{ - config: extensionCfg, - logger: logger, + config: extensionCfg, + telemetrySettings: settings.TelemetrySettings, } return settingsExtension, nil } -func (extension *solarwindsapmSettingsExtension) Start(_ context.Context, _ component.Host) error { - extension.logger.Info("Starting up solarwinds apm settings extension") +func (extension *solarwindsapmSettingsExtension) Start(_ context.Context, host component.Host) error { + extension.telemetrySettings.Logger.Info("starting up solarwinds apm settings extension") ctx := context.Background() ctx, extension.cancel = context.WithCancel(ctx) - var err error - extension.conn, err = grpc.NewClient(extension.config.Endpoint, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{}))) + systemCertPool, err := x509.SystemCertPool() if err != nil { return err } - extension.logger.Info("Dailed to endpoint", zap.String("endpoint", extension.config.Endpoint)) + extension.conn, err = extension.config.ClientConfig.ToClientConn(ctx, host, extension.telemetrySettings, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{RootCAs: systemCertPool}))) + if err != nil { + return err + } + extension.telemetrySettings.Logger.Info("created a gRPC client", zap.String("endpoint", extension.config.ClientConfig.Endpoint)) extension.client = collectorpb.NewTraceCollectorClient(extension.conn) + outputFile := path.Join(os.TempDir(), jsonOutputFile) // initial refresh - refresh(extension) + refresh(extension, outputFile) go func() { ticker := time.NewTicker(extension.config.Interval) @@ -53,9 +68,9 @@ func (extension *solarwindsapmSettingsExtension) Start(_ context.Context, _ comp for { select { case <-ticker.C: - refresh(extension) + refresh(extension, outputFile) case <-ctx.Done(): - extension.logger.Info("Received ctx.Done() from ticker") + extension.telemetrySettings.Logger.Info("received ctx.Done() from ticker") return } } @@ -65,7 +80,7 @@ func (extension *solarwindsapmSettingsExtension) Start(_ context.Context, _ comp } func (extension *solarwindsapmSettingsExtension) Shutdown(_ context.Context) error { - extension.logger.Info("Shutting down solarwinds apm settings extension") + extension.telemetrySettings.Logger.Info("shutting down solarwinds apm settings extension") if extension.cancel != nil { extension.cancel() } @@ -75,7 +90,92 @@ func (extension *solarwindsapmSettingsExtension) Shutdown(_ context.Context) err return nil } -func refresh(extension *solarwindsapmSettingsExtension) { - // Concrete implementation will be available in later PR - extension.logger.Info("refresh task") +func refresh(extension *solarwindsapmSettingsExtension, filename string) { + extension.telemetrySettings.Logger.Info("time to refresh", zap.String("endpoint", extension.config.ClientConfig.Endpoint)) + hostname, err := os.Hostname() + if err != nil { + extension.telemetrySettings.Logger.Error("unable to call os.Hostname()", zap.Error(err)) + return + } + ctx, cancel := context.WithTimeout(context.Background(), grpcContextDeadline) + defer cancel() + + request := &collectorpb.SettingsRequest{ + ApiKey: extension.config.Key, + Identity: &collectorpb.HostID{ + Hostname: hostname, + }, + ClientVersion: "2", + } + response, err := extension.client.GetSettings(ctx, request) + if err != nil { + extension.telemetrySettings.Logger.Error("unable to get settings", zap.String("endpoint", extension.config.ClientConfig.Endpoint), zap.Error(err)) + return + } + switch result := response.GetResult(); result { + case collectorpb.ResultCode_OK: + if len(response.GetWarning()) > 0 { + extension.telemetrySettings.Logger.Warn("GetSettings succeed", zap.String("result", result.String()), zap.String("warning", response.GetWarning())) + } + var settings []map[string]any + for _, item := range response.GetSettings() { + setting := make(map[string]any) + setting["flags"] = string(item.GetFlags()) + setting["timestamp"] = item.GetTimestamp() + setting["value"] = item.GetValue() + arguments := make(map[string]any) + if value, ok := item.Arguments["BucketCapacity"]; ok { + arguments["BucketCapacity"] = math.Float64frombits(binary.LittleEndian.Uint64(value)) + } + if value, ok := item.Arguments["BucketRate"]; ok { + arguments["BucketRate"] = math.Float64frombits(binary.LittleEndian.Uint64(value)) + } + if value, ok := item.Arguments["TriggerRelaxedBucketCapacity"]; ok { + arguments["TriggerRelaxedBucketCapacity"] = math.Float64frombits(binary.LittleEndian.Uint64(value)) + } + if value, ok := item.Arguments["TriggerRelaxedBucketRate"]; ok { + arguments["TriggerRelaxedBucketRate"] = math.Float64frombits(binary.LittleEndian.Uint64(value)) + } + if value, ok := item.Arguments["TriggerStrictBucketCapacity"]; ok { + arguments["TriggerStrictBucketCapacity"] = math.Float64frombits(binary.LittleEndian.Uint64(value)) + } + if value, ok := item.Arguments["TriggerStrictBucketRate"]; ok { + arguments["TriggerStrictBucketRate"] = math.Float64frombits(binary.LittleEndian.Uint64(value)) + } + if value, ok := item.Arguments["MetricsFlushInterval"]; ok { + arguments["MetricsFlushInterval"] = int32(binary.LittleEndian.Uint32(value)) + } + if value, ok := item.Arguments["MaxTransactions"]; ok { + arguments["MaxTransactions"] = int32(binary.LittleEndian.Uint32(value)) + } + if value, ok := item.Arguments["MaxCustomMetrics"]; ok { + arguments["MaxCustomMetrics"] = int32(binary.LittleEndian.Uint32(value)) + } + if value, ok := item.Arguments["EventsFlushInterval"]; ok { + arguments["EventsFlushInterval"] = int32(binary.LittleEndian.Uint32(value)) + } + if value, ok := item.Arguments["ProfilingInterval"]; ok { + arguments["ProfilingInterval"] = int32(binary.LittleEndian.Uint32(value)) + } + setting["arguments"] = arguments + setting["ttl"] = item.GetTtl() + settings = append(settings, setting) + } + if content, err := json.Marshal(settings); err != nil { + extension.telemetrySettings.Logger.Error("unable to marshal setting JSON[] byte from settings", zap.Error(err)) + } else { + if err := os.WriteFile(filename, content, 0600); err != nil { + extension.telemetrySettings.Logger.Error("unable to write "+filename, zap.Error(err)) + } else { + if len(response.GetWarning()) > 0 { + extension.telemetrySettings.Logger.Warn(filename + " is refreshed (soft disabled)") + } else { + extension.telemetrySettings.Logger.Info(filename + " is refreshed") + } + extension.telemetrySettings.Logger.Info(string(content)) + } + } + default: + extension.telemetrySettings.Logger.Warn("GetSettings failed", zap.String("result", result.String()), zap.String("warning", response.GetWarning())) + } } diff --git a/extension/solarwindsapmsettingsextension/extension_test.go b/extension/solarwindsapmsettingsextension/extension_test.go index 743f9b89eca7..3b8278e12048 100644 --- a/extension/solarwindsapmsettingsextension/extension_test.go +++ b/extension/solarwindsapmsettingsextension/extension_test.go @@ -5,12 +5,21 @@ package solarwindsapmsettingsextension import ( "context" + "os" "testing" "time" + "github.com/google/uuid" + "github.com/solarwindscloud/apm-proto/go/collectorpb" + "github.com/solarwindscloud/apm-proto/go/collectorpb/mocks" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/extension" "go.uber.org/zap" + "go.uber.org/zap/zaptest/observer" ) func TestCreateExtension(t *testing.T) { @@ -23,14 +32,18 @@ func TestCreateExtension(t *testing.T) { { name: "default", cfg: &Config{ - Endpoint: DefaultEndpoint, + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, Interval: DefaultInterval, }, }, { name: "anything", cfg: &Config{ - Endpoint: "apm.collector.na-02.cloud.solarwinds.com:443", + ClientConfig: configgrpc.ClientConfig{ + Endpoint: "apm.collector.na-02.cloud.solarwinds.com:443", + }, Key: "something:name", Interval: time.Duration(10) * time.Second, }, @@ -44,12 +57,216 @@ func TestCreateExtension(t *testing.T) { } } +// newNopSettings returns a new nop settings for extension.Factory Create* functions. +func newNopSettings() extension.Settings { + return extension.Settings{ + ID: component.NewIDWithName(component.MustNewType("nop"), uuid.NewString()), + TelemetrySettings: componenttest.NewNopTelemetrySettings(), + BuildInfo: component.NewDefaultBuildInfo(), + } +} + // create extension func createAnExtension(c *Config, t *testing.T) extension.Extension { - logger, err := zap.NewProduction() - require.NoError(t, err) - ex, err := newSolarwindsApmSettingsExtension(c, logger) + ex, err := newSolarwindsApmSettingsExtension(c, newNopSettings()) require.NoError(t, err) require.NoError(t, ex.Start(context.TODO(), nil)) return ex } + +func TestRefresh(t *testing.T) { + t.Parallel() + tests := []struct { + name string + cfg *Config + reply *collectorpb.SettingsResult + filename string + expectedLogMessages []string + fileExist bool + }{ + { + name: "ok", + cfg: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + }, + reply: &collectorpb.SettingsResult{ + Result: collectorpb.ResultCode_OK, + Settings: []*collectorpb.OboeSetting{ + { + Type: collectorpb.OboeSettingType_DEFAULT_SAMPLE_RATE, + Flags: []byte("flag1,flag2,flag3"), + Timestamp: 123, + Value: 456, + Layer: []byte("layer1"), + Arguments: map[string][]byte{ + "BucketCapacity": {1, 0, 0, 0, 0, 0, 0, 64}, + "BucketRate": {2, 0, 0, 0, 0, 0, 240, 63}, + "TriggerRelaxedBucketCapacity": {3, 0, 0, 0, 0, 0, 52, 64}, + "TriggerRelaxedBucketRate": {4, 0, 0, 0, 0, 0, 240, 63}, + "TriggerStrictBucketCapacity": {0, 0, 0, 0, 0, 0, 24, 64}, + "TriggerStrictBucketRate": {154, 153, 153, 153, 153, 153, 185, 63}, + "MetricsFlushInterval": {60, 0, 0, 0}, + "MaxTransactions": {1, 0, 0, 0}, + "MaxCustomMetrics": {2, 0, 0, 0}, + "EventsFlushInterval": {3, 0, 0, 0}, + "ProfilingInterval": {4, 0, 0, 0}, + "SignatureKey": []byte("key"), + }, + Ttl: 789, + }, + }, + }, + filename: "testdata/refresh_ok.json", + expectedLogMessages: []string{ + "time to refresh", + "testdata/refresh_ok.json is refreshed", + "[{\"arguments\":{\"BucketCapacity\":2.0000000000000004,\"BucketRate\":1.0000000000000004,\"EventsFlushInterval\":3,\"MaxCustomMetrics\":2,\"MaxTransactions\":1,\"MetricsFlushInterval\":60,\"ProfilingInterval\":4,\"TriggerRelaxedBucketCapacity\":20.00000000000001,\"TriggerRelaxedBucketRate\":1.0000000000000009,\"TriggerStrictBucketCapacity\":6,\"TriggerStrictBucketRate\":0.1},\"flags\":\"flag1,flag2,flag3\",\"timestamp\":123,\"ttl\":789,\"value\":456}]", + }, + fileExist: true, + }, + { + name: "ok with warning", + cfg: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + }, + reply: &collectorpb.SettingsResult{ + Result: collectorpb.ResultCode_OK, + Settings: []*collectorpb.OboeSetting{ + { + Type: collectorpb.OboeSettingType_DEFAULT_SAMPLE_RATE, + Flags: []byte("flags"), + Timestamp: 0, + Value: 0, + Layer: []byte{}, + Arguments: map[string][]byte{ + "BucketCapacity": {0, 0, 0, 0, 0, 0, 0, 0}, + "BucketRate": {2, 0, 0, 0, 0, 0, 0, 0}, + "TriggerRelaxedBucketCapacity": {0, 0, 0, 0, 0, 0, 0, 0}, + "TriggerRelaxedBucketRate": {0, 0, 0, 0, 0, 0, 0, 0}, + "TriggerStrictBucketCapacity": {0, 0, 0, 0, 0, 0, 0, 0}, + "TriggerStrictBucketRate": {0, 0, 0, 0, 0, 0, 0, 0}, + "MetricsFlushInterval": {0, 0, 0, 0}, + "MaxTransactions": {0, 0, 0, 0}, + "MaxCustomMetrics": {0, 0, 0, 0}, + "EventsFlushInterval": {0, 0, 0, 0}, + "ProfilingInterval": {0, 0, 0, 0}, + "SignatureKey": []byte(""), + }, + Ttl: 10, + }, + }, + Warning: "warning", + }, + filename: "testdata/refresh_warning.json", + expectedLogMessages: []string{ + "time to refresh", + "GetSettings succeed", + "testdata/refresh_warning.json is refreshed (soft disabled)", + "[{\"arguments\":{\"BucketCapacity\":0,\"BucketRate\":1e-323,\"EventsFlushInterval\":0,\"MaxCustomMetrics\":0,\"MaxTransactions\":0,\"MetricsFlushInterval\":0,\"ProfilingInterval\":0,\"TriggerRelaxedBucketCapacity\":0,\"TriggerRelaxedBucketRate\":0,\"TriggerStrictBucketCapacity\":0,\"TriggerStrictBucketRate\":0},\"flags\":\"flags\",\"timestamp\":0,\"ttl\":10,\"value\":0}]", + }, + fileExist: true, + }, + { + name: "try later", + cfg: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + }, + reply: &collectorpb.SettingsResult{ + Result: collectorpb.ResultCode_TRY_LATER, + Warning: "warning", + }, + filename: "testdata/refresh_later.json", + expectedLogMessages: []string{ + "time to refresh", + "GetSettings failed", + }, + fileExist: false, + }, + { + name: "invalid api key", + cfg: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + }, + reply: &collectorpb.SettingsResult{ + Result: collectorpb.ResultCode_INVALID_API_KEY, + Warning: "warning", + }, + filename: "testdata/refresh_invalid_api_key.json", + expectedLogMessages: []string{ + "time to refresh", + "GetSettings failed", + }, + fileExist: false, + }, + { + name: "limit exceeded", + cfg: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + }, + reply: &collectorpb.SettingsResult{ + Result: collectorpb.ResultCode_LIMIT_EXCEEDED, + Warning: "warning", + }, + filename: "testdata/refresh_limit.json", + expectedLogMessages: []string{ + "time to refresh", + "GetSettings failed", + }, + fileExist: false, + }, + { + name: "redirect", + cfg: &Config{ + ClientConfig: configgrpc.ClientConfig{ + Endpoint: DefaultEndpoint, + }, + }, + reply: &collectorpb.SettingsResult{ + Result: collectorpb.ResultCode_REDIRECT, + Warning: "warning", + }, + filename: "testdata/refresh_redirect.json", + expectedLogMessages: []string{ + "time to refresh", + "GetSettings failed", + }, + fileExist: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + mockTraceCollectorClient := &mocks.TraceCollectorClient{} + mockTraceCollectorClient.On("GetSettings", mock.Anything, mock.Anything).Return(tt.reply, nil) + observedZapCore, observedLogs := observer.New(zap.InfoLevel) + settings := newNopSettings() + settings.TelemetrySettings.Logger = zap.New(observedZapCore) + settingsExtension := &solarwindsapmSettingsExtension{ + config: tt.cfg, + telemetrySettings: settings.TelemetrySettings, + client: mockTraceCollectorClient, + } + refresh(settingsExtension, tt.filename) + require.Equal(t, len(tt.expectedLogMessages), observedLogs.Len()) + for index, observedLog := range observedLogs.All() { + require.Equal(t, tt.expectedLogMessages[index], observedLog.Message) + } + _, err := os.Stat(tt.filename) + if tt.fileExist { + require.NoError(t, err) + require.NoError(t, os.Remove(tt.filename)) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/extension/solarwindsapmsettingsextension/factory.go b/extension/solarwindsapmsettingsextension/factory.go index b521cbeee72f..c19b218eafec 100644 --- a/extension/solarwindsapmsettingsextension/factory.go +++ b/extension/solarwindsapmsettingsextension/factory.go @@ -13,7 +13,7 @@ import ( ) func createExtension(_ context.Context, settings extension.Settings, cfg component.Config) (extension.Extension, error) { - return newSolarwindsApmSettingsExtension(cfg.(*Config), settings.Logger) + return newSolarwindsApmSettingsExtension(cfg.(*Config), settings) } func NewFactory() extension.Factory { diff --git a/extension/solarwindsapmsettingsextension/factory_test.go b/extension/solarwindsapmsettingsextension/factory_test.go index 48f7ee1e35f8..d30f14fbaa44 100644 --- a/extension/solarwindsapmsettingsextension/factory_test.go +++ b/extension/solarwindsapmsettingsextension/factory_test.go @@ -17,7 +17,7 @@ func TestCreateDefaultConfig(t *testing.T) { assert.NoError(t, componenttest.CheckConfigStruct(cfg)) ocfg, ok := factory.CreateDefaultConfig().(*Config) assert.True(t, ok) - assert.Equal(t, ocfg.Endpoint, DefaultEndpoint, "Wrong default endpoint") + assert.Equal(t, ocfg.ClientConfig.Endpoint, DefaultEndpoint, "Wrong default endpoint") assert.Empty(t, ocfg.Key, "There is no default key") assert.Equal(t, ocfg.Interval, DefaultInterval, "Wrong default interval") } diff --git a/extension/solarwindsapmsettingsextension/go.mod b/extension/solarwindsapmsettingsextension/go.mod index b3d3a17b36b5..3a2c38d59f93 100644 --- a/extension/solarwindsapmsettingsextension/go.mod +++ b/extension/solarwindsapmsettingsextension/go.mod @@ -3,9 +3,11 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/extension/solar go 1.22.0 require ( + github.com/google/uuid v1.6.0 github.com/solarwindscloud/apm-proto v1.0.7 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.108.2-0.20240829190554-7da6b618a7ee + go.opentelemetry.io/collector/config/configgrpc v0.108.2-0.20240829190554-7da6b618a7ee go.opentelemetry.io/collector/confmap v1.14.2-0.20240829190554-7da6b618a7ee go.opentelemetry.io/collector/extension v0.108.2-0.20240829190554-7da6b618a7ee go.uber.org/goleak v1.3.0 @@ -17,26 +19,41 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/uuid v1.6.0 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/knadh/koanf/maps v0.1.1 // indirect github.com/knadh/koanf/providers/confmap v0.1.0 // indirect github.com/knadh/koanf/v2 v2.1.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/mostynb/go-grpc-compression v1.2.3 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.20.2 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.56.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect + github.com/stretchr/objx v0.5.2 // indirect + go.opentelemetry.io/collector v0.108.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/collector/client v1.14.1 // indirect go.opentelemetry.io/collector/component/componentstatus v0.108.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/collector/config/configauth v0.108.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/collector/config/configcompression v1.14.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/collector/config/confignet v0.108.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/collector/config/configopaque v1.14.2-0.20240829190554-7da6b618a7ee // indirect go.opentelemetry.io/collector/config/configtelemetry v0.108.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/collector/config/configtls v1.14.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/collector/config/internal v0.108.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/collector/extension/auth v0.108.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/collector/featuregate v1.14.2-0.20240829190554-7da6b618a7ee // indirect go.opentelemetry.io/collector/pdata v1.14.2-0.20240829190554-7da6b618a7ee // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect go.opentelemetry.io/otel v1.29.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.51.0 // indirect go.opentelemetry.io/otel/metric v1.29.0 // indirect @@ -44,10 +61,10 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.29.0 // indirect go.opentelemetry.io/otel/trace v1.29.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.27.0 // indirect + golang.org/x/net v0.28.0 // indirect golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect + golang.org/x/text v0.17.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/extension/solarwindsapmsettingsextension/go.sum b/extension/solarwindsapmsettingsextension/go.sum index a2797c14adc7..44d6edb7ea24 100644 --- a/extension/solarwindsapmsettingsextension/go.sum +++ b/extension/solarwindsapmsettingsextension/go.sum @@ -4,6 +4,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -13,10 +15,16 @@ github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpG github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= @@ -37,6 +45,12 @@ github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa1 github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mostynb/go-grpc-compression v1.2.3 h1:42/BKWMy0KEJGSdWvzqIyOZ95YcR9mLPqKctH7Uo//I= +github.com/mostynb/go-grpc-compression v1.2.3/go.mod h1:AghIxF3P57umzqM9yz795+y1Vjs47Km/Y2FE6ouQ7Lg= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -53,22 +67,54 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/solarwindscloud/apm-proto v1.0.7 h1:7vJWXKjMwCv4Ej1niRQr8nGKLBoBtDXLMM9p5v7mW+I= github.com/solarwindscloud/apm-proto v1.0.7/go.mod h1:PIMzXc8HpB0ryT4Oci4pUz8F0m1X7Q/hVXkQE4jGv6Y= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/collector v0.108.2-0.20240829190554-7da6b618a7ee h1:qwS5eXqdHQ8/H6adgQXaqYNv/lco6F7Xl7keuwQ+pWA= +go.opentelemetry.io/collector v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:XhZ6xcWvPeAAqp++6tVqvSphaaAs5loWzolvEjLMkUk= +go.opentelemetry.io/collector/client v1.14.1 h1:UiBhFP07YbZlv3fW2D/Xi0DrEMRGw2QB1DLV2JiJEis= +go.opentelemetry.io/collector/client v1.14.1/go.mod h1:a8A6aWydaeiItFzY0zlHO/Q6mLNnZsW0Y/iVxbJsO4A= go.opentelemetry.io/collector/component v0.108.2-0.20240829190554-7da6b618a7ee h1:huxxQgE9nyBcwUtiJaJFTupk0MhXsy8Y3ZclJ0mCREY= go.opentelemetry.io/collector/component v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:Z9M91arav1Mf67csQf2484IMUx5a++4oAlikGM28AoI= go.opentelemetry.io/collector/component/componentstatus v0.108.2-0.20240829190554-7da6b618a7ee h1:SsH8uYXHWWLJRnolMW3i4EisxTkm3AQk16hPcakBvTw= go.opentelemetry.io/collector/component/componentstatus v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:QcQ4vrW+Z04cg7bvVuAufet3piiZv2+0ugWcLeuMfz4= +go.opentelemetry.io/collector/config/configauth v0.108.2-0.20240829190554-7da6b618a7ee h1:8awSw1sSS0lwNhf6JVhKTFU8tZSaoZpkLH+VQjKnDs0= +go.opentelemetry.io/collector/config/configauth v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:9pjyjXeKrAqvaSrQaQP4vQc2gVKSOtzDrpLasSJp9qk= +go.opentelemetry.io/collector/config/configcompression v1.14.2-0.20240829190554-7da6b618a7ee h1:M9tUkFU3D2/jihM/ZwdsMfoHbKo5t8h2ZajZqQ43VbA= +go.opentelemetry.io/collector/config/configcompression v1.14.2-0.20240829190554-7da6b618a7ee/go.mod h1:pnxkFCLUZLKWzYJvfSwZnPrnm0twX14CYj2ADth5xiU= +go.opentelemetry.io/collector/config/configgrpc v0.108.2-0.20240829190554-7da6b618a7ee h1:aMtB+FFvK+v7+678+GP4Yq7XyQBjuhxgg+K829J3xUk= +go.opentelemetry.io/collector/config/configgrpc v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:kC5PDeUe/Y9pCelH89ma7qhTTcb785CKL90liy1MaZ8= +go.opentelemetry.io/collector/config/confignet v0.108.2-0.20240829190554-7da6b618a7ee h1:/7J6WuiDLjMN9CKIbYqsw9Y99YJ+QcERcsZAvUWxyWI= +go.opentelemetry.io/collector/config/confignet v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:o3v4joAEjvLwntqexg5ixMqRrU1+Vst+jWuCUaBNgOg= +go.opentelemetry.io/collector/config/configopaque v1.14.2-0.20240829190554-7da6b618a7ee h1:Rg4HrJ2Lu9W4NNvkDLJwmOWJO45u9ucKcQ/G2erVapU= +go.opentelemetry.io/collector/config/configopaque v1.14.2-0.20240829190554-7da6b618a7ee/go.mod h1:6zlLIyOoRpJJ+0bEKrlZOZon3rOp5Jrz9fMdR4twOS4= go.opentelemetry.io/collector/config/configtelemetry v0.108.2-0.20240829190554-7da6b618a7ee h1:LGoJWO9fANov2zNgtX4uYuH6YI4p+H0I/PbY2S+9wLk= go.opentelemetry.io/collector/config/configtelemetry v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:R0MBUxjSMVMIhljuDHWIygzzJWQyZHXXWIgQNxcFwhc= +go.opentelemetry.io/collector/config/configtls v1.14.2-0.20240829190554-7da6b618a7ee h1:gwOJQiT5+tWB66lwp5nrUrBj67pa0o2N+KNLgfZvngg= +go.opentelemetry.io/collector/config/configtls v1.14.2-0.20240829190554-7da6b618a7ee/go.mod h1:StxglrVWeRIFaqc2hpsF9xSsv2A5MOAx5GhG4WjFuP4= +go.opentelemetry.io/collector/config/internal v0.108.2-0.20240829190554-7da6b618a7ee h1:trfNlCLq8bycjsdvB6GmoELDf34aFA2G7eOARIberTo= +go.opentelemetry.io/collector/config/internal v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:tRaaE2CNdXE3lUQcIBGJkdBPSGYY3Taa6DzkWmxmgzk= go.opentelemetry.io/collector/confmap v1.14.2-0.20240829190554-7da6b618a7ee h1:+AZ6R3DhcUGDVQVya18ZVoZK863f8a1LXhHBq9TKkuw= go.opentelemetry.io/collector/confmap v1.14.2-0.20240829190554-7da6b618a7ee/go.mod h1:GrIZ12P/9DPOuTpe2PIS51a0P/ZM6iKtByVee1Uf3+k= +go.opentelemetry.io/collector/consumer v0.108.1 h1:75zHUpIDfgZMp3t9fYdpXXE6/wsBs9DwTZdfwS3+NDI= +go.opentelemetry.io/collector/consumer v0.108.1/go.mod h1:xu2pOTqK+uCFXZWd9RcU8s6sCRwK5GyuP64YuHLMzzA= go.opentelemetry.io/collector/extension v0.108.2-0.20240829190554-7da6b618a7ee h1:yuy6iGp41ARpBTR3E0IjwbJNps4me7QBlViAXIT00Xs= go.opentelemetry.io/collector/extension v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:0Ialf9Lc/ESknUYJnAeQjGdQvlhLtJav0sv+Eo2xMnU= +go.opentelemetry.io/collector/extension/auth v0.108.2-0.20240829190554-7da6b618a7ee h1:w6Y6lOz9HRkl0rjdxmlqp209tvtWIaXOUqYH4YqTY1s= +go.opentelemetry.io/collector/extension/auth v0.108.2-0.20240829190554-7da6b618a7ee/go.mod h1:CmNrylNxbrs/awKHOdRWdu5BMAUxXyY94ry9LrKH/tQ= +go.opentelemetry.io/collector/featuregate v1.14.2-0.20240829190554-7da6b618a7ee h1:kOnDlEC1EDsymDjAZe8LZhwbVqnWPtPwSlUXDYwUmws= +go.opentelemetry.io/collector/featuregate v1.14.2-0.20240829190554-7da6b618a7ee/go.mod h1:47xrISO71vJ83LSMm8+yIDsUbKktUp48Ovt7RR6VbRs= go.opentelemetry.io/collector/pdata v1.14.2-0.20240829190554-7da6b618a7ee h1:vqnRTZckt4i+bGcR+d/LAOAe4nAAs/KkN2L2CTXvW0Q= go.opentelemetry.io/collector/pdata v1.14.2-0.20240829190554-7da6b618a7ee/go.mod h1:z1dTjwwtcoXxZx2/nkHysjxMeaxe9pEmYTEr4SMNIx8= +go.opentelemetry.io/collector/pdata/pprofile v0.108.1 h1:/XbunfZ+/jt1+d1p4zM4vZ/AgeaIJsayjYdlN1fV+tk= +go.opentelemetry.io/collector/pdata/pprofile v0.108.1/go.mod h1:/GvG2WcN9Dajlw4QaIOjgz7N32wSfPL3qxJ0BKOcVPo= +go.opentelemetry.io/collector/pdata/testdata v0.108.1 h1:TpBDoBMBYvC/Ibswe3Ec2eof8XrRrEec6+tfnTeTSGk= +go.opentelemetry.io/collector/pdata/testdata v0.108.1/go.mod h1:PdUmBA4yDRD4Wf0fpCyrpdZexz9EDoHBw5Ot4iIUPRs= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 h1:r6I7RJCN86bpD/FQwedZ0vSixDpwuWREjW9oRMsmqDc= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0/go.mod h1:B9yO6b04uB80CzjedvewuqDhxJxi11s7/GtiGa8bAjI= go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= go.opentelemetry.io/otel/exporters/prometheus v0.51.0 h1:G7uexXb/K3T+T9fNLCCKncweEtNEBMTO+46hKX5EdKw= @@ -96,8 +142,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -108,8 +154,8 @@ golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -118,8 +164,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd h1:6TEm2ZxXoQmFWFlt1vNxvVOa1Q0dXFQD1m/rYjXmS0E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= diff --git a/extension/solarwindsapmsettingsextension/testdata/config.yaml b/extension/solarwindsapmsettingsextension/testdata/config.yaml index 4fb5cf5c0417..f6e45b2b01f0 100644 --- a/extension/solarwindsapmsettingsextension/testdata/config.yaml +++ b/extension/solarwindsapmsettingsextension/testdata/config.yaml @@ -1,13 +1,93 @@ solarwindsapmsettings: solarwindsapmsettings/1: - endpoint: "apm.collector.apj-01.cloud.solarwinds.com:443" + endpoint: "apm.collector.na-01.cloud.solarwinds.com:443" key: "something:name" interval: 10s solarwindsapmsettings/2: - endpoint: "apm.collector.eu-01.cloud.solarwinds.com" - key: "something" - interval: "4s" + endpoint: "apm.collector.na-02.cloud.solarwinds.com:443" + key: "something:name" + interval: 10s solarwindsapmsettings/3: + endpoint: "apm.collector.eu-01.cloud.solarwinds.com:443" + key: "something:name" + interval: 10s +solarwindsapmsettings/4: + endpoint: "apm.collector.apj-01.cloud.solarwinds.com:443" + key: "something:name" + interval: 10s +solarwindsapmsettings/5: + endpoint: "apm.collector.na-01.st-ssp.solarwinds.com:443" + key: "something:name" + interval: 10s +solarwindsapmsettings/6: + endpoint: "apm.collector.na-01.dev-ssp.solarwinds.com:443" + key: "something:name" + interval: 10s +solarwindsapmsettings/7: + endpoint: "apm.collector.na-01.cloud.solarwinds.com" + key: "something:name" + interval: 10s +solarwindsapmsettings/8: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:a:b" + key: "something:name" + interval: 10s +solarwindsapmsettings/9: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:port" + key: "something:name" + interval: 10s +solarwindsapmsettings/10: + endpoint: "apm.collector..cloud.solarwinds.com:443" + key: "something:name" + interval: 10s +solarwindsapmsettings/11: + endpoint: ":443" + key: "something:name" + interval: 10s +solarwindsapmsettings/12: + endpoint: ":" + key: "something:name" + interval: 10s +solarwindsapmsettings/13: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:" + key: "something:name" + interval: 10s +solarwindsapmsettings/14: + endpoint: "::" + key: "something:name" + interval: 10s +solarwindsapmsettings/15: endpoint: "" key: "something:name" + interval: 10s +solarwindsapmsettings/16: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:443" + key: "" + interval: 10s +solarwindsapmsettings/17: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:443" + key: ":" + interval: 10s +solarwindsapmsettings/18: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:443" + key: "::" + interval: 10s +solarwindsapmsettings/19: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:443" + key: ":name" + interval: 10s +solarwindsapmsettings/20: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:443" + key: "token:" + interval: 10s +solarwindsapmsettings/21: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:443" + key: "token:name" + interval: 4s +solarwindsapmsettings/22: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:443" + key: "token:name" interval: 61s +solarwindsapmsettings/23: + endpoint: "apm.collector.na-01.cloud.solarwinds.com:443" + key: "token:name" + interval: 30