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

[v2][adjuster] Implement function to get standard adjusters to operate on otlp format #6396

Merged
merged 8 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 4 additions & 4 deletions cmd/query/app/querysvc/adjuster/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var _ Adjuster = (*SpanHashDeduper)(nil)
//
// To ensure consistent hash codes, this adjuster should be executed after
// SortAttributesAndEvents, which normalizes the order of collections within the span.
func SpanHash() SpanHashDeduper {
return SpanHashDeduper{
func SpanHash() *SpanHashDeduper {
return &SpanHashDeduper{
marshaler: &ptrace.ProtoMarshaler{},
}
}
Expand All @@ -33,7 +33,7 @@ type SpanHashDeduper struct {
marshaler ptrace.Marshaler
}

func (s *SpanHashDeduper) Adjust(traces ptrace.Traces) {
func (s SpanHashDeduper) Adjust(traces ptrace.Traces) {
mahadzaryab1 marked this conversation as resolved.
Show resolved Hide resolved
spansByHash := make(map[uint64]ptrace.Span)
resourceSpans := traces.ResourceSpans()
for i := 0; i < resourceSpans.Len(); i++ {
Expand Down Expand Up @@ -70,7 +70,7 @@ func (s *SpanHashDeduper) Adjust(traces ptrace.Traces) {
}
}

func (s *SpanHashDeduper) computeHashCode(
func (s SpanHashDeduper) computeHashCode(
hashTrace ptrace.Traces,
) (uint64, error) {
b, err := s.marshaler.MarshalTraces(hashTrace)
Expand Down
22 changes: 22 additions & 0 deletions cmd/query/app/querysvc/adjuster/standard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package adjuster

import (
"time"
)

// StandardAdjusters returns a list of adjusters applied by the query service
// before returning the data to the API clients.
func StandardAdjusters(maxClockSkewAdjust time.Duration) []Adjuster {
return []Adjuster{
SpanIDUniquifier(),
SortAttributesAndEvents(),
SpanHash(), // requires SortAttributesAndEvents for deterministic results
ClockSkew(maxClockSkewAdjust), // adds warnings (which affect SpanHash) on duplicate span IDs
IPAttribute(),
ResourceAttributes(),
SpanLinks(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider renaming these adjusters to reflect the business function. Reading this list I can reasonably guess what the first two are doing, plus ClockSkew. But all others are poorly named.

My suggestion would be to use verbs that describe the function, e.g.

  • DedupeClientServerSpanIDs
  • SortAttributes
  • DedupeSpans
  • etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro Done. Let me know what you think

}
}
25 changes: 25 additions & 0 deletions cmd/query/app/querysvc/adjuster/standard_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package adjuster

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
)

func TestStandardAdjusters(t *testing.T) {
maxClockSkewAdjust := 10 * time.Second
adjusters := StandardAdjusters(maxClockSkewAdjust)

assert.Len(t, adjusters, 7, "Expected 7 adjusters")
assert.IsType(t, SpanIDUniquifier(), adjusters[0])
assert.IsType(t, SortAttributesAndEvents(), adjusters[1])
assert.IsType(t, SpanHash(), adjusters[2])
assert.IsType(t, ClockSkew(maxClockSkewAdjust), adjusters[3])
assert.IsType(t, IPAttribute(), adjusters[4])
assert.IsType(t, ResourceAttributes(), adjusters[5])
assert.IsType(t, SpanLinks(), adjusters[6])
}
Loading