Skip to content

Commit

Permalink
Remove unecessary code
Browse files Browse the repository at this point in the history
Signed-off-by: chahatsagarmain <[email protected]>
  • Loading branch information
chahatsagarmain committed Jan 18, 2025
1 parent c6d70f8 commit 79b0d92
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.
2 changes: 1 addition & 1 deletion cmd/collector/app/sanitizer/hash_sanitizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestHashingSanitizer(t *testing.T) {
SpanID: model.SpanID(2),
Tags: []model.KeyValue{
{
Key: jptrace.HashAttribute,
Key: jptrace.HashAttribute,
VType: model.ValueType_INT64,
VInt64: 12345,
},
Expand Down
24 changes: 0 additions & 24 deletions cmd/jaeger/internal/sanitizer/hash_sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
package sanitizer

import (
"hash/fnv"
"unsafe"

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

"github.com/jaegertracing/jaeger/internal/jptrace"
Expand Down Expand Up @@ -48,24 +45,3 @@ func hashingSanitizer(traces ptrace.Traces) ptrace.Traces {

return traces
}

func computeHashCode(hashTrace ptrace.Traces, marshaler ptrace.Marshaler) (uint64, ptrace.Span, error) {
b, err := marshaler.MarshalTraces(hashTrace)
if err != nil {
return 0, ptrace.Span{}, err
}
hasher := fnv.New64a()
hasher.Write(b)
hash := hasher.Sum64()

span := hashTrace.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0)

attrs := span.Attributes()
attrs.PutInt(jptrace.HashAttribute, uint64ToInt64Bits(hash))

return hash, span, nil
}

func uint64ToInt64Bits(value uint64) int64 {
return *(*int64)(unsafe.Pointer(&value))
}
9 changes: 5 additions & 4 deletions cmd/jaeger/internal/sanitizer/hash_sanitizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ func TestHashingSanitizer(t *testing.T) {
hashAttr, exists := span.Attributes().Get(jptrace.HashAttribute)

require.True(t, exists, "hash should be added")
fmt.Printf("%v",hashAttr.Type())
fmt.Printf("%v", hashAttr.Type())
assert.Equal(t, pcommon.ValueTypeInt, hashAttr.Type())
})
}

func TestComputeHashCode(t *testing.T) {
t.Run("successful hash computation", func(t *testing.T) {
traces := createTestTraces()
marshaler := &ptrace.ProtoMarshaler{}

hash, span, err := computeHashCode(traces, marshaler)
spanHasher := jptrace.NewSpanHasher()

hash, err := spanHasher.SpanHash(traces)
span := traces.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0)
span.Attributes().PutInt(jptrace.HashAttribute, hash)
require.NoError(t, err)
assert.NotZero(t, hash)

Expand Down

0 comments on commit 79b0d92

Please sign in to comment.