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

Replace usage of OpenTracing constants with OpenTelemetry in the domain model #4614

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 9 additions & 8 deletions model/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"io"
"strconv"

"github.com/opentracing/opentracing-go/ext"
"github.com/uber/jaeger-client-go"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"
)

Expand All @@ -34,6 +34,7 @@ const (
FirehoseFlag = Flags(8)

samplerType = "sampler.type"
keySpanKind = "span.kind"
samplerTypeUnknown = "unknown"
)

Expand All @@ -49,19 +50,19 @@ func (s *Span) Hash(w io.Writer) (err error) {
}

// HasSpanKind returns true if the span has a `span.kind` tag set to `kind`.
func (s *Span) HasSpanKind(kind ext.SpanKindEnum) bool {
if tag, ok := KeyValues(s.Tags).FindByKey(string(ext.SpanKind)); ok {
return tag.AsString() == string(kind)
func (s *Span) HasSpanKind(kind trace.SpanKind) bool {
if tag, ok := KeyValues(s.Tags).FindByKey(keySpanKind); ok {
return tag.AsString() == kind.String()
}
return false
}

// GetSpanKind returns value of `span.kind` tag and whether the tag can be found
func (s *Span) GetSpanKind() (spanKind string, found bool) {
if tag, ok := KeyValues(s.Tags).FindByKey(string(ext.SpanKind)); ok {
if tag, ok := KeyValues(s.Tags).FindByKey(keySpanKind); ok {
return tag.AsString(), true
}
return "", false
return trace.SpanKindUnspecified.String(), false
afzal442 marked this conversation as resolved.
Show resolved Hide resolved
}

// GetSamplerType returns the sampler type for span
Expand All @@ -79,13 +80,13 @@ func (s *Span) GetSamplerType() string {
// IsRPCClient returns true if the span represents a client side of an RPC,
// as indicated by the `span.kind` tag set to `client`.
func (s *Span) IsRPCClient() bool {
return s.HasSpanKind(ext.SpanKindRPCClientEnum)
return s.HasSpanKind(trace.SpanKindClient)
}

// IsRPCServer returns true if the span represents a server side of an RPC,
// as indicated by the `span.kind` tag set to `server`.
func (s *Span) IsRPCServer() bool {
return s.HasSpanKind(ext.SpanKindRPCServerEnum)
return s.HasSpanKind(trace.SpanKindServer)
}

// NormalizeTimestamps changes all timestamps in this span to UTC.
Expand Down
8 changes: 4 additions & 4 deletions model/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (

"github.com/gogo/protobuf/jsonpb"
"github.com/gogo/protobuf/proto"
"github.com/opentracing/opentracing-go/ext"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/model"
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestSpanIDUnmarshalJSONErrors(t *testing.T) {
func TestIsRPCClientServer(t *testing.T) {
span1 := &model.Span{
Tags: model.KeyValues{
model.String(string(ext.SpanKind), string(ext.SpanKindRPCClientEnum)),
model.String(string("span.kind"), trace.SpanKindClient.String()),
afzal442 marked this conversation as resolved.
Show resolved Hide resolved
},
}
assert.True(t, span1.IsRPCClient())
Expand Down Expand Up @@ -227,12 +227,12 @@ func TestIsFirehoseEnabled(t *testing.T) {
func TestGetSpanKind(t *testing.T) {
span := makeSpan(model.String("sampler.type", "lowerbound"))
spanKind, found := span.GetSpanKind()
assert.Equal(t, "", spanKind)
assert.Equal(t, trace.SpanKind.String(0), spanKind)
afzal442 marked this conversation as resolved.
Show resolved Hide resolved
assert.Equal(t, false, found)

span = makeSpan(model.String("span.kind", "client"))
spanKind, found = span.GetSpanKind()
assert.Equal(t, "client", spanKind)
assert.Equal(t, trace.SpanKind.String(3), spanKind)
assert.Equal(t, true, found)
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/cassandra/spanstore/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func TestStorageMode_IndexOnly_FirehoseSpan(t *testing.T) {
assert.Equal(t, "planet-express", serviceWritten.Load())
assert.Equal(t, dbmodel.Operation{
ServiceName: "planet-express",
SpanKind: "",
SpanKind: "unspecified",
OperationName: "package-delivery",
}, operationWritten.Load())
}, StoreIndexesOnly())
Expand Down