-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] Change
TraceQueryParams
to accept typed attributes (#6780)
## Which problem is this PR solving? - Towards #6765 ## Description of the changes - Updates `TraceQueryParams` to change the `Attributes` field from a `map[string]string` to `pcommon.Map` to accept typed attributes to match the Remote Storage API v2 being developed as part of #6629 ## How was this change tested? - CI ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] 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: Mahad Zaryab <[email protected]>
- Loading branch information
1 parent
1c99aa0
commit 043b826
Showing
13 changed files
with
221 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package jptrace | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.opentelemetry.io/collector/pdata/pcommon" | ||
) | ||
|
||
func TestAttributesToMap(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
attributes pcommon.Map | ||
expected map[string]string | ||
}{ | ||
{ | ||
name: "empty attributes", | ||
attributes: pcommon.NewMap(), | ||
expected: map[string]string{}, | ||
}, | ||
{ | ||
name: "single attribute", | ||
attributes: func() pcommon.Map { | ||
m := pcommon.NewMap() | ||
m.PutStr("key1", "value1") | ||
return m | ||
}(), | ||
expected: map[string]string{"key1": "value1"}, | ||
}, | ||
{ | ||
name: "multiple attributes", | ||
attributes: func() pcommon.Map { | ||
m := pcommon.NewMap() | ||
m.PutStr("key1", "value1") | ||
m.PutStr("key2", "value2") | ||
return m | ||
}(), | ||
expected: map[string]string{"key1": "value1", "key2": "value2"}, | ||
}, | ||
{ | ||
name: "non-string attributes", | ||
attributes: func() pcommon.Map { | ||
m := pcommon.NewMap() | ||
m.PutInt("key1", 1) | ||
m.PutDouble("key2", 3.14) | ||
return m | ||
}(), | ||
expected: map[string]string{"key1": "1", "key2": "3.14"}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
result := AttributesToMap(test.attributes) | ||
assert.Equal(t, test.expected, result) | ||
}) | ||
} | ||
} | ||
|
||
func TestMapToAttributes(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
tags map[string]string | ||
expected pcommon.Map | ||
}{ | ||
{ | ||
name: "empty map", | ||
tags: map[string]string{}, | ||
expected: pcommon.NewMap(), | ||
}, | ||
{ | ||
name: "single tag", | ||
tags: map[string]string{"key1": "value1"}, | ||
expected: func() pcommon.Map { | ||
m := pcommon.NewMap() | ||
m.PutStr("key1", "value1") | ||
return m | ||
}(), | ||
}, | ||
{ | ||
name: "multiple tags", | ||
tags: map[string]string{"key1": "value1", "key2": "value2"}, | ||
expected: func() pcommon.Map { | ||
m := pcommon.NewMap() | ||
m.PutStr("key1", "value1") | ||
m.PutStr("key2", "value2") | ||
return m | ||
}(), | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
result := MapToAttributes(test.tags) | ||
assert.Equal(t, test.expected, result) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.