Skip to content

ComposableAnnotatingSampler missing toString shows Object hash in composed description #8644

Description

@thswlsqls

Describe the bug
ComposableAnnotatingSampler does not override toString(), so when another sampler nests it, the composed getDescription() output shows an Object hash instead of the annotating sampler's description.

Steps to reproduce

ComposableSampler.parentThreshold(
        ComposableSampler.annotating(ComposableSampler.alwaysOn(), Attributes.empty()))
    .getDescription();

What did you expect to see?

ComposableParentThresholdSampler{rootSampler=ComposableAnnotatingSampler{ComposableAlwaysOnSampler,{}}}

The other six ComposableSampler implementations all override toString() to return getDescription().

What did you see instead?

ComposableParentThresholdSampler{rootSampler=ComposableAnnotatingSampler@1a2b3c}

ComposableParentThresholdSampler builds its description by concatenating the nested sampler (ComposableParentThresholdSampler.java line 28), which calls toString() on the root sampler. ComposableAnnotatingSampler is the only implementation without that override, so it falls back to Object.toString().

What version and what artifacts are you using?
Artifacts: opentelemetry-sdk-extension-incubator
Version: main @ 09d6c17
How did you reference these artifacts? N/A

Environment
Compiler: Temurin 21
OS: N/A

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions