- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1k
          Add code attributes to spring webflux controller spans and remove spring-webflux.handler.type
          #12887
        
          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
                      Changes from 9 commits
24b443c
              ee2c31e
              8e8fbbb
              33ec295
              7043602
              e7381bb
              1120ad8
              807fd56
              c1a5638
              d8d3837
              3810623
              930f0f4
              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 | 
|---|---|---|
|  | @@ -5,7 +5,6 @@ | |
|  | ||
| package io.opentelemetry.javaagent.instrumentation.spring.webflux.v5_0.server; | ||
|  | ||
| import static io.opentelemetry.api.common.AttributeKey.stringKey; | ||
| import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; | ||
| import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; | ||
| import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies; | ||
|  | @@ -25,6 +24,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; | ||
|  | @@ -139,7 +140,12 @@ void basicGetTest(Parameter parameter) { | |
| .hasParent(trace.getSpan(0)) | ||
| .hasAttributesSatisfyingExactly( | ||
| satisfies( | ||
| stringKey("spring-webflux.handler.type"), | ||
| CODE_FUNCTION, | ||
| parameter.annotatedMethod == null | ||
| ? val -> val.isEqualTo("handle") | ||
| : val -> val.isEqualTo(parameter.annotatedMethod)), | ||
| satisfies( | ||
| CODE_NAMESPACE, | ||
| 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  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. updated 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. now it reports  | ||
|  | @@ -258,7 +264,12 @@ void getAsyncResponseTest(Parameter parameter) { | |
| .hasParent(trace.getSpan(0)) | ||
| .hasAttributesSatisfyingExactly( | ||
| satisfies( | ||
| stringKey("spring-webflux.handler.type"), | ||
| CODE_FUNCTION, | ||
| parameter.annotatedMethod == null | ||
| ? val -> val.isEqualTo("handle") | ||
| : val -> val.isEqualTo(parameter.annotatedMethod)), | ||
| satisfies( | ||
| CODE_NAMESPACE, | ||
| parameter.annotatedMethod == null | ||
| ? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
| : val -> val.isEqualTo(TestController.class.getName()))); | ||
|  | @@ -364,7 +375,12 @@ void createSpanDuringHandlerFunctionTest(Parameter parameter) { | |
| .hasParent(trace.getSpan(0)) | ||
| .hasAttributesSatisfyingExactly( | ||
| satisfies( | ||
| stringKey("spring-webflux.handler.type"), | ||
| CODE_FUNCTION, | ||
| parameter.annotatedMethod == null | ||
| ? val -> val.isEqualTo("handle") | ||
| : val -> val.isEqualTo(parameter.annotatedMethod)), | ||
| satisfies( | ||
| CODE_NAMESPACE, | ||
| parameter.annotatedMethod == null | ||
| ? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
| : val -> val.isEqualTo(TestController.class.getName()))); | ||
|  | @@ -428,8 +444,9 @@ void get404Test() { | |
| .hasStatus(StatusData.error()) | ||
| .hasEventsSatisfyingExactly(SpringWebfluxTest::resource404Exception) | ||
| .hasAttributesSatisfyingExactly( | ||
| equalTo(CODE_FUNCTION, "handle"), | ||
| equalTo( | ||
| stringKey("spring-webflux.handler.type"), | ||
| CODE_NAMESPACE, | ||
| "org.springframework.web.reactive.resource.ResourceWebHandler")))); | ||
| } | ||
|  | ||
|  | @@ -485,9 +502,8 @@ void basicPostTest() { | |
| .hasKind(SpanKind.INTERNAL) | ||
| .hasParent(trace.getSpan(0)) | ||
| .hasAttributesSatisfyingExactly( | ||
| satisfies( | ||
| stringKey("spring-webflux.handler.type"), | ||
| val -> val.contains(EchoHandlerFunction.class.getName()))), | ||
| equalTo(CODE_FUNCTION, "handle"), | ||
| equalTo(CODE_NAMESPACE, "server.EchoHandlerFunction")), | ||
|         
                  cuichenli marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| span -> | ||
| span.hasName("echo").hasParent(trace.getSpan(1)).hasTotalAttributeCount(0))); | ||
| } | ||
|  | @@ -545,7 +561,12 @@ void getToBadEndpointTest(Parameter parameter) { | |
| val -> val.isInstanceOf(String.class)))) | ||
| .hasAttributesSatisfyingExactly( | ||
| satisfies( | ||
| stringKey("spring-webflux.handler.type"), | ||
| CODE_FUNCTION, | ||
| parameter.annotatedMethod == null | ||
| ? val -> val.isEqualTo("handle") | ||
| : val -> val.isEqualTo(parameter.annotatedMethod)), | ||
| satisfies( | ||
| CODE_NAMESPACE, | ||
| parameter.annotatedMethod == null | ||
| ? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
| : val -> val.isEqualTo(TestController.class.getName()))); | ||
|  | @@ -603,8 +624,9 @@ void redirectTest() { | |
| .hasKind(SpanKind.INTERNAL) | ||
| .hasParent(trace.getSpan(0)) | ||
| .hasAttributesSatisfyingExactly( | ||
| equalTo(CODE_FUNCTION, "handle"), | ||
| satisfies( | ||
| stringKey("spring-webflux.handler.type"), | ||
| CODE_NAMESPACE, | ||
| val -> val.startsWith("server.RedirectComponent$$Lambda")))), | ||
| trace -> | ||
| trace.hasSpansSatisfyingExactly( | ||
|  | @@ -631,8 +653,9 @@ void redirectTest() { | |
| span.hasKind(SpanKind.INTERNAL) | ||
| .hasParent(trace.getSpan(0)) | ||
| .hasAttributesSatisfyingExactly( | ||
| equalTo(CODE_FUNCTION, "handle"), | ||
| satisfies( | ||
| stringKey("spring-webflux.handler.type"), | ||
| CODE_NAMESPACE, | ||
| val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX))); | ||
| })); | ||
| } | ||
|  | @@ -689,7 +712,12 @@ void multipleGetsToDelayingRoute(Parameter parameter) { | |
| .hasParent(trace.getSpan(0)) | ||
| .hasAttributesSatisfyingExactly( | ||
| satisfies( | ||
| stringKey("spring-webflux.handler.type"), | ||
| CODE_FUNCTION, | ||
| parameter.annotatedMethod == null | ||
| ? val -> val.isEqualTo("handle") | ||
| : val -> val.isEqualTo(parameter.annotatedMethod)), | ||
| satisfies( | ||
| CODE_NAMESPACE, | ||
| parameter.annotatedMethod == null | ||
| ? val -> val.contains(INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX) | ||
| : val -> val.isEqualTo(TestController.class.getName()))); | ||
|  | @@ -760,10 +788,11 @@ void cancelRequestTest() throws Exception { | |
| .hasKind(SpanKind.INTERNAL) | ||
| .hasParent(trace.getSpan(0)) | ||
| .hasAttributesSatisfyingExactly( | ||
| equalTo(CODE_FUNCTION, "handle"), | ||
| satisfies( | ||
| stringKey("spring-webflux.handler.type"), | ||
| value -> | ||
| value.startsWith( | ||
| 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.
👍