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

Add OTLP ingest #202

Merged
merged 29 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
662a762
add opentelemtry-proto as internal package
MikeGoldsmith Jan 8, 2021
2d3d99c
add grpc server addr to config
MikeGoldsmith Jan 7, 2021
e3ad0c5
validate grpc listen addr config value if not empty
MikeGoldsmith Jan 7, 2021
321b43d
create grpc server in router
MikeGoldsmith Jan 8, 2021
3b92a6a
flesh out otlp export handler
MikeGoldsmith Jan 8, 2021
c4a8af3
register otlp export func with grpc server
MikeGoldsmith Jan 8, 2021
d84dec2
remove unused err check for grpc server
MikeGoldsmith Jan 8, 2021
73786af
fix config test typo
MikeGoldsmith Jan 8, 2021
c041d97
fix typo
MikeGoldsmith Jan 11, 2021
c58a30c
add extra grpc server settings
MikeGoldsmith Jan 13, 2021
1d4df3e
log reason why event failed to be processed
MikeGoldsmith Jan 13, 2021
076c089
only setup grpc for incoming requets, not for peers
MikeGoldsmith Jan 22, 2021
c142f63
refactor getting apikey and dataset into func with test
MikeGoldsmith Jan 22, 2021
516acd1
fix variable name
MikeGoldsmith Jan 22, 2021
04ae150
check library is not nil before trying to get name/version
MikeGoldsmith Jan 22, 2021
0dc5ca2
use case-insensitive loop to get apikey and dataset
MikeGoldsmith Jan 22, 2021
8722208
add GRPCListenAddr entry to config_complete.toml
MikeGoldsmith Jan 22, 2021
09081ff
update apikey and dataset header funcs
MikeGoldsmith Jan 22, 2021
29c9025
use md.Set to set values
MikeGoldsmith Jan 22, 2021
76c633b
update helper func description name
MikeGoldsmith Jan 22, 2021
680cddc
consolidate string empty checks to use len() > 0
MikeGoldsmith Jan 22, 2021
f58aa1b
extract retrieving sampleRate into separate func with tests
MikeGoldsmith Jan 22, 2021
1e13313
fix samplerate test struct field type
MikeGoldsmith Jan 22, 2021
260f71f
fix error format variable placeholders
MikeGoldsmith Jan 22, 2021
5045de7
Merge branch 'main' into mike/otlp
MikeGoldsmith Jan 22, 2021
0ea1e4a
fix bad merge conflict
MikeGoldsmith Jan 22, 2021
87e9055
remove unnecessary reload test
MikeGoldsmith Jan 22, 2021
2f9aa4e
consolidate grpcListAddr with listAddr
MikeGoldsmith Jan 22, 2021
eaaaa52
add comment for how requestID is used in OTLP handler
MikeGoldsmith Jan 25, 2021
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
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ type Config interface {
// peer traffic
GetPeerListenAddr() (string, error)

// GetGRPCListenAddr returns the address and port on which to listen for
// incoming events over gRPC
GetGRPCListenAddr() (string, error)

// GetAPIKeys returns a list of Honeycomb API keys
GetAPIKeys() ([]string, error)

Expand Down
10 changes: 9 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestReload(t *testing.T) {

dummy := []byte(`
ListenAddr="0.0.0.0:8080"
GRPCListenAddr="0.0.0.0:9090"

[InMemCollector]
CacheCapacity=1000
Expand All @@ -81,6 +82,9 @@ func TestReload(t *testing.T) {
if d, _ := c.GetListenAddr(); d != "0.0.0.0:8080" {
t.Error("received", d, "expected", "0.0.0.0:8080")
}
if d, _ := c.GetGRPCListenAddr(); d != "0.0.0.0:9090" {
t.Error("received", d, "expected", "0.0.0.0:9090")
}

wg := &sync.WaitGroup{}

Expand Down Expand Up @@ -118,6 +122,8 @@ func TestReload(t *testing.T) {

if file, err := os.OpenFile(configFile.Name(), os.O_RDWR, 0644); err == nil {
file.WriteString(`ListenAddr = "0.0.0.0:9000"`)
file.WriteString("\n")
file.WriteString(`GRPCListenAddr = "0.0.0.0:1010"`)
file.Close()
}

Expand All @@ -126,7 +132,9 @@ func TestReload(t *testing.T) {
if d, _ := c.GetListenAddr(); d != "0.0.0.0:9000" {
t.Error("received", d, "expected", "0.0.0.0:9000")
}

if d, _ := c.GetGRPCListenAddr(); d != "0.0.0.0:1010" {
t.Error("received", d, "expected", "0.0.0.0:1010")
}
}

func TestReadDefaults(t *testing.T) {
Expand Down
19 changes: 17 additions & 2 deletions config/file_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ func (r *RulesBasedSamplerConfig) String() string {
}

type configContents struct {
ListenAddr string `validate:"required"`
PeerListenAddr string `validate:"required"`
ListenAddr string `validate:"required"`
MikeGoldsmith marked this conversation as resolved.
Show resolved Hide resolved
PeerListenAddr string `validate:"required"`
GRPCListenAddr string
APIKeys []string `validate:"required"`
HoneycombAPI string `validate:"required,url"`
Logger string `validate:"required,oneof= logrus honeycomb"`
Expand Down Expand Up @@ -379,6 +380,20 @@ func (f *fileConfig) GetPeerListenAddr() (string, error) {
return f.conf.PeerListenAddr, nil
}

func (f *fileConfig) GetGRPCListenAddr() (string, error) {
f.mux.RLock()
defer f.mux.RUnlock()

// GRPC listen addr is optional, only check value is valid if not empty
if f.conf.GRPCListenAddr != "" {
_, _, err := net.SplitHostPort(f.conf.GRPCListenAddr)
if err != nil {
return "", err
}
}
return f.conf.GRPCListenAddr, nil
}

func (f *fileConfig) GetAPIKeys() ([]string, error) {
f.mux.RLock()
defer f.mux.RUnlock()
Expand Down
8 changes: 8 additions & 0 deletions config/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type MockConfig struct {
GetListenAddrVal string
GetPeerListenAddrErr error
GetPeerListenAddrVal string
GetGRPCListenAddrErr error
GetGRPCListenAddrVal string
GetLoggerTypeErr error
GetLoggerTypeVal string
GetHoneycombLoggerConfigErr error
Expand Down Expand Up @@ -114,6 +116,12 @@ func (m *MockConfig) GetPeerListenAddr() (string, error) {

return m.GetPeerListenAddrVal, m.GetPeerListenAddrErr
}
func (m *MockConfig) GetGRPCListenAddr() (string, error) {
m.Mux.RLock()
defer m.Mux.RUnlock()

return m.GetGRPCListenAddrVal, m.GetGRPCListenAddrErr
}
func (m *MockConfig) GetLoggerType() (string, error) {
m.Mux.RLock()
defer m.Mux.RUnlock()
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ require (
github.com/garyburd/redigo v1.6.0
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator v9.31.0+incompatible
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.4.3
github.com/gorilla/mux v1.6.3-0.20190108142930-08e7f807d38d
github.com/grpc-ecosystem/grpc-gateway v1.12.1
github.com/hashicorp/golang-lru v0.5.1
github.com/honeycombio/dynsampler-go v0.2.1
github.com/honeycombio/libhoney-go v1.12.4
Expand All @@ -35,6 +38,7 @@ require (
github.com/vmihailenco/msgpack/v4 v4.3.11
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6 // indirect
golang.org/x/text v0.3.3 // indirect
google.golang.org/grpc v1.32.0
gopkg.in/alexcesaro/statsd.v2 v2.0.0
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/ini.v1 v1.57.0 // indirect
Expand Down
44 changes: 44 additions & 0 deletions go.sum

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions internal/opentelemetry-proto-gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OTLP Protobuf Definitions

The definitions can be found [here](https://github.com/open-telemetry/opentelemetry-proto/tree/59c488bfb8fb6d0458ad6425758b70259ff4a2bd).

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading