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

Update Husky to latest #505

Merged
merged 1 commit into from
Sep 7, 2022
Merged
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: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/hashicorp/golang-lru v0.5.4
github.com/honeycombio/dynsampler-go v0.2.1
github.com/honeycombio/husky v0.10.6
github.com/honeycombio/husky v0.15.0
github.com/honeycombio/libhoney-go v1.16.0
github.com/jessevdk/go-flags v1.5.0
github.com/json-iterator/go v1.1.12
Expand Down Expand Up @@ -45,6 +45,7 @@ require (
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
Expand Down
7 changes: 5 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ github.com/go-playground/validator v9.31.0+incompatible/go.mod h1:yrEkQXlcI+Pugk
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -180,6 +181,8 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.1 h1:/sDbPb60SusIXjiJGYLUoS/rAQurQmvGWmwn2bBPM9c=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.1/go.mod h1:G+WkljZi4mflcqVxYSgvt8MNctRQHjEH8ubKtt1Ka3w=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
Expand All @@ -188,8 +191,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/honeycombio/dynsampler-go v0.2.1 h1:IbhjbdB0IbLSZn7xVYuk6jjk/ZDk/EO+DJ5OXFZliv8=
github.com/honeycombio/dynsampler-go v0.2.1/go.mod h1:BOeTUPT6fCRH5X/+QqF6Kza3IyLp9uSq/rWgEtI4aZI=
github.com/honeycombio/husky v0.10.6 h1:jU/lXqo7Qz6e9eUJErIH3Lst2gjKWSJ4oAXYjFSXkn0=
github.com/honeycombio/husky v0.10.6/go.mod h1:i69+3xApIcsQn9PPeFRndTOOw6edNG66TxTTd+L6oq0=
github.com/honeycombio/husky v0.15.0 h1:RuYmKC1jHSB6y3C7pSXf889w8AaSzZ1JkIkLaiXlC5o=
github.com/honeycombio/husky v0.15.0/go.mod h1:ZO2AzJnnJkUoXbIQ5qLCvQuWdQOG/BZEup8pf2y5ua0=
github.com/honeycombio/libhoney-go v1.16.0 h1:kPpqoz6vbOzgp7jC6SR7SkNj7rua7rgxvznI6M3KdHc=
github.com/honeycombio/libhoney-go v1.16.0/go.mod h1:izP4fbREuZ3vqC4HlCAmPrcPT9gxyxejRjGtCYpmBn0=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
2 changes: 1 addition & 1 deletion route/otlp_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
huskyotlp "github.com/honeycombio/husky/otlp"
"github.com/honeycombio/refinery/types"

collectortrace "go.opentelemetry.io/proto/otlp/collector/trace/v1"
collectortrace "github.com/honeycombio/husky/proto/otlp/collector/trace/v1"
)

func (router *Router) postOTLP(w http.ResponseWriter, req *http.Request) {
Expand Down
49 changes: 31 additions & 18 deletions route/otlp_trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ import (
"time"

huskyotlp "github.com/honeycombio/husky/otlp"
collectortrace "github.com/honeycombio/husky/proto/otlp/collector/trace/v1"
common "github.com/honeycombio/husky/proto/otlp/common/v1"
resource "github.com/honeycombio/husky/proto/otlp/resource/v1"
trace "github.com/honeycombio/husky/proto/otlp/trace/v1"
"github.com/honeycombio/refinery/config"
"github.com/honeycombio/refinery/logger"
"github.com/honeycombio/refinery/metrics"
"github.com/honeycombio/refinery/transmit"
"github.com/klauspost/compress/zstd"
"github.com/stretchr/testify/assert"
collectortrace "go.opentelemetry.io/proto/otlp/collector/trace/v1"
common "go.opentelemetry.io/proto/otlp/common/v1"
resource "go.opentelemetry.io/proto/otlp/resource/v1"
trace "go.opentelemetry.io/proto/otlp/trace/v1"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)

Expand Down Expand Up @@ -67,7 +68,7 @@ func TestOTLPHandler(t *testing.T) {
t.Run("span with status", func(t *testing.T) {
req := &collectortrace.ExportTraceServiceRequest{
ResourceSpans: []*trace.ResourceSpans{{
InstrumentationLibrarySpans: []*trace.InstrumentationLibrarySpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: helperOTLPRequestSpansWithStatus(),
}},
}},
Expand All @@ -83,7 +84,7 @@ func TestOTLPHandler(t *testing.T) {
t.Run("span without status", func(t *testing.T) {
req := &collectortrace.ExportTraceServiceRequest{
ResourceSpans: []*trace.ResourceSpans{{
InstrumentationLibrarySpans: []*trace.InstrumentationLibrarySpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: helperOTLPRequestSpansWithoutStatus(),
}},
}},
Expand All @@ -105,7 +106,7 @@ func TestOTLPHandler(t *testing.T) {
spanID := []byte{1, 0, 0, 0, 0}
req := &collectortrace.ExportTraceServiceRequest{
ResourceSpans: []*trace.ResourceSpans{{
InstrumentationLibrarySpans: []*trace.InstrumentationLibrarySpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: []*trace.Span{{
TraceId: traceID,
SpanId: spanID,
Expand Down Expand Up @@ -153,7 +154,7 @@ func TestOTLPHandler(t *testing.T) {

req := &collectortrace.ExportTraceServiceRequest{
ResourceSpans: []*trace.ResourceSpans{{
InstrumentationLibrarySpans: []*trace.InstrumentationLibrarySpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: []*trace.Span{{
Name: "span_with_link",
TraceId: traceID,
Expand Down Expand Up @@ -191,7 +192,7 @@ func TestOTLPHandler(t *testing.T) {
t.Run("can receive OTLP over HTTP/protobuf", func(t *testing.T) {
req := &collectortrace.ExportTraceServiceRequest{
ResourceSpans: []*trace.ResourceSpans{{
InstrumentationLibrarySpans: []*trace.InstrumentationLibrarySpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: helperOTLPRequestSpansWithStatus(),
}},
}},
Expand All @@ -218,7 +219,7 @@ func TestOTLPHandler(t *testing.T) {
t.Run("can receive OTLP over HTTP/protobuf with gzip encoding", func(t *testing.T) {
req := &collectortrace.ExportTraceServiceRequest{
ResourceSpans: []*trace.ResourceSpans{{
InstrumentationLibrarySpans: []*trace.InstrumentationLibrarySpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: helperOTLPRequestSpansWithStatus(),
}},
}},
Expand Down Expand Up @@ -254,7 +255,7 @@ func TestOTLPHandler(t *testing.T) {
t.Run("can receive OTLP over HTTP/protobuf with zstd encoding", func(t *testing.T) {
req := &collectortrace.ExportTraceServiceRequest{
ResourceSpans: []*trace.ResourceSpans{{
InstrumentationLibrarySpans: []*trace.InstrumentationLibrarySpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: helperOTLPRequestSpansWithStatus(),
}},
}},
Expand Down Expand Up @@ -290,19 +291,31 @@ func TestOTLPHandler(t *testing.T) {
mockTransmission.Flush()
})

t.Run("rejects OTLP over HTTP/JSON ", func(t *testing.T) {
request, _ := http.NewRequest("POST", "/v1/traces", strings.NewReader("{}"))
t.Run("accepts OTLP over HTTP/JSON ", func(t *testing.T) {
req := &collectortrace.ExportTraceServiceRequest{
ResourceSpans: []*trace.ResourceSpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: helperOTLPRequestSpansWithStatus(),
}},
}},
}
body, err := protojson.Marshal(req)
if err != nil {
t.Error(err)
}

request, _ := http.NewRequest("POST", "/v1/traces", bytes.NewReader(body))
request.Header = http.Header{}
request.Header.Set("content-type", "application/json")
request.Header.Set("x-honeycomb-team", legacyAPIKey)
request.Header.Set("x-honeycomb-dataset", "dataset")

w := httptest.NewRecorder()
router.postOTLP(w, request)
assert.Equal(t, w.Code, http.StatusNotImplemented)
assert.Equal(t, `{"source":"refinery","error":"invalid content-type - only 'application/protobuf' is supported"}`, string(w.Body.String()))
assert.Equal(t, w.Code, http.StatusOK)
assert.Equal(t, "", w.Body.String())

assert.Equal(t, 0, len(mockTransmission.Events))
assert.Equal(t, 2, len(mockTransmission.Events))
mockTransmission.Flush()
})

Expand All @@ -317,7 +330,7 @@ func TestOTLPHandler(t *testing.T) {
{Key: "service.name", Value: &common.AnyValue{Value: &common.AnyValue_StringValue{StringValue: "my-service"}}},
},
},
InstrumentationLibrarySpans: []*trace.InstrumentationLibrarySpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: []*trace.Span{{
Name: "my-span",
}},
Expand Down Expand Up @@ -350,7 +363,7 @@ func TestOTLPHandler(t *testing.T) {
{Key: "service.name", Value: &common.AnyValue{Value: &common.AnyValue_StringValue{StringValue: "my-service"}}},
},
},
InstrumentationLibrarySpans: []*trace.InstrumentationLibrarySpans{{
ScopeSpans: []*trace.ScopeSpans{{
Spans: []*trace.Span{{
Name: "my-span",
}},
Expand Down
2 changes: 1 addition & 1 deletion route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/honeycombio/refinery/transmit"
"github.com/honeycombio/refinery/types"

collectortrace "go.opentelemetry.io/proto/otlp/collector/trace/v1"
collectortrace "github.com/honeycombio/husky/proto/otlp/collector/trace/v1"
)

const (
Expand Down