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

OtelTraceContextBuilder throwing Exception #911

Open
eceolinupgrade opened this issue Dec 13, 2024 · 1 comment
Open

OtelTraceContextBuilder throwing Exception #911

eceolinupgrade opened this issue Dec 13, 2024 · 1 comment
Labels
bug A general bug
Milestone

Comments

@eceolinupgrade
Copy link

eceolinupgrade commented Dec 13, 2024

The TraceContext interface accepts nullable values on sampled flag.

The problem is if you do not set that value you'll get NPE because of the ternary condition on the .build() method.

@Override
    public TraceContext build() {
        if (StringUtils.isNotEmpty(this.parentId)) {
            return new OtelTraceContext(
                    SpanContext.createFromRemoteParent(this.traceId, this.spanId,
                            this.sampled ? TraceFlags.getSampled() : TraceFlags.getDefault(), TraceState.getDefault()),
                    null);
        }
        return new OtelTraceContext(
                SpanContext.create(this.traceId, this.spanId,
                        this.sampled ? TraceFlags.getSampled() : TraceFlags.getDefault(), TraceState.getDefault()),
                null);
    }
@binig
Copy link

binig commented Dec 13, 2024

just offered a simple fix for this #910

@shakuzen shakuzen added the bug A general bug label Dec 16, 2024
@shakuzen shakuzen added this to the 1.3.x milestone Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants