| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package plog // import "go.opentelemetry.io/collector/pdata/plog" |
| 5 |
|
| 6 |
const isSampledMask = uint32(1) |
| 7 |
|
| 8 |
var DefaultLogRecordFlags = LogRecordFlags(0) |
| 9 |
|
| 10 |
// LogRecordFlags defines flags for the LogRecord. The 8 least significant bits are the trace flags as |
| 11 |
// defined in W3C Trace Context specification. 24 most significant bits are reserved and must be set to 0. |
| 12 |
type LogRecordFlags uint32 |
| 13 |
|
| 14 |
// IsSampled returns true if the LogRecordFlags contains the IsSampled flag. |
| 15 |
func (ms LogRecordFlags) IsSampled() bool { |
| 16 |
return uint32(ms)&isSampledMask != 0 |
| 17 |
} |
| 18 |
|
| 19 |
// WithIsSampled returns a new LogRecordFlags, with the IsSampled flag set to the given value. |
| 20 |
func (ms LogRecordFlags) WithIsSampled(b bool) LogRecordFlags { |
| 21 |
orig := uint32(ms) |
| 22 |
if b { |
| 23 |
orig |= isSampledMask |
| 24 |
} else { |
| 25 |
orig &^= isSampledMask |
| 26 |
} |
| 27 |
return LogRecordFlags(orig) |
| 28 |
} |