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][WIP] Span hash sanitizer and enhance span hash adjuster #6499

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
39 changes: 39 additions & 0 deletions cmd/collector/app/sanitizer/hash_sanitizer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2022 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package sanitizer

import (
"bytes"
"encoding/hex"

"github.com/jaegertracing/jaeger/model"
)

// NewHashingSanitizer creates a sanitizer to add hash field to spans
func NewHashingSanitizer() SanitizeSpan {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func NewHashingSanitizer() SanitizeSpan {
func AddHashTag() SanitizeSpan {

and similarly file name add_hash_tag

return hashingSanitizer
}

func hashingSanitizer(span *model.Span) *model.Span {
// Check if hash already exists
for _, tag := range span.Tags {
if tag.Key == "span.hash" {
return span
}

Check warning on line 23 in cmd/collector/app/sanitizer/hash_sanitizer.go

View check run for this annotation

Codecov / codecov/patch

cmd/collector/app/sanitizer/hash_sanitizer.go#L22-L23

Added lines #L22 - L23 were not covered by tests
}

buf := &bytes.Buffer{}
if err := span.Hash(buf); err != nil {
return span
}

Check warning on line 29 in cmd/collector/app/sanitizer/hash_sanitizer.go

View check run for this annotation

Codecov / codecov/patch

cmd/collector/app/sanitizer/hash_sanitizer.go#L28-L29

Added lines #L28 - L29 were not covered by tests

hashStr := hex.EncodeToString(buf.Bytes())
span.Tags = append(span.Tags, model.KeyValue{
Key: "span.hash",
VType: model.ValueType_STRING,
Copy link
Member

Choose a reason for hiding this comment

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

hard to evaluate this PR without seeing how it will be used in the storage backends. For example, is it really a string we want, or a number?

VStr: hashStr,
})

return span
}
1 change: 1 addition & 0 deletions cmd/collector/app/sanitizer/sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type SanitizeSpan func(span *model.Span) *model.Span
func NewStandardSanitizers() []SanitizeSpan {
return []SanitizeSpan{
NewEmptyServiceNameSanitizer(),
NewHashingSanitizer(),
Copy link
Member

@yurishkuro yurishkuro Jan 9, 2025

Choose a reason for hiding this comment

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

note: we also have v2 sanitizers, need to add this logic that as well.

./cmd/jaeger/internal/sanitizer

}
}

Expand Down
Loading