-
Notifications
You must be signed in to change notification settings - Fork 847
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
feat(metrics-api): use common attributes definitions #3038
feat(metrics-api): use common attributes definitions #3038
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3038 +/- ##
==========================================
- Coverage 93.08% 93.08% -0.01%
==========================================
Files 188 188
Lines 6246 6243 -3
Branches 1313 1313
==========================================
- Hits 5814 5811 -3
Misses 432 432
|
c97d58a
to
a9c9eb9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM I just want to make sure I und
@@ -34,7 +34,7 @@ export function hashAttributes(attributes: MetricAttributes): string { | |||
keys = keys.sort(); | |||
return keys.reduce((result, key) => { | |||
if (result.length > 2) { | |||
result += ','; | |||
result += '|#'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure it is safe to use this as a separator if we're allowing string values? I think it is possible to collide hashes, but do we think it is sufficiently unlikely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For string values, it is always possible to collide before or after this change, like:
key1
=value1
, andkey2
=value2
, results in|#key1:value1,key2:value2
,key1
=value1,key2=value2
, also results in|#key1:value1,key2:value2
.
The change here is mainly to circumvent the string value of an array of strings, like ["value1", "value2"].toString()
is value1,value2
in which values are separated with ","
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to consider trying to make it impossible to collide? Or is this good enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what is in my mind now, it can be costly to do so. This hashing is very common across the operations in metrics SDK. I would be open to any improvements to this function but I'd be hesitant to make it a relatively costly one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dyladan I've updated the hash function to support arbitrary attribute values with JSON.stringify
. PTAL :)
Done. |
a9c9eb9
to
c4a10c0
Compare
c4a10c0
to
0545596
Compare
# Conflicts: # experimental/packages/otlp-transformer/test/metrics.test.ts
# Conflicts: # experimental/CHANGELOG.md
d1116a9
to
ab01df7
Compare
@dyladan I noticed that you removed this PR from the metrics GA milestone. Is there any specific reason to exclude this from metrics GA? |
I excluded all PRs from the milestone since they already have issues. It was distorting the %completion number |
Thank you for the explanation. Make sense to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 🙂
Thanks for working on this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I prefer the more robust hash even if it is slightly more costly.
Fixed tests introduced on the main branch which need to be updated accordingly in this PR. |
Which problem is this PR solving?
Use common attributes definitions.
Fixes #2585
Fixes #2587
Fixes #1482
Short description of the changes
Type of change
How Has This Been Tested?
hashAttributes
PrometheusSerializer
Checklist: