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

Additional model/ cleanup #6610

Merged
merged 4 commits into from
Jan 25, 2025
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
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ linters-settings:
desc: "Use errors.Join instead of github.com/hashicorp/go-multierror"
- pkg: go.uber.org/multierr
desc: "Use errors.Join instead of github.com/hashicorp/go-multierror"
- pkg: "github.com/jaegertracing/jaeger/model$"
desc: "Use github.com/jaegertracing/jaeger-idl/model/v1"
# crossdock-go provides assert/require similar to stretchr/testify
# but we never want to use them outside of the crossdock tests.
disallow-crossdock:
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Protobuf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PROTO_GOGO_MAPPINGS := $(shell echo \
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types \
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types \
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api \
Mmodel.proto=github.com/jaegertracing/jaeger/model \
Mmodel.proto=github.com/jaegertracing/jaeger-idl/model/v1 \
| $(SED) 's/ */,/g')

OPENMETRICS_PROTO_FILES=$(wildcard model/proto/metrics/*.proto)
Expand Down
4 changes: 2 additions & 2 deletions cmd/jaeger/internal/integration/trace_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"google.golang.org/grpc/status"

"github.com/jaegertracing/jaeger/internal/proto/api_v3"
OTELModel "github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/pkg/iter"
"github.com/jaegertracing/jaeger/ports"
"github.com/jaegertracing/jaeger/storage/spanstore"
"github.com/jaegertracing/jaeger/storage_v2/tracestore"
"github.com/jaegertracing/jaeger/storage_v2/v1adapter"
)

var (
Expand Down Expand Up @@ -68,7 +68,7 @@ func (r *traceReader) GetTraces(
return func(yield func([]ptrace.Traces, error) bool) {
// api_v3 does not support multi-get, so loop through IDs
for _, idParams := range traceIDs {
idStr := OTELModel.TraceIDFromOTEL(idParams.TraceID).String()
idStr := v1adapter.ToV1TraceID(idParams.TraceID).String()
r.logger.Info("Calling api_v3.GetTrace", zap.String("trace_id", idStr))
stream, err := r.client.GetTrace(ctx, &api_v3.GetTraceRequest{
TraceId: idStr,
Expand Down
4 changes: 2 additions & 2 deletions cmd/query/app/apiv3/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
"github.com/jaegertracing/jaeger-idl/model/v1"
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc/v2/querysvc"
"github.com/jaegertracing/jaeger/internal/proto/api_v3"
OTELModel "github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/pkg/iter"
"github.com/jaegertracing/jaeger/storage_v2/tracestore"
"github.com/jaegertracing/jaeger/storage_v2/v1adapter"
)

// Handler implements api_v3.QueryServiceServer
Expand All @@ -38,7 +38,7 @@ func (h *Handler) GetTrace(request *api_v3.GetTraceRequest, stream api_v3.QueryS
query := querysvc.GetTraceParams{
TraceIDs: []tracestore.GetTraceParams{
{
TraceID: OTELModel.ToOTELTraceID(traceID),
TraceID: v1adapter.FromV1TraceID(traceID),
Start: request.GetStartTime(),
End: request.GetEndTime(),
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/query/app/apiv3/http_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"github.com/jaegertracing/jaeger-idl/model/v1"
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc/v2/querysvc"
"github.com/jaegertracing/jaeger/internal/proto/api_v3"
OTELModel "github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/pkg/iter"
"github.com/jaegertracing/jaeger/storage/spanstore"
"github.com/jaegertracing/jaeger/storage_v2/tracestore"
"github.com/jaegertracing/jaeger/storage_v2/v1adapter"
)

const (
Expand Down Expand Up @@ -162,7 +162,7 @@ func (h *HTTPGateway) getTrace(w http.ResponseWriter, r *http.Request) {
request := querysvc.GetTraceParams{
TraceIDs: []tracestore.GetTraceParams{
{
TraceID: OTELModel.ToOTELTraceID(traceID),
TraceID: v1adapter.FromV1TraceID(traceID),
},
},
}
Expand Down
5 changes: 0 additions & 5 deletions model/ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
modelv1 "github.com/jaegertracing/jaeger-idl/model/v1"
)

const (
// traceIDShortBytesLen indicates length of 64bit traceID when represented as list of bytes
traceIDShortBytesLen = 8
)

// TraceID is a random 128bit identifier for a trace
type TraceID = modelv1.TraceID

Expand Down
15 changes: 5 additions & 10 deletions model/keyvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ import (

// These constants are kept mostly for backwards compatibility.
const (
// StringType indicates the value is a unicode string
StringType = ValueType_STRING
// BoolType indicates the value is a Boolean encoded as int64 number 0 or 1
BoolType = ValueType_BOOL
// Int64Type indicates the value is an int64 number
Int64Type = ValueType_INT64
// Float64Type indicates the value is a float64 number stored as int64
Float64Type = ValueType_FLOAT64
// BinaryType indicates the value is binary blob stored as a byte array
BinaryType = ValueType_BINARY
StringType = modelv1.StringType
BoolType = modelv1.BoolType
Int64Type = modelv1.Int64Type
Float64Type = modelv1.Float64Type
BinaryType = modelv1.BinaryType

SpanKindKey = modelv1.SpanKindKey
SamplerTypeKey = modelv1.SamplerTypeKey
Expand Down
8 changes: 0 additions & 8 deletions model/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,4 @@ const (
SamplerTypeConst = modelv1.SamplerTypeConst
)

var toSamplerType = map[string]SamplerType{
"unrecognized": SamplerTypeUnrecognized,
"probabilistic": SamplerTypeProbabilistic,
"lowerbound": SamplerTypeLowerBound,
"ratelimiting": SamplerTypeRateLimiting,
"const": SamplerTypeConst,
}

var SpanKindTag = modelv1.SpanKindTag
17 changes: 0 additions & 17 deletions model/span_pkg_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions model/spanref.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
const (
// ChildOf span reference type describes a reference to a parent span
// that depends on the response from the current (child) span
ChildOf = SpanRefType_CHILD_OF
ChildOf = modelv1.ChildOf

// FollowsFrom span reference type describes a reference to a "parent" span
// that does not depend on the response from the current (child) span
FollowsFrom = SpanRefType_FOLLOWS_FROM
FollowsFrom = modelv1.FollowsFrom
)

// MaybeAddParentSpanID adds non-zero parentSpanID to refs as a child-of reference.
Expand Down
7 changes: 3 additions & 4 deletions plugin/storage/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/stretchr/testify/require"

"github.com/jaegertracing/jaeger-idl/model/v1"
OTELModel "github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/storage/samplingstore"
samplemodel "github.com/jaegertracing/jaeger/storage/samplingstore/model"
"github.com/jaegertracing/jaeger/storage/spanstore"
Expand Down Expand Up @@ -218,7 +217,7 @@ func (s *StorageIntegration) testGetLargeSpan(t *testing.T) {
t.Log("Testing Large Trace over 10K with duplicate IDs...")

expected := s.writeLargeTraceWithDuplicateSpanIds(t)
expectedTraceID := OTELModel.ToOTELTraceID(expected.Spans[0].TraceID)
expectedTraceID := v1adapter.FromV1TraceID(expected.Spans[0].TraceID)

actual := &model.Trace{} // no spans
found := s.waitForCondition(t, func(_ *testing.T) bool {
Expand Down Expand Up @@ -294,7 +293,7 @@ func (s *StorageIntegration) testGetTrace(t *testing.T) {
defer s.cleanUp(t)

expected := s.loadParseAndWriteExampleTrace(t)
expectedTraceID := OTELModel.ToOTELTraceID(expected.Spans[0].TraceID)
expectedTraceID := v1adapter.FromV1TraceID(expected.Spans[0].TraceID)

actual := &model.Trace{} // no spans
found := s.waitForCondition(t, func(t *testing.T) bool {
Expand All @@ -314,7 +313,7 @@ func (s *StorageIntegration) testGetTrace(t *testing.T) {
}

t.Run("NotFound error", func(t *testing.T) {
fakeTraceID := OTELModel.ToOTELTraceID(model.TraceID{High: 0, Low: 1})
fakeTraceID := v1adapter.FromV1TraceID(model.TraceID{High: 0, Low: 1})
iterTraces := s.TraceReader.GetTraces(context.Background(), tracestore.GetTraceParams{TraceID: fakeTraceID})
traces, err := v1adapter.V1TracesFromSeq2(iterTraces)
require.NoError(t, err) // v2 TraceReader no longer returns an error for not found
Expand Down
38 changes: 19 additions & 19 deletions proto-gen/storage_v1/storage.pb.go

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

3 changes: 3 additions & 0 deletions scripts/lint/check-go-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ check .golangci.yml "go:\s\+\"$version_regex\"" "$go_previous_version"

# find all other go.mod files in the repository and check for latest Go version
for file in $(find . -type f -name go.mod | grep -v '^./go.mod'); do
if [[ $file == "./idl/go.mod" ]]; then
continue
fi
check "$file" "^go\s\+$version_regex" "$go_latest_version"
done

Expand Down
25 changes: 15 additions & 10 deletions model/otelids.go → storage_v2/v1adapter/otelids.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,48 @@
// Copyright (c) 2018 Uber Technologies, Inc.
// SPDX-License-Identifier: Apache-2.0

package model
package v1adapter

import (
"encoding/binary"

"go.opentelemetry.io/collector/pdata/pcommon"

"github.com/jaegertracing/jaeger-idl/model/v1"
)

// ToOTELTraceID converts the TraceID to OTEL's representation of a trace identitfier.
// FromV1TraceID converts the TraceID to OTEL's representation of a trace identitfier.
// This was taken from
// https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/internal/coreinternal/idutils/big_endian_converter.go.
func ToOTELTraceID(t TraceID) pcommon.TraceID {
func FromV1TraceID(t model.TraceID) pcommon.TraceID {
traceID := [16]byte{}
binary.BigEndian.PutUint64(traceID[:8], t.High)
binary.BigEndian.PutUint64(traceID[8:], t.Low)
return traceID
}

func TraceIDFromOTEL(traceID pcommon.TraceID) TraceID {
return TraceID{
func ToV1TraceID(traceID pcommon.TraceID) model.TraceID {
// traceIDShortBytesLen indicates length of 64bit traceID when represented as list of bytes
const traceIDShortBytesLen = 8

return model.TraceID{
High: binary.BigEndian.Uint64(traceID[:traceIDShortBytesLen]),
Low: binary.BigEndian.Uint64(traceID[traceIDShortBytesLen:]),
}
}

// ToOTELSpanID converts the SpanID to OTEL's representation of a span identitfier.
// FromV1SpanID converts the SpanID to OTEL's representation of a span identitfier.
// This was taken from
// https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/internal/coreinternal/idutils/big_endian_converter.go.
func ToOTELSpanID(s SpanID) pcommon.SpanID {
func FromV1SpanID(s model.SpanID) pcommon.SpanID {
spanID := [8]byte{}
binary.BigEndian.PutUint64(spanID[:], uint64(s))
return pcommon.SpanID(spanID)
}

// ToOTELSpanID converts OTEL's SpanID to the model representation of a span identitfier.
// ToV1SpanID converts OTEL's SpanID to the model representation of a span identitfier.
// This was taken from
// https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/internal/coreinternal/idutils/big_endian_converter.go.
func SpanIDFromOTEL(spanID pcommon.SpanID) SpanID {
return SpanID(binary.BigEndian.Uint64(spanID[:]))
func ToV1SpanID(spanID pcommon.SpanID) model.SpanID {
return model.SpanID(binary.BigEndian.Uint64(spanID[:]))
}
Loading
Loading