-
Notifications
You must be signed in to change notification settings - Fork 20
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
Semconv codegen should produce different constant names if attribute is renamed _ -> `` #75
Semconv codegen should produce different constant names if attribute is renamed _ -> `` #75
Conversation
@@ -113,7 +113,7 @@ public static final class JvmMemoryTypeValues { | |||
public static final String HEAP = "heap"; | |||
|
|||
/** Non-heap memory. */ | |||
public static final String NON_HEAP = "non_heap"; | |||
public static final String NONHEAP = "non_heap"; |
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 apply this change here (and other values)?
/** Values for {@link #DB_CASSANDRA_CONSISTENCY_LEVEL}. */ | ||
public static final class DbCassandraConsistencyLevelValues { | ||
/** Values for {@link #DB_CASSANDRA_CONSISTENCYLEVEL}. */ | ||
public static final class DbCassandraConsistencylevelValues { |
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.
😢
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 agree, the only way it can be tolerated is if we avoided multi_word_names as much as possible.
public static final AttributeKey<Long> HTTP_REQUEST_RESENDCOUNT = | ||
longKey("http.request.resend_count"); |
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.
from an API user perspective, it looks like a typo that we forgot some underscore(s) in the constant name 😢
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.
what do you think about alternative proposal:
- first one gets the good constant name:
MESSAGING_CLIENT_ID = "messaging.client_id"
- next one (after rename) gets a "bad" constant name:
MESSAGING_CLIENT_ID2 = "messaging.client.id"
- when stabilizing, we are moving from
MessagingIncubatingAttributes
toMessagingAttributes
and so the stable one can get the good constant name at that time:MESSAGING_CLIENT_ID = "messaging.client.id"
- if anything is renamed after stability, we'd need to do a major version bump anyways (although users of the previously stable constant name would silently get the new constant value without any compilation warnings, which is not great, but really hoping this kind of rename after marking something stable is a rarity 😬)
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 prefer this plan.
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.
we could also just tolerate it (for experimental ones):
- generate both as MESSAGING_CLIENT_ID, override the value (non-deprecated wins) - it's tolerable for experimental attributes
- as you mentioned, we'd probably never do a rename like this for a stable attribute - the value would be too low to justify the cost.
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'm not excited about MESSAGING_CLIENT_ID2
since it would either need to be stabilized with this const name or users would need to update IncubatingAttributes.MESSAGING_CLIENT_ID2
-> Attributes.MESSAGING_CLIENT_ID
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.
The problem still remains - we don't really know the order in which attributes were added and which one should become MESSAGING_CLIENT_ID2
. We can assume that deprecated should get MESSAGING_CLIENT_ID
, but what if we deprecated both?
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.
What would we put into stable artifact when it's stabilized?
MESSAGING_CLIENT_ID
?
👍
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.
we can do it with some manual interventions.
Given that collisions are rare, it should be ok.
Trying it out here 6390847
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 don't mind the approach 3.5 where we accept breaking changes in the incubating artifact, but wondering if this solution could work better for folks who are more apprehensive about the breaking changes (and the strategy could also be used to mitigate the even rarer attribute type changes on experimental attributes)
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.
#76 shows manual conflict resolution:
- it allows to change constant names for experimental attributes. E.g. say that
messaging.client.id
constant names should be generated as if it wasmessaging.client.id_new
(preserving the const value) - or drop an attribute based on the name
Code generator generates the same attribute name constant for
attribute.name
andattribute_name
. As a result, if attribute is renamed (_
is changed to.
or vice versa), the value of attribute changes, but the name stays the same.It's ambiguous - see open-telemetry/semantic-conventions#1031 and open-telemetry/semantic-conventions#1118 for the discussion.
Based on open-telemetry/semantic-conventions#1118, the semconv recommendation would be to:
_
when generating any constants in the code (fields, methods, class names, etc)_
This PR demonstrates the result of such naming policy change.