-
Notifications
You must be signed in to change notification settings - Fork 869
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 code attributes to spring webflux controller spans and remove spring-webflux.handler.type
#12887
base: main
Are you sure you want to change the base?
Add code attributes to spring webflux controller spans and remove spring-webflux.handler.type
#12887
Changes from 1 commit
24b443c
ee2c31e
8e8fbbb
33ec295
7043602
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ | |
import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; | ||
import static io.opentelemetry.semconv.UrlAttributes.URL_SCHEME; | ||
import static io.opentelemetry.semconv.UserAgentAttributes.USER_AGENT_ORIGINAL; | ||
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION; | ||
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_NAMESPACE; | ||
import static org.junit.jupiter.api.Named.named; | ||
|
||
import io.opentelemetry.api.trace.SpanKind; | ||
|
@@ -142,7 +144,13 @@ void basicGetTest(Parameter parameter) { | |
stringKey("spring-webflux.handler.type"), | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.isEqualTo(TestController.class.getName()))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previously used |
||
: val -> val.isEqualTo(TestController.class.getName())), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
satisfies( | ||
CODE_NAMESPACE, | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.endsWith("HandlerMethod"))); | ||
})); | ||
} | ||
|
||
|
@@ -261,7 +269,13 @@ void getAsyncResponseTest(Parameter parameter) { | |
stringKey("spring-webflux.handler.type"), | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.isEqualTo(TestController.class.getName()))); | ||
: val -> val.isEqualTo(TestController.class.getName())), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
satisfies( | ||
CODE_NAMESPACE, | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.endsWith("HandlerMethod"))); | ||
}, | ||
span -> | ||
span.hasName("tracedMethod") | ||
|
@@ -367,7 +381,13 @@ void createSpanDuringHandlerFunctionTest(Parameter parameter) { | |
stringKey("spring-webflux.handler.type"), | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.isEqualTo(TestController.class.getName()))); | ||
: val -> val.isEqualTo(TestController.class.getName())), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
satisfies( | ||
CODE_NAMESPACE, | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.endsWith("HandlerMethod"))); | ||
}, | ||
span -> | ||
span.hasName("tracedMethod") | ||
|
@@ -430,6 +450,10 @@ void get404Test() { | |
.hasAttributesSatisfyingExactly( | ||
equalTo( | ||
stringKey("spring-webflux.handler.type"), | ||
"org.springframework.web.reactive.resource.ResourceWebHandler"), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
equalTo( | ||
CODE_NAMESPACE, | ||
"org.springframework.web.reactive.resource.ResourceWebHandler")))); | ||
} | ||
|
||
|
@@ -487,7 +511,11 @@ void basicPostTest() { | |
.hasAttributesSatisfyingExactly( | ||
satisfies( | ||
stringKey("spring-webflux.handler.type"), | ||
val -> val.contains(EchoHandlerFunction.class.getName()))), | ||
val -> val.contains(EchoHandlerFunction.class.getName())), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you are testing for exact value use |
||
satisfies( | ||
CODE_NAMESPACE, | ||
val -> val.isEqualTo("server.EchoHandlerFunction"))), | ||
span -> | ||
span.hasName("echo").hasParent(trace.getSpan(1)).hasTotalAttributeCount(0))); | ||
} | ||
|
@@ -548,7 +576,13 @@ void getToBadEndpointTest(Parameter parameter) { | |
stringKey("spring-webflux.handler.type"), | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.isEqualTo(TestController.class.getName()))); | ||
: val -> val.isEqualTo(TestController.class.getName())), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
satisfies( | ||
CODE_NAMESPACE, | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.endsWith("HandlerMethod"))); | ||
})); | ||
} | ||
|
||
|
@@ -605,6 +639,10 @@ void redirectTest() { | |
.hasAttributesSatisfyingExactly( | ||
satisfies( | ||
stringKey("spring-webflux.handler.type"), | ||
val -> val.startsWith("server.RedirectComponent$$Lambda")), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
satisfies( | ||
CODE_NAMESPACE, | ||
val -> val.startsWith("server.RedirectComponent$$Lambda")))), | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
|
@@ -633,6 +671,10 @@ void redirectTest() { | |
.hasAttributesSatisfyingExactly( | ||
satisfies( | ||
stringKey("spring-webflux.handler.type"), | ||
val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX)), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
satisfies( | ||
CODE_NAMESPACE, | ||
val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX))); | ||
})); | ||
} | ||
|
@@ -692,7 +734,13 @@ void multipleGetsToDelayingRoute(Parameter parameter) { | |
stringKey("spring-webflux.handler.type"), | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.isEqualTo(TestController.class.getName()))); | ||
: val -> val.isEqualTo(TestController.class.getName())), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
satisfies( | ||
CODE_NAMESPACE, | ||
parameter.annotatedMethod == null | ||
? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
: val -> val.endsWith("HandlerMethod"))); | ||
}); | ||
|
||
testing.waitAndAssertTraces(Collections.nCopies(requestsCount, traceAssertion)); | ||
|
@@ -764,6 +812,12 @@ void cancelRequestTest() throws Exception { | |
stringKey("spring-webflux.handler.type"), | ||
value -> | ||
value.startsWith( | ||
"server.SpringWebFluxTestApplication$$Lambda")), | ||
satisfies(CODE_FUNCTION, val -> val.isEqualTo("handle")), | ||
satisfies( | ||
CODE_NAMESPACE, | ||
val -> | ||
val.startsWith( | ||
"server.SpringWebFluxTestApplication$$Lambda"))))); | ||
|
||
SpringWebFluxTestApplication.resumeSlowRequest(); | ||
|
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
spring-webflux.handler.type
redundant now?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.
yeah i think it is redundant now. but not sure what is the recommended procedure of deprecating a metric? can we just remove it or we should mark it deprecated and remove it in a future release? thanks!
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.
since it's already an opt-in experimental attribute, I think it's ok to just remove it and mention in the PR title so that I will remember to add it in the migration notes when writing the change log
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.
i have removed it in the latest change, and updated the title. please kindly have a look. thanks!