mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Do not overwrite attributes in ClientObservationConventionAdapter
Prior to this commit, the `ClientObservationConventionAdapter` would overwrite a request builder attribute. This would happen when the request is not fully built when the observation starts. At that point, the tags are built for long task timers, but not for the actual metric. This effectively overrides the correct value of the URI template in the builder. This commit removes this builder update which was invalid in the first place. Fixes gh-40330
This commit is contained in:
parent
12e004f131
commit
24f80154d4
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -57,7 +57,7 @@ class ClientObservationConventionAdapter implements ClientRequestObservationConv
|
|||||||
public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) {
|
public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) {
|
||||||
ClientRequest request = context.getRequest();
|
ClientRequest request = context.getRequest();
|
||||||
if (request == null) {
|
if (request == null) {
|
||||||
request = context.getCarrier().attribute(URI_TEMPLATE_ATTRIBUTE, context.getUriTemplate()).build();
|
request = context.getCarrier().build();
|
||||||
}
|
}
|
||||||
Iterable<Tag> tags = this.tagsProvider.tags(request, context.getResponse(), context.getError());
|
Iterable<Tag> tags = this.tagsProvider.tags(request, context.getResponse(), context.getError());
|
||||||
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
|
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -83,6 +83,7 @@ class ClientObservationConventionAdapterTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void doesNotFailWithEmptyRequest() {
|
void doesNotFailWithEmptyRequest() {
|
||||||
|
this.context.setUriTemplate(null);
|
||||||
assertThat(this.convention.getLowCardinalityKeyValues(this.context)).contains(KeyValue.of("status", "200"),
|
assertThat(this.convention.getLowCardinalityKeyValues(this.context)).contains(KeyValue.of("status", "200"),
|
||||||
KeyValue.of("outcome", "SUCCESS"), KeyValue.of("uri", "/resource/{name}"),
|
KeyValue.of("outcome", "SUCCESS"), KeyValue.of("uri", "/resource/{name}"),
|
||||||
KeyValue.of("method", "GET"));
|
KeyValue.of("method", "GET"));
|
||||||
|
Loading…
Reference in New Issue
Block a user