-
Notifications
You must be signed in to change notification settings - Fork 812
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: Rename Labels to Attributes #2523
feat: Rename Labels to Attributes #2523
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2523 +/- ##
=======================================
Coverage 93.00% 93.00%
=======================================
Files 138 138
Lines 5092 5092
Branches 1095 1095
=======================================
Hits 4736 4736
Misses 356 356
|
experimental/packages/opentelemetry-api-metrics/src/types/Metric.ts
Outdated
Show resolved
Hide resolved
I'm converting it back to draft just to be sure its not merged before #2496 |
I'm wondering if it can be easier to review if the PR can be split into two PRs: one for renaming and one for attribute value type changes. |
fb6c327
to
e11d308
Compare
Sorry for the delay, I think it should be ready for review now! |
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.
Kind of large PR but seems pretty straightforward. Thanks for doing the work.
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.
👍
@@ -14,17 +14,17 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
import { Labels } from './Metric'; | |||
import { Attributes } from './Metric'; |
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.
According to spec, the attribute interface is now shared between metric and trace. Should we just use the Attributes from the 1.0 API?
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.
That makes sense, but I believe this should happen in a follow-up PR. I assume there will be some breaking changes, especially with #2554 and open-telemetry/opentelemetry-proto#342 (including removing the deprecated labels field) coming up. I am not sure how to best navigate that change, as it seems quite big. I think what needs to happen for that to work is:
- Update the Proto to the latest version (as the currently referenced version does not have attributes yet)
- Either update the hand-rolled proto implementation, or set up a way of auto-generating JS code from the proto directly.
- Then we can update the actual reference of what were labels before to the new attributes.
These things are only somewhat related to the renaming of Labels
to Attributes
, but without updating the underlying data structures as well as the code, I am not sure we can make this change without breaking the code or tests.
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.
Sounds good. I'll create a follow up story for that.
hold off on updating labels to attributes until the proto is updated
e11d308
to
4d65142
Compare
@open-telemetry/javascript-maintainers would like one more 👀 at this before merge. It's a simple rename so I think it's pretty safe but I might have missed something. |
@@ -15,7 +15,7 @@ | |||
*/ | |||
|
|||
import { SpanAttributes, HrTime } from '@opentelemetry/api'; | |||
import { Labels, ValueType } from '@opentelemetry/api-metrics'; | |||
import { Attributes as Labels, ValueType } from '@opentelemetry/api-metrics'; |
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.
Newbie question. On line 30-39 it would not change?
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.
I left it as Labels
in this case, since its using the types defined for the 0.6.0 proto (until #2586 is done, probably). The field is called labels
in the TS representation of the protobuf, so I kept it that way.
This one is good to go? |
Yes |
Which problem is this PR solving?
The
opentelemetry-exporter-otlp-http
package uses the Proto definitions in version 0.6.0 (https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v0.6.0). This release does not have the Attributes field yet. I did not want to update the proto in this PR, since that would also mean updating the hand-rolled implementation in https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-exporter-otlp-http/src/types.ts, which would make this change much more than a renaming. This is due to breaking changes released in 0.8.0 of the Proto, where the serialization of some instruments to OTLP was changed (see open-telemetry/opentelemetry-proto@v0.6.0...v0.8.0, metrics.proto, line 125 and below). Additionally, #2554 proposes using a shared proto impl, maybe even auto-generated from the proto files. Therefore, theopentelemetry-exporter-otlp-http
package is in an intermediate state, where it, in some cases, uses attributes, but still exports lables, due to the old proto version.Short description of the changes