Skip to content

Commit 81827bc

Browse files
committed
@laurit PR comments are addressed
1 parent 418a259 commit 81827bc

File tree

7 files changed

+11
-194
lines changed

7 files changed

+11
-194
lines changed

instrumentation/activej-http-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/activejhttp/ActivejHttpServerHeaders.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ public String get(HttpRequest carrier, String key) {
3333

3434
@Override
3535
public Iterator<String> getAll(HttpRequest carrier, String key) {
36+
HttpHeader httpHeader = HttpHeaders.of(key);
3637
List<String> values = new ArrayList<>();
3738
if (carrier != null) {
3839
for (Map.Entry<HttpHeader, HttpHeaderValue> entry : carrier.getHeaders()) {
39-
if (entry.getKey().toString().equalsIgnoreCase(key)) {
40+
if (httpHeader.equals(entry.getKey())) {
4041
values.add(entry.getValue().toString());
4142
}
4243
}

instrumentation/activej-http-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/activejhttp/ActivejHttpServerHttpAttributesGetter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
package io.opentelemetry.javaagent.instrumentation.activejhttp;
77

8-
import static io.opentelemetry.testing.internal.armeria.internal.shaded.guava.base.Ascii.toLowerCase;
9-
108
import io.activej.http.HttpRequest;
119
import io.activej.http.HttpResponse;
1210
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter;
@@ -18,7 +16,7 @@ final class ActivejHttpServerHttpAttributesGetter
1816

1917
@Override
2018
public String getHttpRequestMethod(HttpRequest request) {
21-
return ActivejHttpServerUtil.getHttpRequestMethod(request);
19+
return request.getMethod().name();
2220
}
2321

2422
@Override
@@ -40,7 +38,7 @@ public List<String> getHttpResponseHeader(
4038

4139
@Override
4240
public String getUrlScheme(HttpRequest request) {
43-
return toLowerCase(request.getProtocol().name());
41+
return request.getProtocol().lowercase();
4442
}
4543

4644
@Override

instrumentation/activej-http-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/activejhttp/ActivejHttpServerUtil.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@
1919

2020
public final class ActivejHttpServerUtil {
2121

22-
private ActivejHttpServerUtil() {
23-
throw new UnsupportedOperationException();
24-
}
25-
26-
static String getHttpRequestMethod(HttpRequest request) {
27-
return request.getMethod().name();
28-
}
22+
private ActivejHttpServerUtil() {}
2923

3024
static List<String> requestHeader(HttpRequest request, String name) {
3125
String headerValue = request.getHeader(HttpHeaders.of(name));

instrumentation/activej-http-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/activejhttp/PromiseWrapper.java

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,15 @@
1010
import io.activej.http.HttpRequest;
1111
import io.activej.http.HttpResponse;
1212
import io.activej.promise.Promise;
13-
import io.activej.promise.SettablePromise;
1413
import io.opentelemetry.context.Context;
15-
import io.opentelemetry.context.Scope;
1614

1715
public class PromiseWrapper {
1816

1917
public static Promise<HttpResponse> wrap(
2018
Promise<HttpResponse> promise, HttpRequest httpRequest, Context context) {
21-
SettablePromise<HttpResponse> settablePromise = new SettablePromise<>();
22-
promise
23-
.whenResult(
24-
result -> {
25-
Exception error = null;
26-
try (Scope ignored = context.makeCurrent()) {
27-
settablePromise.set(result);
28-
} catch (RuntimeException exception) {
29-
error = exception;
30-
settablePromise.setException(
31-
new RuntimeException("Context management failed", exception));
32-
} finally {
33-
instrumenter().end(context, httpRequest, result, error);
34-
}
35-
})
36-
.whenException(
37-
throwable -> {
38-
try (Scope ignored = context.makeCurrent()) {
39-
settablePromise.setException(throwable);
40-
} catch (RuntimeException exception) {
41-
settablePromise.setException(
42-
new RuntimeException("Context management failed", exception));
43-
} finally {
44-
instrumenter().end(context, httpRequest, null, throwable);
45-
}
46-
});
47-
return settablePromise;
19+
return promise.whenComplete(
20+
(httpResponse, exception) ->
21+
instrumenter().end(context, httpRequest, httpResponse, exception));
4822
}
4923

5024
private PromiseWrapper() {}

instrumentation/activej-http-6.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/activejhttp/ActivejHttpServerTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.javaagent.instrumentation.activejhttp;
77

8+
import static io.activej.common.exception.FatalErrorHandlers.rethrow;
89
import static io.activej.http.HttpMethod.GET;
910
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS;
1011
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
@@ -25,7 +26,6 @@
2526
import io.activej.http.HttpServer;
2627
import io.activej.http.RoutingServlet;
2728
import io.activej.promise.Promise;
28-
import io.activej.reactor.Reactor;
2929
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
3030
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
3131
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest;
@@ -37,12 +37,11 @@
3737

3838
class ActivejHttpServerTest extends AbstractHttpServerTest<HttpServer> {
3939

40-
@RegisterExtension static final EventloopExtension eventloopExtension = new EventloopExtension();
41-
4240
@RegisterExtension
4341
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent();
4442

45-
private static final Eventloop eventloop = Reactor.getCurrentReactor();
43+
private static final Eventloop eventloop =
44+
Eventloop.builder().withCurrentThread().withFatalErrorHandler(rethrow()).build();
4645
private Thread thread;
4746

4847
@Override

instrumentation/activej-http-6.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/activejhttp/ActivejRoutingServletTest.java

Lines changed: 0 additions & 111 deletions
This file was deleted.

instrumentation/activej-http-6.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/activejhttp/EventloopExtension.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)