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

Treat 1 value as true for boolean tag values #4296

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ private static boolean interceptMeasured(DDSpanContext span, Object value) {

private static boolean asBoolean(Object value) {
return Boolean.TRUE.equals(value)
|| "1".equals(value)
|| (!Boolean.FALSE.equals(value) && Boolean.parseBoolean(String.valueOf(value)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,4 +575,36 @@ class TagInterceptorTest extends DDCoreSpecification {
cleanup:
tracer.close()
}

def "treat `1` value as `true` for boolean tag values"() {
setup:
def tracer = tracerBuilder()
.serviceName("some-service")
.writer(new LoggingWriter())
.sampler(new AllSampler())
.build()

when:
AgentSpan span = tracer.buildSpan("test").start()

then:
span.getSamplingPriority() == null

when:
span.setTag(tag, value)

then:
span.getSamplingPriority() == samplingPriority

where:
tag | value | samplingPriority
DDTags.MANUAL_DROP | true | PrioritySampling.USER_DROP
DDTags.MANUAL_DROP | "1" | PrioritySampling.USER_DROP
DDTags.MANUAL_DROP | false | null
DDTags.MANUAL_DROP | "0" | null
DDTags.MANUAL_KEEP | true | PrioritySampling.USER_KEEP
DDTags.MANUAL_KEEP | "1" | PrioritySampling.USER_KEEP
DDTags.MANUAL_KEEP | false | null
DDTags.MANUAL_KEEP | "0" | null
}
}