Skip to content

Commit

Permalink
Expose OTLP -> Jaeger converter for use in trace ingest (#44)
Browse files Browse the repository at this point in the history
* tidy go.mod/sum

* Export OTLP->Jaeger conversion func for use with GRPC
  • Loading branch information
benkeith-splunk authored Sep 23, 2021
1 parent df84cc1 commit 950be06
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ require (
github.com/pavius/impi v0.0.3
github.com/stretchr/testify v1.7.0
go.opencensus.io v0.23.0
google.golang.org/grpc v1.33.2
honnef.co/go/tools v0.1.2
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@ google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBr
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
Expand All @@ -1106,6 +1107,7 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand Down
2 changes: 1 addition & 1 deletion otlp/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ func ParseRequest(req *http.Request) (*splunksapm.PostSpansRequest, error) {
if err := sapmprotocol.ParseSapmRequest(req, &otlp); err != nil {
return nil, err
}
return otlpToSAPM(otlp)
return ToSAPM(otlp)
}
4 changes: 2 additions & 2 deletions otlp/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
otlptrace "github.com/signalfx/sapm-proto/gen/otlp/trace/v1"
)

// otlpToSAPM translates otlp trace proto into the SAPM Proto.
func otlpToSAPM(td otlpcoltrace.ExportTraceServiceRequest) (*splunksapm.PostSpansRequest, error) {
// ToSAPM translates otlp trace proto into the SAPM Proto.
func ToSAPM(td otlpcoltrace.ExportTraceServiceRequest) (*splunksapm.PostSpansRequest, error) {
sapm := &splunksapm.PostSpansRequest{}
if len(td.ResourceSpans) == 0 {
return sapm, nil
Expand Down
4 changes: 2 additions & 2 deletions otlp/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ func TestInternalTracesToJaegerProto(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
jbs, err := otlpToSAPM(test.td)
jbs, err := ToSAPM(test.td)
if test.hasErr {
assert.Error(t, err)
assert.Nil(t, jbs)
Expand Down Expand Up @@ -770,7 +770,7 @@ func BenchmarkInternalTracesToJaegerProto(b *testing.B) {

b.ResetTimer()
for n := 0; n < b.N; n++ {
_, err := otlpToSAPM(td)
_, err := ToSAPM(td)
assert.NoError(b, err)
}
}
Expand Down

0 comments on commit 950be06

Please sign in to comment.