Skip to content
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

Ensure helper enums are consistently declared #405

Conversation

tigrannajaryan
Copy link
Member

The changes in this PR do not affect wire formats in any way
since these are helper enums. This is not a breaking change
for the protocol.

This is a breaking change for the generated code.

This change is the smaller subset of #397

Comment on lines 153 to 157
// Masks for LogRecord.flags field.
enum LogRecordFlags {
LOG_RECORD_FLAG_UNSPECIFIED = 0;
LOG_RECORD_FLAG_TRACE_FLAGS_MASK = 0x000000FF;
LOG_RECORD_FLAGS_UNSPECIFIED = 0;
LOG_RECORD_FLAGS_TRACE_FLAGS_MASK = 0x000000FF;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather remove them, since this repo is for the protocol definition and not for the "helpers" around the protocol.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These help to implement the protocol correctly. Without these enums we have to explain the flags using English prose, which is more fragile and error prone.

I understand the desire to minimize the contract surface but I believe to help increase OTLP popularity we need to take some pains ourselves in order to reduce the pains for others who adopt OTLP. See my comment about the proposed approach here: #400 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree since a standard like w3c does not define "helpers" for trace flags for example. Also it is very bad design right now that helpers related to trace flags are defined in "logs" package.

I strongly suggest to remove for the moment, and determine if you are right or not about the "wrong" implementation, once we first hear about that we can have a small design for the helpers: where do they live, what are the guarantees since in this repo we mention that we guarantee wire not generated code (then how do you use this?), etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree since a standard like w3c does not define "helpers" for trace flags for example.

I am not sure the analogy with w3c standard that you bring helps. The entire w3c trace context spec is just English prose, so there is no mechanism available for formal, compiler-enforced enum declarations there. I think the fact that w3c standard doesn't define helpers is not an argument that helps us to make a decision in our case, where such Protobuf compiler-enforced mechanism is luckily available.

Also it is very bad design right now that helpers related to trace flags are defined in "logs" package.

I think there is some confusion about what this enum is. This helper is not trace flags definitions. This helper enum is the definition of LogRecord.flags field. Yes, 8 bits of the flags field will contain the value of w3c trace flags, but note how we don't define what is contained in those 8 bits here - the fact that only 1 bit is actually used here is irrelevant here, is not OTLP's business and is intentionally omitted. There may be other LogRecord flag definitions added here in the future, totally unrelated to the w3c trace flags. So, this is really LogRecord.flags field definition. Can you clarify why you think it is a bad design?

To be clear, I am not strongly opposed to removing the helpers. I do think the helpers are useful and have a slight preference to keep them, but if you see strong arguments in favour of removing we can remove them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm with @tigrannajaryan. Soft-yes to include them, mostly because I don't see strong arguments for removing them.

opentelemetry/proto/metrics/v1/metrics.proto Outdated Show resolved Hide resolved

// This DataPoint is valid but has no recorded value. This value
// SHOULD be used to reflect explicitly missing data in a series, as
// for an equivalent to the Prometheus "staleness marker".
FLAG_NO_RECORDED_VALUE = 1;
DATA_POINTS_FLAG_NO_RECORDED_VALUE = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DATA_POINTS_FLAG_NO_RECORDED_VALUE = 1;
DATA_POINTS_FLAGS_NO_RECORDED_VALUE = 1;

If we're going to change these we should be consistent with the LOG_RECORD_FLAGS_* values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tigrannajaryan my point on removing seems to be proven here. I DATA_POINTS_FLAGS_NO_RECORDED_VALUE sounds like the value of the "flags" not the value of the "mask" that you need to "bit and/or". I do suggest even more to remove them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DATA_POINTS_FLAGS_NO_RECORDED_VALUE sounds like the value of the "flags" not the value of the "mask" that you need to "bit and/or". I do suggest even more to remove them.

I am not sure understand. Here is what the enum comment currently says:

// DataPointFlags is defined as a protobuf 'uint32' type and is to be used as a
// bit-field representing 32 distinct boolean flags.  Each flag defined in this
// enum is a bit-mask.  To test the presence of a single flag in the flags of
// a data point, for example, use an expression like:
//
//   (point.flags & FLAG_NO_RECORDED_VALUE) == FLAG_NO_RECORDED_VALUE

So, it is a bitmask, right? DATA_POINTS_FLAGS_NO_RECORDED_VALUE is equal to 1, denoting the least significant bit in this field.

Please clarify where do you see a problem here that proves your point. Are you saying the name DATA_POINTS_FLAGS_NO_RECORDED_VALUE is confusing because it is not clear it is a mask?

opentelemetry/proto/metrics/v1/metrics.proto Outdated Show resolved Hide resolved
@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/helperenums branch from 02739bb to 9004b9d Compare June 21, 2022 22:12
The changes in this PR do not affect wire formats in any way
since these are helper enums. This is not a breaking change
for the protocol.

This is a breaking change for the generated code.

This change is the smaller subset of open-telemetry#397
@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/helperenums branch from 9004b9d to 401b3f8 Compare June 21, 2022 22:13
//
enum DataPointFlags {
FLAG_NONE = 0;
DATA_POINTS_FLAGS_NONE = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name change seems 100% inline w/ C++ generated code (vs. other language). Is that correct? Do we have a naming convention for enums that requires the value name to include the enum name?

Comment on lines 153 to 157
// Masks for LogRecord.flags field.
enum LogRecordFlags {
LOG_RECORD_FLAG_UNSPECIFIED = 0;
LOG_RECORD_FLAG_TRACE_FLAGS_MASK = 0x000000FF;
LOG_RECORD_FLAGS_UNSPECIFIED = 0;
LOG_RECORD_FLAGS_TRACE_FLAGS_MASK = 0x000000FF;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm with @tigrannajaryan. Soft-yes to include them, mostly because I don't see strong arguments for removing them.

@tigrannajaryan
Copy link
Member Author

Closing since there is no consensus on how to move forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants