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

Clarify that zero values bitfield helper enums should not be used #461

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions opentelemetry/proto/logs/v1/logs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,21 @@ enum SeverityNumber {
SEVERITY_NUMBER_FATAL4 = 24;
}

// Masks for LogRecord.flags field.
// LogRecordFlags is defined as a protobuf 'uint32' type and is to be used as
// bit-fields. Each non-zero value defined in this enum is a bit-mask.
// To extract the bit-field, for example, use an expression like:
//
// (logRecord.flags & LOG_RECORD_FLAG_TRACE_FLAGS_MASK)
//
enum LogRecordFlags {
LOG_RECORD_FLAG_UNSPECIFIED = 0;
// The zero value for the enum. Should not be used for comparisons.
// Instead use bitwise "and" with the appropriate mask as shown above.
LOG_RECORD_FLAG_DO_NOT_USE = 0;

// Bits 0-7 are used for trace flags.
LOG_RECORD_FLAG_TRACE_FLAGS_MASK = 0x000000FF;

// Bits 8-31 are reserved for future use.
}

// A log record according to OpenTelemetry Log Data Model:
Expand Down
8 changes: 5 additions & 3 deletions opentelemetry/proto/metrics/v1/metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,17 @@ enum AggregationTemporality {
// 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
// (point.flags & FLAG_NO_RECORDED_VALUE_MASK) == FLAG_NO_RECORDED_VALUE_MASK
//
enum DataPointFlags {
FLAG_NONE = 0;
// The zero value for the enum. Should not be used for comparisons.
// Instead use bitwise "and" with the appropriate mask as shown above.
FLAG_DO_NOT_USE = 0;

// 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;
FLAG_NO_RECORDED_VALUE_MASK = 1;

// Bits 2-31 are reserved for future use.
}
Expand Down