Skip to content

Commit 559d89f

Browse files
committed
more cleanup
1 parent 39b823c commit 559d89f

File tree

5 files changed

+12
-100
lines changed

5 files changed

+12
-100
lines changed

instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/HandlerAdapterInstrumentation.java

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ public ElementMatcher<TypeDescription> typeMatcher() {
4747

4848
@Override
4949
public void transform(TypeTransformer transformer) {
50-
// Get the class name being transformed - this requires accessing transformer internals
51-
// For now, just log that we're transforming
52-
System.out.println("=== HandlerAdapterInstrumentation.transform() called ===");
53-
System.out.println(" Applying advice to 'handle' method");
5450
transformer.applyAdviceToMethod(
5551
isMethod()
5652
.and(isPublic())
@@ -59,7 +55,6 @@ public void transform(TypeTransformer transformer) {
5955
.and(takesArgument(1, Object.class))
6056
.and(takesArguments(2)),
6157
this.getClass().getName() + "$HandleAdvice");
62-
System.out.println("=== HandlerAdapterInstrumentation advice applied ===");
6358
}
6459

6560
@SuppressWarnings("unused")
@@ -76,13 +71,7 @@ private AdviceScope(Context context, Scope scope) {
7671

7772
@Nullable
7873
public static AdviceScope enter(ServerWebExchange exchange, Object handler) {
79-
System.out.println("=== HandlerAdapter.enter() called ===");
80-
System.out.println(
81-
" Handler: " + (handler != null ? handler.getClass().getName() : "null"));
82-
System.out.println(" Thread: " + Thread.currentThread().getName());
83-
8474
Context parentContext = Context.current();
85-
System.out.println(" Parent context: " + parentContext);
8675

8776
// HttpRouteSource.CONTROLLER has useFirst true, and it will update http.route only once
8877
// using the last portion of the nested path.
@@ -93,20 +82,13 @@ public static AdviceScope enter(ServerWebExchange exchange, Object handler) {
9382
parentContext, HttpServerRouteSource.NESTED_CONTROLLER, httpRouteGetter(), exchange);
9483

9584
if (handler == null) {
96-
System.out.println(" Handler is null, returning null");
9785
return null;
9886
}
9987

100-
boolean shouldStart = instrumenter().shouldStart(parentContext, handler);
101-
System.out.println(" shouldStart: " + shouldStart);
102-
103-
if (!shouldStart) {
104-
System.out.println(" instrumenter().shouldStart returned false, returning null");
88+
if (!instrumenter().shouldStart(parentContext, handler)) {
10589
return null;
10690
}
107-
10891
Context context = instrumenter().start(parentContext, handler);
109-
System.out.println(" Started new context: " + context);
11092
return new AdviceScope(context, context.makeCurrent());
11193
}
11294

@@ -132,13 +114,10 @@ public Mono<HandlerResult> exit(
132114
}
133115

134116
@Nullable
135-
@Advice.OnMethodEnter
117+
@Advice.OnMethodEnter(suppress = Throwable.class)
136118
public static AdviceScope methodEnter(
137119
@Advice.Argument(0) ServerWebExchange exchange, @Advice.Argument(1) Object handler) {
138-
System.out.println("=== HandlerAdapter.methodEnter() CALLED ===");
139-
AdviceScope scope = AdviceScope.enter(exchange, handler);
140-
System.out.println(" Returning AdviceScope: " + scope);
141-
return scope;
120+
return AdviceScope.enter(exchange, handler);
142121
}
143122

144123
@AssignReturned.ToReturned
@@ -150,18 +129,11 @@ public static Mono<HandlerResult> methodExit(
150129
@Advice.Thrown Throwable throwable,
151130
@Advice.Enter @Nullable AdviceScope adviceScope) {
152131

153-
System.out.println("=== HandlerAdapter.methodExit() CALLED ===");
154-
System.out.println(" AdviceScope: " + adviceScope);
155-
System.out.println(" Throwable: " + throwable);
156-
157132
if (adviceScope == null) {
158-
System.out.println(" AdviceScope is null, returning original mono");
159133
return mono;
160134
}
161135

162-
Mono<HandlerResult> result = adviceScope.exit(throwable, exchange, handler, mono);
163-
System.out.println(" Returning wrapped mono");
164-
return result;
136+
return adviceScope.exit(throwable, exchange, handler, mono);
165137
}
166138
}
167139
}

instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v7_0/server/base/DelayedHandlerSpringWebFluxServerTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ protected Mono<ServerResponse> wrapResponse(
4949
return response
5050
.delayElement(Duration.ofMillis(10))
5151
.map(
52-
original -> {
53-
System.out.println("In wrapResponse map for endpoint " + endpoint);
54-
return controller(
55-
endpoint,
56-
() -> {
57-
spanAction.run();
58-
return original;
59-
});
60-
});
52+
original ->
53+
controller(
54+
endpoint,
55+
() -> {
56+
spanAction.run();
57+
return original;
58+
}));
6159
}
6260
}
6361
}

instrumentation/spring/spring-webflux/spring-webflux-5.0/testing/src/main/java/io/opentelemetry/instrumentation/spring/webflux/server/AbstractImmediateHandlerSpringWebFluxServerTest.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,6 @@
2121
*/
2222
public abstract class AbstractImmediateHandlerSpringWebFluxServerTest
2323
extends AbstractHandlerSpringWebFluxServerTest {
24-
// @Override
25-
// protected Class<?> getApplicationClass() {
26-
// return Application.class;
27-
// }
28-
29-
// @Configuration
30-
// @EnableAutoConfiguration
31-
// static class Application {
32-
// @Bean
33-
// RouterFunction<ServerResponse> router() {
34-
// return new RouteFactory().createRoutes();
35-
// }
36-
//
37-
// @Bean
38-
// NettyReactiveWebServerFactory nettyFactory() {
39-
// return new NettyReactiveWebServerFactory();
40-
// }
41-
// }
42-
43-
// static class RouteFactory extends ServerTestRouteFactory {
44-
//
45-
// @Override
46-
// protected Mono<ServerResponse> wrapResponse(
47-
// ServerEndpoint endpoint, Mono<ServerResponse> response, Runnable spanAction) {
48-
// return controller(
49-
// endpoint,
50-
// () -> {
51-
// spanAction.run();
52-
// return response;
53-
// });
54-
// }
55-
// }
5624

5725
@Test
5826
void nestedPath() {

testing-common/src/main/java/io/opentelemetry/instrumentation/testing/TestInstrumenters.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,7 @@ <T, E extends Throwable> T runWithNonRecordingSpan(ThrowingSupplier<T, E> callba
9797
private static <T, E extends Throwable> T runWithInstrumenter(
9898
String spanName, Instrumenter<String, Void> instrumenter, ThrowingSupplier<T, E> callback)
9999
throws E {
100-
System.out.println("=== TestInstrumenters.runWithInstrumenter() CALLED ===");
101-
System.out.println(" Span name: " + spanName);
102-
System.out.println(" Thread: " + Thread.currentThread().getName());
103-
104-
Context parentContext = Context.current();
105-
System.out.println(" Parent context: " + parentContext);
106-
107-
boolean shouldStart = instrumenter.shouldStart(parentContext, spanName);
108-
System.out.println(" shouldStart: " + shouldStart);
109-
110-
if (!shouldStart) {
111-
System.out.println(" Instrumenter refused to start span, running callback without span");
112-
return callback.get();
113-
}
114-
115-
Context context = instrumenter.start(parentContext, spanName);
116-
System.out.println(" Started context: " + context);
100+
Context context = instrumenter.start(Context.current(), spanName);
117101

118102
T result;
119103
try (Scope ignored = context.makeCurrent()) {
@@ -123,7 +107,6 @@ private static <T, E extends Throwable> T runWithInstrumenter(
123107
throw t;
124108
}
125109
instrumenter.end(context, spanName, null, null);
126-
System.out.println(" Span ended successfully");
127110
return result;
128111
}
129112

testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,10 @@ protected void configure(HttpServerTestOptions options) {}
121121

122122
public static <T, E extends Throwable> T controller(
123123
ServerEndpoint endpoint, ThrowingSupplier<T, E> closure) throws E {
124-
System.out.println("=== controller() CALLED ===");
125-
System.out.println(" Endpoint: " + endpoint);
126-
System.out.println(" Thread: " + Thread.currentThread().getName());
127-
System.out.println(" Current span: " + Span.current());
128-
System.out.println(
129-
" Current span context valid: " + Span.current().getSpanContext().isValid());
130-
131124
assert Span.current().getSpanContext().isValid() : "Controller should have a parent span.";
132125
if (endpoint == NOT_FOUND) {
133-
System.out.println(" Endpoint is NOT_FOUND, skipping controller span");
134126
return closure.get();
135127
}
136-
System.out.println(" Calling GlobalTraceUtil.runWithSpan('controller', ...)");
137128
return GlobalTraceUtil.runWithSpan("controller", closure);
138129
}
139130

0 commit comments

Comments
 (0)