Description
Component(s)
processor/probabilisticsampler
What happened?
Description
It is possible to configure the processor to sample based upon an arbitrary attribute of each log record. Currently, if you provide an attribute that is not a Bytes
typed attribute, then the collector will panic with something similar to the following:
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x102c9c0e8]
goroutine 14 [running]:
testing.tRunner.func1.2({0x102e93760, 0x1034ec850})
/opt/homebrew/Cellar/go/1.19.5/libexec/src/testing/testing.go:1396 +0x1c8
testing.tRunner.func1()
/opt/homebrew/Cellar/go/1.19.5/libexec/src/testing/testing.go:1399 +0x378
panic({0x102e93760, 0x1034ec850})
/opt/homebrew/Cellar/go/1.19.5/libexec/src/runtime/panic.go:884 +0x204
go.opentelemetry.io/collector/pdata/pcommon.ByteSlice.AsRaw(...)
<snip>
Effectively, when Bytes()
is called on any attribute value that is not of type AnyValue_BytesValue
here:
The returned BytesSlice
will be zero-initialised, resulting in the AsRaw()
call panicking.
Steps to Reproduce
Configure the processor to sample based on an attribute of each log record, where the attribute is not of type Bytes
e.g.,
processors:
probabilistic_sampler:
sampling_percentage: 15
attribute_source: record
from_attribute: <an_attribute_thats_not_bytes>
Expected Result
Either the attribute value is used for a sampling decision, or the log record is skipped and not sampled.
Actual Result
The collector panics.
Collector version
latest
Environment information
Environment
All
OpenTelemetry Collector configuration
No response
Log output
No response
Additional context
No response