-
Notifications
You must be signed in to change notification settings - Fork 880
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update webflux to Instrumenter API (and improvements/simplifications) (…
…#3798) * Update Webflux to Instrumenter API * Change webflux handler to match other handlers * Further simplification * Fix Mono failure tests * Use extractors! * Renames * Fix comment * Update instrumentation/spring/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/server/AdviceUtils.java Co-authored-by: Mateusz Rzeszutek <[email protected]>
- Loading branch information
Showing
10 changed files
with
159 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...etry/javaagent/instrumentation/spring/webflux/server/ExperimentalAttributesExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.spring.webflux.server; | ||
|
||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.api.common.AttributesBuilder; | ||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
import org.springframework.web.method.HandlerMethod; | ||
|
||
public class ExperimentalAttributesExtractor extends AttributesExtractor<Object, Void> { | ||
|
||
private static final AttributeKey<String> HANDLER_TYPE = | ||
AttributeKey.stringKey("spring-webflux.handler.type"); | ||
|
||
@Override | ||
protected void onStart(AttributesBuilder attributes, Object handler) { | ||
attributes.put(HANDLER_TYPE, getHandlerType(handler)); | ||
} | ||
|
||
@Override | ||
protected void onEnd(AttributesBuilder attributes, Object handler, @Nullable Void unused) {} | ||
|
||
private static String getHandlerType(Object handler) { | ||
if (handler instanceof HandlerMethod) { | ||
// Special case for requests mapped with annotations | ||
HandlerMethod handlerMethod = (HandlerMethod) handler; | ||
return handlerMethod.getMethod().getDeclaringClass().getName(); | ||
} else { | ||
return handler.getClass().getName(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
...emetry/javaagent/instrumentation/spring/webflux/server/SpringWebfluxHttpServerTracer.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.