Skip to content

Commit

Permalink
Replace Tag to KeyValues adapter code
Browse files Browse the repository at this point in the history
Closes gh-32876
  • Loading branch information
mhalbritter committed Nov 2, 2022
1 parent cc0ba82 commit 05c5b12
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ class ClientHttpObservationConventionAdapter implements ClientRequestObservation
public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) {
Iterable<Tag> tags = this.tagsProvider.getTags(context.getUriTemplate(), context.getCarrier(),
context.getResponse());
KeyValues keyValues = KeyValues.empty();
for (Tag tag : tags) {
keyValues = keyValues.and(tag.getKey(), tag.getValue());
}
return keyValues;
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ public boolean supportsContext(Observation.Context context) {
public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) {
mutateClientRequest(context);
Iterable<Tag> tags = this.tagsProvider.tags(context.getCarrier(), context.getResponse(), context.getError());
KeyValues keyValues = KeyValues.empty();
for (Tag tag : tags) {
keyValues = keyValues.and(tag.getKey(), tag.getValue());
}
return keyValues;
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
}

private void mutateClientRequest(ClientRequestObservationContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ public String getName() {
@Override
public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) {
Iterable<Tag> tags = this.tagsProvider.httpRequestTags(context.getServerWebExchange(), context.getError());
KeyValues keyValues = KeyValues.empty();
for (Tag tag : tags) {
keyValues = keyValues.and(tag.getKey(), tag.getValue());
}
return keyValues;
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ public boolean supportsContext(Observation.Context context) {
public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) {
Iterable<Tag> tags = this.tagsProvider.getTags(context.getCarrier(), context.getResponse(), getHandler(context),
context.getError());
KeyValues keyValues = KeyValues.empty();
for (Tag tag : tags) {
keyValues = keyValues.and(tag.getKey(), tag.getValue());
}
return keyValues;
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
}

private Object getHandler(ServerRequestObservationContext context) {
Expand Down

0 comments on commit 05c5b12

Please sign in to comment.