Skip to content

Commit

Permalink
Redefine model/ and api_v2/ types as aliases to jaeger-idl/ types (#6602
Browse files Browse the repository at this point in the history
)

## Which problem is this PR solving?
- part of #6595
- part of #6494

## Description of the changes
- change models

## How was this change tested?
- `make lint`, `make test`

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: nabil salah <[email protected]>
  • Loading branch information
Nabil-Salah authored Jan 24, 2025
1 parent 07e4f57 commit 5fa0297
Show file tree
Hide file tree
Showing 26 changed files with 365 additions and 10,334 deletions.
13 changes: 1 addition & 12 deletions Makefile.Protobuf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,12 @@ define proto_compile
endef

.PHONY: proto
proto: proto-model \
proto-api-v2 \
proto-storage-v1 \
proto: proto-storage-v1 \
proto-hotrod \
proto-zipkin \
proto-openmetrics \
proto-api-v3

.PHONY: proto-model
proto-model:
$(call proto_compile, model, idl/proto/api_v2/model.proto)
$(PROTOC) -Imodel/proto --go_out=$(PWD)/model/ model/proto/model_test.proto

API_V2_PATCHED_DIR=proto-gen/.patched/api_v2
.PHONY: patch-api-v2
Expand All @@ -99,11 +93,6 @@ patch-api-v2:
cp idl/proto/api_v2/sampling.proto $(API_V2_PATCHED_DIR)/
cat idl/proto/api_v2/query.proto | $(SED) 's|jaegertracing/jaeger-idl/model/v1.|jaegertracing/jaeger/model.|g' > $(API_V2_PATCHED_DIR)/query.proto

.PHONY: proto-api-v2
proto-api-v2: patch-api-v2
$(call proto_compile, proto-gen/api_v2, $(API_V2_PATCHED_DIR)/query.proto)
$(call proto_compile, proto-gen/api_v2, $(API_V2_PATCHED_DIR)/collector.proto)
$(call proto_compile, proto-gen/api_v2, $(API_V2_PATCHED_DIR)/sampling.proto)

.PHONY: proto-openmetrics
proto-openmetrics:
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jaegertracing/jaeger-idl v0.0.0-20250122172554-3e525d710892
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/ionos-cloud/sdk-go/v6 v6.1.11 h1:J/uRN4UWO3wCyGOeDdMKv8LWRzKu6UIkLEaes38Kzh8=
github.com/ionos-cloud/sdk-go/v6 v6.1.11/go.mod h1:EzEgRIDxBELvfoa/uBN0kOQaqovLjUWEB7iW4/Q+t4k=
github.com/jaegertracing/jaeger-idl v0.0.0-20250122172554-3e525d710892 h1:wDzNPLnnHOGCvGpLGn78gPo6Cqxpdil5TkS9dKfT2cE=
github.com/jaegertracing/jaeger-idl v0.0.0-20250122172554-3e525d710892/go.mod h1:TimiEKGlMAcMZsKSHJkXNo0I0Q39iaENPswLXA1I2XY=
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
Expand Down
15 changes: 5 additions & 10 deletions model/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@

package model

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

const (
// JaegerDependencyLinkSource describes a dependency diagram that was generated from Jaeger traces.
JaegerDependencyLinkSource = "jaeger"
JaegerDependencyLinkSource = modelv1.JaegerDependencyLinkSource
)

// ApplyDefaults applies defaults to the DependencyLink.
func (d DependencyLink) ApplyDefaults() DependencyLink {
dd := d
if dd.Source == "" {
dd.Source = JaegerDependencyLinkSource
}
return dd
}
6 changes: 0 additions & 6 deletions model/doc.go

This file was deleted.

54 changes: 8 additions & 46 deletions model/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,18 @@

package model

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

const (
// SampledFlag is the bit set in Flags in order to define a span as a sampled span
SampledFlag = Flags(1)
SampledFlag = modelv1.SampledFlag
// DebugFlag is the bit set in Flags in order to define a span as a debug span
DebugFlag = Flags(2)
DebugFlag = modelv1.SampledFlag
// FirehoseFlag is the bit in Flags in order to define a span as a firehose span
FirehoseFlag = Flags(8)
FirehoseFlag = modelv1.SampledFlag
)

// Flags is a bit map of flags for a span
type Flags uint32

// ------- Flags -------

// SetSampled sets the Flags as sampled
func (f *Flags) SetSampled() {
f.setFlags(SampledFlag)
}

// SetDebug set the Flags as sampled
func (f *Flags) SetDebug() {
f.setFlags(DebugFlag)
}

// SetFirehose set the Flags as firehose enabled
func (f *Flags) SetFirehose() {
f.setFlags(FirehoseFlag)
}

func (f *Flags) setFlags(bit Flags) {
*f |= bit
}

// IsSampled returns true if the Flags denote sampling
func (f Flags) IsSampled() bool {
return f.checkFlags(SampledFlag)
}

// IsDebug returns true if the Flags denote debugging
// Debugging can be useful in testing tracing availability or correctness
func (f Flags) IsDebug() bool {
return f.checkFlags(DebugFlag)
}

// IsFirehoseEnabled returns true if firehose is enabled
// Firehose is used to decide whether to index a span or not
func (f Flags) IsFirehoseEnabled() bool {
return f.checkFlags(FirehoseFlag)
}

func (f Flags) checkFlags(bit Flags) bool {
return f&bit == bit
}
type Flags = modelv1.Flags
15 changes: 3 additions & 12 deletions model/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,12 @@
package model

import (
"hash/fnv"
"io"
modelv1 "github.com/jaegertracing/jaeger-idl/model/v1"
)

// Hashable interface is for type that can participate in a hash computation
// by writing their data into io.Writer, which is usually an instance of hash.Hash.
type Hashable interface {
Hash(w io.Writer) error
}
type Hashable = modelv1.Hashable

// HashCode calculates a FNV-1a hash code for a Hashable object.
func HashCode(o Hashable) (uint64, error) {
h := fnv.New64a()
if err := o.Hash(h); err != nil {
return 0, err
}
return h.Sum64(), nil
}
var HashCode = modelv1.HashCode
Loading

0 comments on commit 5fa0297

Please sign in to comment.