Skip to content

Add span kind to sampling overrides#1960

Merged
trask merged 9 commits into
mainfrom
add-span-kind-to-sampling-overrides
Nov 16, 2021
Merged

Add span kind to sampling overrides#1960
trask merged 9 commits into
mainfrom
add-span-kind-to-sampling-overrides

Conversation

@trask

@trask trask commented Nov 12, 2021

Copy link
Copy Markdown
Member

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


public enum SpanKind {
@JsonProperty("server")
SERVER(io.opentelemetry.api.trace.SpanKind.SERVER),

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member Author

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.


public static class SamplingOverride {
// TODO (trask) consider making this required when moving out of preview
@Nullable public SpanKind spanKind;

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

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")));

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes


// expect
assertThat(sampler.getOverride(attributes).getPercentage()).isEqualTo(0);
assertThat(sampler.getOverride(SpanKind.SERVER, attributes).getPercentage()).isEqualTo(0);

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@trask trask merged commit 404f79c into main Nov 16, 2021
@trask trask deleted the add-span-kind-to-sampling-overrides branch November 16, 2021 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants