Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] AO-14906: remove the old udp reporter #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,8 @@ These environment variables may be set:
|APPOPTICS_DEBUG_LEVEL|No|WARN|Logging level to adjust the logging verbosity. Increase the logging verbosity to one of the debug levels to get more detailed information. Possible values: DEBUG, INFO, WARN, ERROR|
|APPOPTICS_HOSTNAME_ALIAS|No||A logical/readable hostname that can be used to easily identify the host|
|APPOPTICS_TRACING_MODE|No|enabled|Mode "enabled" will instruct AppOptics to consider sampling every inbound request for tracing. Mode "disabled" will disable tracing, and will neither start nor continue traces.|
|APPOPTICS_REPORTER|No|ssl|The reporter that will be used throughout the runtime of the app. Possible values: ssl, udp, none|
|APPOPTICS_REPORTER|No|ssl|The reporter that will be used throughout the runtime of the app. Possible values: ssl, none|
|APPOPTICS_COLLECTOR|No|collector.appoptics.com:443|SSL collector endpoint address and port (only used if APPOPTICS_REPORTER = ssl).|
|APPOPTICS_COLLECTOR_UDP|No|127.0.0.1:7831|UDP collector endpoint address and port (only used if APPOPTICS_REPORTER = udp).|
|APPOPTICS_TRUSTEDPATH|No||Path to the certificate used to verify the collector endpoint.|
|APPOPTICS_INSECURE_SKIP_VERIFY|No|true|Skip verification of the server's certificate chain and host name. Possible values: true, false|
|APPOPTICS_PREPEND_DOMAIN|No|false|Prepend the domain name to the transaction name. Possible values: true, false|
Expand Down
13 changes: 1 addition & 12 deletions v1/ao/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const (
envAppOpticsCollector = "APPOPTICS_COLLECTOR"
envAppOpticsServiceKey = "APPOPTICS_SERVICE_KEY"
envAppOpticsTrustedPath = "APPOPTICS_TRUSTEDPATH"
envAppOpticsCollectorUDP = "APPOPTICS_COLLECTOR_UDP"
envAppOpticsReporter = "APPOPTICS_REPORTER"
envAppOpticsTracingMode = "APPOPTICS_TRACING_MODE"
envAppOpticsSampleRate = "APPOPTICS_SAMPLE_RATE"
Expand Down Expand Up @@ -79,10 +78,7 @@ type Config struct {
// The file path of the cert file for gRPC connection
TrustedPath string `yaml:"TrustedPath,omitempty" env:"APPOPTICS_TRUSTEDPATH"`

// The host and port of the UDP collector
CollectorUDP string `yaml:"CollectorUDP,omitempty" env:"APPOPTICS_COLLECTOR_UDP"`

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

Sampling *SamplingConfig `yaml:"Sampling,omitempty"`
Expand Down Expand Up @@ -734,13 +730,6 @@ func (c *Config) GetReporterType() string {
return c.ReporterType
}

// GetCollectorUDP returns the UDP collector host
func (c *Config) GetCollectorUDP() string {
c.RLock()
defer c.RUnlock()
return c.CollectorUDP
}

// GetTracingMode returns the local tracing mode
func (c *Config) GetTracingMode() TracingMode {
c.RLock()
Expand Down
18 changes: 4 additions & 14 deletions v1/ao/internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ func TestLoadConfig(t *testing.T) {
os.Setenv(envAppOpticsHostnameAlias, "test")
os.Setenv(envAppOpticsInsecureSkipVerify, "false")
os.Setenv(envAppOpticsTrustedPath, "test.crt")
os.Setenv(envAppOpticsCollectorUDP, "hello.udp")
os.Setenv(envAppOpticsDisabled, "invalidValue")

c.Load()
assert.Equal(t, ToServiceKey(key1), c.GetServiceKey())
assert.Equal(t, "test", c.GetHostAlias())
assert.Equal(t, false, c.GetSkipVerify())
assert.Equal(t, "test.crt", filepath.Base(c.GetTrustedPath()))
assert.Equal(t, "hello.udp", c.GetCollectorUDP())
assert.Equal(t, false, c.GetDisabled())
}

Expand Down Expand Up @@ -120,7 +118,6 @@ func TestConfigInit(t *testing.T) {
Collector: defaultSSLCollector,
ServiceKey: "",
TrustedPath: "",
CollectorUDP: "",
ReporterType: "ssl",
Sampling: &SamplingConfig{
TracingMode: "enabled",
Expand Down Expand Up @@ -179,8 +176,6 @@ func TestEnvsLoading(t *testing.T) {
"APPOPTICS_COLLECTOR=collector.test.com",
"APPOPTICS_SERVICE_KEY=ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
"APPOPTICS_TRUSTEDPATH=/collector.crt",
"APPOPTICS_COLLECTOR_UDP=udp.test.com",
"APPOPTICS_REPORTER=udp",
"APPOPTICS_TRACING_MODE=never",
"APPOPTICS_SAMPLE_RATE=1000",
"APPOPTICS_PREPEND_DOMAIN=true",
Expand All @@ -202,8 +197,7 @@ func TestEnvsLoading(t *testing.T) {
Collector: "collector.test.com",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
TrustedPath: "/collector.crt",
CollectorUDP: "udp.test.com",
ReporterType: "udp",
ReporterType: "ssl",
Sampling: &SamplingConfig{
TracingMode: "disabled",
tracingModeConfigured: true,
Expand Down Expand Up @@ -246,8 +240,7 @@ func TestYamlConfig(t *testing.T) {
Collector: "yaml.test.com",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189218:go",
TrustedPath: "/yaml-collector.crt",
CollectorUDP: "yamludp.test.com",
ReporterType: "udp",
ReporterType: "ssl",
Sampling: &SamplingConfig{
TracingMode: "disabled",
tracingModeConfigured: true,
Expand Down Expand Up @@ -302,8 +295,7 @@ func TestYamlConfig(t *testing.T) {
"APPOPTICS_COLLECTOR=collector.test.com",
"APPOPTICS_SERVICE_KEY=ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
"APPOPTICS_TRUSTEDPATH=/collector.crt",
"APPOPTICS_COLLECTOR_UDP=udp.test.com",
"APPOPTICS_REPORTER=udp",
"APPOPTICS_REPORTER=ssl",
"APPOPTICS_TRACING_MODE=never",
"APPOPTICS_SAMPLE_RATE=1000",
"APPOPTICS_PREPEND_DOMAIN=true",
Expand All @@ -323,8 +315,7 @@ func TestYamlConfig(t *testing.T) {
Collector: "collector.test.com",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
TrustedPath: "/collector.crt",
CollectorUDP: "udp.test.com",
ReporterType: "udp",
ReporterType: "ssl",
Sampling: &SamplingConfig{
TracingMode: "disabled",
tracingModeConfigured: true,
Expand Down Expand Up @@ -429,7 +420,6 @@ func TestInvalidConfig(t *testing.T) {
Collector: "",
ServiceKey: "ae38315f6116585d64d82ec2455aa3ec61e02fee25d286f74ace9e4fea189217:go",
TrustedPath: "",
CollectorUDP: "",
ReporterType: "invalid",
Sampling: &SamplingConfig{
TracingMode: "disabled",
Expand Down
2 changes: 1 addition & 1 deletion v1/ao/internal/config/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func IsValidFile(file string) bool {
// IsValidReporterType checks if the reporter type is valid.
func IsValidReporterType(t string) bool {
t = strings.ToLower(strings.TrimSpace(t))
return t == "ssl" || t == "udp"
return t == "ssl" || t == "none"
}

// IsValidEc2MetadataTimeout checks if the timeout is within the designated range
Expand Down
2 changes: 0 additions & 2 deletions v1/ao/internal/config/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ func TestIsValidTracingMode(t *testing.T) {
}

func TestIsValidReporterType(t *testing.T) {
assert.Equal(t, true, IsValidReporterType("udp"))
assert.Equal(t, true, IsValidReporterType("ssl"))
assert.Equal(t, true, IsValidReporterType("Udp"))
assert.Equal(t, false, IsValidReporterType("xxx"))
assert.Equal(t, false, IsValidReporterType(""))
assert.Equal(t, false, IsValidReporterType("udpabc"))
Expand Down
3 changes: 0 additions & 3 deletions v1/ao/internal/config/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ var GetSampleRate = conf.GetSampleRate
// SamplingConfigured is a wrapper to the method of the global config
var SamplingConfigured = conf.SamplingConfigured

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

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

Expand Down
10 changes: 0 additions & 10 deletions v1/ao/internal/reporter/oboe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ func assertInitMessage(t *testing.T, bufs [][]byte) {
})
}

func TestInitMessageUDP(t *testing.T) {
assertUDPMode(t)

var bufs [][]byte
done := startTestUDPListener(t, &bufs, 2)
sendInitMessage()
<-done
assertInitMessage(t, bufs)
}

func TestTokenBucket(t *testing.T) {
b := newTokenBucket(5, 2)
c := b
Expand Down
7 changes: 2 additions & 5 deletions v1/ao/internal/reporter/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,11 @@ func setGlobalReporter(reporterType string) {

switch strings.ToLower(reporterType) {
case "ssl":
fallthrough // using fallthrough since the SSL reporter (gRPC) is our default reporter
default:
globalReporter = newGRPCReporter()
case "udp":
globalReporter = udpNewReporter()
case "none":
fallthrough
default:
globalReporter = newNullReporter()

}
}

Expand Down
60 changes: 1 addition & 59 deletions v1/ao/internal/reporter/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package reporter
import (
"context"
"io"
"net"
"os"
"reflect"
"testing"
Expand Down Expand Up @@ -135,67 +134,10 @@ func TestNullReporter(t *testing.T) {

}

// ========================= UDP Reporter =============================
func startTestUDPListener(t *testing.T, bufs *[][]byte, numbufs int) chan struct{} {
done := make(chan struct{})
assert.IsType(t, &udpReporter{}, globalReporter)

addr, err := net.ResolveUDPAddr("udp4", os.Getenv("APPOPTICS_COLLECTOR_UDP"))
assert.NoError(t, err)
conn, err := net.ListenUDP("udp4", addr)
assert.NoError(t, err)
go func(numBufs int) {
defer conn.Close()
for i := 0; i < numBufs; i++ {
buf := make([]byte, 128*1024)
n, _, err := conn.ReadFromUDP(buf)
t.Logf("Got UDP buf len %v err %v", n, err)
if err != nil {
t.Logf("UDP listener got err, quitting %v", err)
break
}
*bufs = append(*bufs, buf[0:n])
}
close(done)
t.Logf("Closing UDP listener, got %d bufs", numBufs)
}(numbufs)
return done
}

func assertUDPMode(t *testing.T) {
// for UDP mode run test like this:
// APPOPTICS_REPORTER=udp go test -v

if os.Getenv("APPOPTICS_REPORTER") != "udp" {
t.Skip("not running in UDP mode, skipping.")
}
}

func TestUDPReporter(t *testing.T) {
assertUDPMode(t)
assert.IsType(t, &udpReporter{}, globalReporter)

r := globalReporter.(*udpReporter)
ctx := newTestContext(t)
ev1, _ := ctx.newEvent(LabelInfo, testLayer)
ev2, _ := ctx.newEvent(LabelInfo, testLayer)

var bufs [][]byte
startTestUDPListener(t, &bufs, 2)

assert.Error(t, r.reportEvent(nil, nil))
assert.Error(t, r.reportEvent(ctx, nil))
assert.NoError(t, r.reportEvent(ctx, ev1))

assert.Error(t, r.reportStatus(nil, nil))
assert.Error(t, r.reportStatus(ctx, nil))
assert.NoError(t, r.reportStatus(ctx, ev2))
}

// ========================= GRPC Reporter =============================

func assertSSLMode(t *testing.T) {
if os.Getenv("APPOPTICS_REPORTER") == "udp" {
if os.Getenv("APPOPTICS_REPORTER") != "ssl" {
t.Skip("not running in SSL mode, skipping.")
}
}
Expand Down
105 changes: 0 additions & 105 deletions v1/ao/internal/reporter/reporter_udp.go

This file was deleted.