Skip to content

Commit

Permalink
Rm ReporterType
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed May 14, 2024
1 parent faa9a78 commit 75eab4c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 67 deletions.
17 changes: 0 additions & 17 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ type Config struct {
// The file path of the cert file for gRPC connection
TrustedPath string `yaml:"TrustedPath,omitempty" env:"SW_APM_TRUSTEDPATH"`

// The reporter type, ssl or none
ReporterType string `yaml:"ReporterType,omitempty" env:"SW_APM_REPORTER" default:"ssl"`

Sampling *SamplingConfig `yaml:"Sampling,omitempty"`

// Whether the domain should be prepended to the transaction name.
Expand Down Expand Up @@ -365,13 +362,6 @@ func (c *Config) validate() error {
c.Ec2MetadataTimeout = t
}

c.ReporterType = strings.ToLower(strings.TrimSpace(c.ReporterType))

if ok := IsValidReporterType(c.ReporterType); !ok {
log.Info(InvalidEnv("ReporterType", c.ReporterType))
c.ReporterType = getFieldDefaultValue(c, "ReporterType")
}

if c.TransactionName != "" && !hasLambdaEnv() {
log.Info(InvalidEnv("TransactionName", c.TransactionName))
c.TransactionName = getFieldDefaultValue(c, "TransactionName")
Expand Down Expand Up @@ -777,13 +767,6 @@ func (c *Config) GetTrustedPath() string {
return c.TrustedPath
}

// GetReporterType returns the reporter type
func (c *Config) GetReporterType() string {
c.RLock()
defer c.RUnlock()
return c.ReporterType
}

// GetTracingMode returns the local tracing mode
func (c *Config) GetTracingMode() TracingMode {
c.RLock()
Expand Down
38 changes: 15 additions & 23 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ func TestConfigInit(t *testing.T) {
c.reset()

defaultC := Config{
Collector: defaultSSLCollector,
ServiceKey: "",
TrustedPath: "",
ReporterType: "ssl",
Collector: defaultSSLCollector,
ServiceKey: "",
TrustedPath: "",
Sampling: &SamplingConfig{
TracingMode: "enabled",
tracingModeConfigured: false,
Expand Down Expand Up @@ -253,10 +252,9 @@ func TestEnvsLoading(t *testing.T) {
SetEnvs(envs)

envConfig := Config{
Collector: "collector.test.com",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
TrustedPath: "/collector.crt",
ReporterType: "ssl",
Collector: "collector.test.com",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
TrustedPath: "/collector.crt",
Sampling: &SamplingConfig{
TracingMode: "disabled",
tracingModeConfigured: true,
Expand Down Expand Up @@ -300,10 +298,9 @@ func TestEnvsLoading(t *testing.T) {

func TestYamlConfig(t *testing.T) {
yamlConfig := Config{
Collector: "yaml.test.com",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189218:go",
TrustedPath: "/yaml-collector.crt",
ReporterType: "ssl",
Collector: "yaml.test.com",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189218:go",
TrustedPath: "/yaml-collector.crt",
Sampling: &SamplingConfig{
TracingMode: "disabled",
tracingModeConfigured: true,
Expand Down Expand Up @@ -383,10 +380,9 @@ func TestYamlConfig(t *testing.T) {
os.Setenv("SW_APM_CONFIG_FILE", "/tmp/solarwinds-apm-config.yaml")

envConfig := Config{
Collector: "collector.test.com",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
TrustedPath: "/collector.crt",
ReporterType: "ssl",
Collector: "collector.test.com",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
TrustedPath: "/collector.crt",
Sampling: &SamplingConfig{
TracingMode: "disabled",
tracingModeConfigured: true,
Expand Down Expand Up @@ -496,10 +492,9 @@ func TestInvalidConfig(t *testing.T) {
}()

invalid := Config{
Collector: "",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
TrustedPath: "",
ReporterType: "invalid",
Collector: "",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
TrustedPath: "",
Sampling: &SamplingConfig{
TracingMode: "disabled",
tracingModeConfigured: true,
Expand Down Expand Up @@ -532,9 +527,6 @@ func TestInvalidConfig(t *testing.T) {
assert.Equal(t, defaultSSLCollector, invalid.Collector)
assert.Contains(t, buf.String(), "invalid env, discarded - Collector:", buf.String())

assert.Equal(t, "ssl", invalid.ReporterType)
assert.Contains(t, buf.String(), "invalid env, discarded - ReporterType:", buf.String())

assert.Equal(t, 1000, invalid.Ec2MetadataTimeout)
assert.Contains(t, buf.String(), "invalid env, discarded - Ec2MetadataTimeout:", buf.String())

Expand Down
11 changes: 0 additions & 11 deletions internal/config/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ const (
invalidCharReplacer = ""
)

// reporter types
const (
reporterTypeSSL = "ssl"
)

var (
// IsValidServiceKey verifies if the service key is a valid one.
// A valid service key is something like 'service_token:service_name'.
Expand Down Expand Up @@ -101,12 +96,6 @@ func IsValidFile(file string) bool {
return true
}

// IsValidReporterType checks if the reporter type is valid.
func IsValidReporterType(t string) bool {
t = strings.ToLower(strings.TrimSpace(t))
return t == reporterTypeSSL
}

// IsValidEc2MetadataTimeout checks if the timeout is within the designated range
func IsValidEc2MetadataTimeout(t int) bool {
return t >= 0 && t <= 3000
Expand Down
10 changes: 0 additions & 10 deletions internal/config/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ func TestIsValidTracingMode(t *testing.T) {
assert.Equal(t, false, IsValidTracingMode("NEVER"))
}

func TestIsValidReporterType(t *testing.T) {
assert.Equal(t, false, IsValidReporterType("udp"))
assert.Equal(t, true, IsValidReporterType("ssl"))
assert.Equal(t, false, IsValidReporterType("Udp"))
assert.Equal(t, false, IsValidReporterType("xxx"))
assert.Equal(t, false, IsValidReporterType(""))
assert.Equal(t, false, IsValidReporterType("udpabc"))
assert.Equal(t, false, IsValidReporterType("serverless"))
}

func TestConverters(t *testing.T) {
assert.Equal(t, DisabledTracingMode, NormalizeTracingMode("disabled"))
assert.Equal(t, DisabledTracingMode, NormalizeTracingMode("never"))
Expand Down
3 changes: 0 additions & 3 deletions internal/config/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ var GetServiceKey = conf.GetServiceKey
// GetTrustedPath is a wrapper to the method of the global config
var GetTrustedPath = conf.GetTrustedPath

// GetReporterType is a wrapper to the method of the global config
var GetReporterType = conf.GetReporterType

// GetTracingMode is a wrapper to the method of the global config
var GetTracingMode = conf.GetTracingMode

Expand Down
7 changes: 4 additions & 3 deletions internal/reporter/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ package reporter
import (
"context"
"fmt"
"strings"
"time"

"github.com/pkg/errors"
"github.com/solarwinds/apm-go/internal/config"
"github.com/solarwinds/apm-go/internal/log"
Expand All @@ -29,8 +32,6 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/resource"
"go.opentelemetry.io/otel/trace"
"strings"
"time"
)

// defines what methods a Reporter should offer (internal to Reporter package)
Expand Down Expand Up @@ -88,7 +89,7 @@ func initReporter(r *resource.Resource, registry metrics.LegacyRegistry, o oboe.
log.Warning("SolarWinds Observability APM agent is disabled.")
rt = "none"
} else {
rt = config.GetReporterType()
rt = "ssl"
}
otelServiceName := ""
if sn, ok := r.Set().Value(semconv.ServiceNameKey); ok {
Expand Down

0 comments on commit 75eab4c

Please sign in to comment.