-
Notifications
You must be signed in to change notification settings - Fork 199
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
Add span kind to sampling overrides #1960
Conversation
This reverts commit cf5b048.
@@ -62,6 +63,25 @@ private static boolean isEmpty(String str) { | |||
return str == null || str.trim().isEmpty(); | |||
} | |||
|
|||
public enum SpanKind { | |||
@JsonProperty("server") | |||
SERVER(io.opentelemetry.api.trace.SpanKind.SERVER), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is io.opentelemetry.api.trace.SpanKind an enum? can we reuse it rather than create a new one? if their spankind is updated, we shouldn't need to update ours.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our convention is for json enum values to be lowercase, and we can't add @JsonProperty
to those classes since they are not under our control. I will add a TODO marker here to investigate other options for mapping external annotations to lowercase.
@@ -373,6 +393,8 @@ private static String getDefaultPath() { | |||
} | |||
|
|||
public static class SamplingOverride { | |||
// TODO (trask) consider making this required when moving out of preview | |||
@Nullable public SpanKind spanKind; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declare it as io.opentelemetry.api.trace.SpanKind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above
void shouldFilterStrictMatchWithNullSpanKind() { | ||
// given | ||
List<SamplingOverride> overrides = | ||
singletonList(newOverride(null, 0, newStrictAttribute("one", "1"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when it's null, it will match any span kind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
SamplingOverrides sampler = new SamplingOverrides(overrides); | ||
Attributes attributes = Attributes.of(AttributeKey.stringKey("one"), "1"); | ||
|
||
// expect | ||
assertThat(sampler.getOverride(attributes).getPercentage()).isEqualTo(0); | ||
assertThat(sampler.getOverride(SpanKind.SERVER, attributes).getPercentage()).isEqualTo(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertThat(sampler.getOverride(SpanKind.CLIENT, attributes).getPercentage))).isEqualTo(0); should work too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
it's currently hard to suppress all outgoing http client spans, since those have essentially the same attributes as incoming http server spans.
attaching snapshot for testing: applicationinsights-agent-3.2.4-BETA-SNAPSHOT.jar.zip