Skip to content

Commit 0a2d912

Browse files
committed
Resolved build check issues (ex. spotlessCheck)
1 parent e51a735 commit 0a2d912

10 files changed

+185
-144
lines changed

.fossa.yml

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ targets:
4949
- type: gradle
5050
path: ./
5151
target: ':testing:agent-for-testing'
52+
- type: gradle
53+
path: ./
54+
target: ':instrumentation:activej-http:javaagent'
5255
- type: gradle
5356
path: ./
5457
target: ':instrumentation:alibaba-druid-1.0:javaagent'

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

+38-32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.javaagent.instrumentation.activejhttp;
27

38
import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext;
@@ -25,10 +30,10 @@
2530
import net.bytebuddy.matcher.ElementMatcher;
2631

2732
/**
28-
* <p>This class provides instrumentation for ActiveJ HTTP server connections by applying advice to the
29-
* {@code serve} method of classes that extend {@code io.activej.http.AsyncServlet}. The instrumentation is
30-
* designed to integrate with OpenTelemetry for distributed tracing, capturing and propagating trace context
31-
* through HTTP requests and responses.</p>
33+
* This class provides instrumentation for ActiveJ HTTP server connections by applying advice to the
34+
* {@code serve} method of classes that extend {@code io.activej.http.AsyncServlet}. The
35+
* instrumentation is designed to integrate with OpenTelemetry for distributed tracing, capturing
36+
* and propagating trace context through HTTP requests and responses.
3237
*
3338
* @author Krishna Chaitanya Surapaneni
3439
*/
@@ -41,37 +46,39 @@ public class ActiveJHttpServerConnectionInstrumentation implements TypeInstrumen
4146
*/
4247
@Override
4348
public ElementMatcher<TypeDescription> typeMatcher() {
44-
return hasSuperType(named("io.activej.http.AsyncServlet"))
45-
.and(not(isInterface()));
49+
return hasSuperType(named("io.activej.http.AsyncServlet")).and(not(isInterface()));
4650
}
4751

4852
/**
49-
* Applies advice to the {@code serve} method of the matched classes. The advice captures trace context
50-
* at the start of the method and propagates it through the response.
53+
* Applies advice to the {@code serve} method of the matched classes. The advice captures trace
54+
* context at the start of the method and propagates it through the response.
5155
*
5256
* @param transformer The {@code TypeTransformer} used to apply the advice.
5357
*/
5458
@Override
5559
public void transform(TypeTransformer transformer) {
5660
transformer.applyAdviceToMethod(
57-
isMethod().and(named("serve")).and(takesArguments(1)
58-
.and(takesArgument(0, named("io.activej.http.HttpRequest")))),
61+
isMethod()
62+
.and(named("serve"))
63+
.and(takesArguments(1).and(takesArgument(0, named("io.activej.http.HttpRequest")))),
5964
this.getClass().getName() + "$ServeAdvice");
6065
}
6166

6267
/**
63-
* <p>Inner class containing the advice logic for the {@code serve} method. This class defines two methods:</p>
68+
* Inner class containing the advice logic for the {@code serve} method. This class defines two
69+
* methods:
70+
*
6471
* <ul>
65-
* <li>{@code methodEnter}: Captures the trace context at the start of the method.</li>
66-
* <li>{@code methodExit}: Propagates the trace context to the response and ends the span.</li>
72+
* <li>{@code methodEnter}: Captures the trace context at the start of the method.
73+
* <li>{@code methodExit}: Propagates the trace context to the response and ends the span.
6774
* </ul>
6875
*/
6976
@SuppressWarnings("unused")
7077
public static class ServeAdvice {
7178

7279
/**
73-
* Advice executed at the start of the {@code serve} method. Captures the current trace context and
74-
* starts a new span if tracing is enabled for the request.
80+
* Advice executed at the start of the {@code serve} method. Captures the current trace context
81+
* and starts a new span if tracing is enabled for the request.
7582
*
7683
* @param asyncServlet The {@code AsyncServlet} instance handling the request.
7784
* @param request The incoming HTTP request.
@@ -96,8 +103,8 @@ public static void methodEnter(
96103
}
97104

98105
/**
99-
* Advice executed at the end of the {@code serve} method. Propagates the trace context to the response,
100-
* handles exceptions, and ends the span.
106+
* Advice executed at the end of the {@code serve} method. Propagates the trace context to the
107+
* response, handles exceptions, and ends the span.
101108
*
102109
* @param asyncServlet The {@code AsyncServlet} instance handling the request.
103110
* @param responsePromise The promise representing the HTTP response.
@@ -119,8 +126,8 @@ public static void methodExit(
119126
}
120127
String traceId = Span.fromContext(context).getSpanContext().getTraceId();
121128
String spanId = Span.fromContext(context).getSpanContext().getSpanId();
122-
String traceFlags = Span.fromContext(context).getSpanContext().getTraceFlags().asHex()
123-
.substring(0, 2);
129+
String traceFlags =
130+
Span.fromContext(context).getSpanContext().getTraceFlags().asHex().substring(0, 2);
124131
String traceparent = String.format("00-%s-%s-%s", traceId, spanId, traceFlags);
125132

126133
scope.close();
@@ -135,24 +142,23 @@ public static void methodExit(
135142
instrumenter().end(context, httpRequest, httpResponse, error);
136143
responsePromise = Promise.of(httpResponse);
137144
} else if (throwable != null) {
138-
HttpResponse httpResponse = HttpResponse.builder()
139-
.withCode(500)
140-
.withPlainText(throwable.getMessage())
141-
.withHeader(HttpHeaders.of(traceparentHeader), traceparent)
142-
.build();
143-
instrumenter().end(context, httpRequest, httpResponse,
144-
throwable);
145+
HttpResponse httpResponse =
146+
HttpResponse.builder()
147+
.withCode(500)
148+
.withPlainText(throwable.getMessage())
149+
.withHeader(HttpHeaders.of(traceparentHeader), traceparent)
150+
.build();
151+
instrumenter().end(context, httpRequest, httpResponse, throwable);
145152
responsePromise = Promise.of(httpResponse);
146153
throwable = null;
147154
} else {
148-
HttpResponse httpResponse = HttpResponse.notFound404()
149-
.withHeader(HttpHeaders.of(traceparentHeader), traceparent)
150-
.build();
151-
instrumenter().end(context, httpRequest, httpResponse,
152-
throwable);
155+
HttpResponse httpResponse =
156+
HttpResponse.notFound404()
157+
.withHeader(HttpHeaders.of(traceparentHeader), traceparent)
158+
.build();
159+
instrumenter().end(context, httpRequest, httpResponse, throwable);
153160
responsePromise = Promise.of(httpResponse);
154161
}
155162
}
156163
}
157-
158164
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.javaagent.instrumentation.activejhttp;
27

38
import static java.util.Collections.singletonList;
@@ -9,31 +14,34 @@
914
import java.util.List;
1015

1116
/**
12-
* <p>This class is an instrumentation module for ActiveJ HTTP server connections. It integrates with
13-
* OpenTelemetry to provide distributed tracing capabilities for applications using the ActiveJ HTTP server.</p>
17+
* This class is an instrumentation module for ActiveJ HTTP server connections. It integrates with
18+
* OpenTelemetry to provide distributed tracing capabilities for applications using the ActiveJ HTTP
19+
* server.
1420
*
15-
* <p>The module is annotated with {@code @AutoService(InstrumentationModule.class)}, which automatically
16-
* registers it as a service provider for the OpenTelemetry instrumentation framework. This allows the module
17-
* to be discovered and loaded dynamically during runtime.</p>
21+
* <p>The module is annotated with {@code @AutoService(InstrumentationModule.class)}, which
22+
* automatically registers it as a service provider for the OpenTelemetry instrumentation framework.
23+
* This allows the module to be discovered and loaded dynamically during runtime.
1824
*
1925
* @author Krishna Chaitanya Surapaneni
2026
*/
2127
@AutoService(InstrumentationModule.class)
2228
public class ActiveJHttpServerConnectionInstrumentationModule extends InstrumentationModule {
2329

2430
/**
25-
* Constructs the instrumentation module with the specified instrumentation names. These names are used to
26-
* identify the instrumentation in the OpenTelemetry framework.
31+
* Constructs the instrumentation module with the specified instrumentation names. These names are
32+
* used to identify the instrumentation in the OpenTelemetry framework.
2733
*
28-
* <p>In this case, the module is identified by the names "activej-http" and "activej-http-server".</p>
34+
* <p>In this case, the module is identified by the names "activej-http" and
35+
* "activej-http-server".
2936
*/
3037
public ActiveJHttpServerConnectionInstrumentationModule() {
3138
super("activej-http", "activej-http-server");
3239
}
3340

3441
/**
35-
* Returns a list of type instrumentation's provided by this module. Each type instrumentation applies advice
36-
* to specific methods or classes to capture trace context and propagate it through HTTP requests and responses.
42+
* Returns a list of type instrumentation's provided by this module. Each type instrumentation
43+
* applies advice to specific methods or classes to capture trace context and propagate it through
44+
* HTTP requests and responses.
3745
*
3846
* @return A list containing the {@code ActiveJHttpServerConnectionInstrumentation} instance.
3947
*/
@@ -43,17 +51,16 @@ public List<TypeInstrumentation> typeInstrumentations() {
4351
}
4452

4553
/**
46-
* Registers helper resources required for the instrumentation. Helper resources are typically utility classes
47-
* or configurations that support the instrumentation logic.
54+
* Registers helper resources required for the instrumentation. Helper resources are typically
55+
* utility classes or configurations that support the instrumentation logic.
4856
*
49-
* <p>In this case, the {@code ActiveJHttpServerHelper} class is registered as a helper resource. This class
50-
* provides utilities for creating HTTP responses with trace context.</p>
57+
* <p>In this case, the {@code ActiveJHttpServerHelper} class is registered as a helper resource.
58+
* This class provides utilities for creating HTTP responses with trace context.
5159
*
5260
* @param helperResourceBuilder The builder used to register helper resources.
5361
*/
5462
@Override
5563
public void registerHelperResources(HelperResourceBuilder helperResourceBuilder) {
5664
helperResourceBuilder.register(ActiveJHttpServerHelper.class.getName());
5765
}
58-
5966
}

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.javaagent.instrumentation.activejhttp;
27

38
import io.activej.http.HttpRequest;
@@ -6,9 +11,9 @@
611
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
712

813
/**
9-
* <p>This class provides singleton instances and utilities for ActiveJ HTTP server instrumentation. It is
10-
* designed to centralize the creation and access of OpenTelemetry-related components, such as the
11-
* {@code Instrumenter} used for tracing HTTP requests and responses.</p>
14+
* This class provides singleton instances and utilities for ActiveJ HTTP server instrumentation. It
15+
* is designed to centralize the creation and access of OpenTelemetry-related components, such as
16+
* the {@code Instrumenter} used for tracing HTTP requests and responses.
1217
*
1318
* @author Krishna Chaitanya Surapaneni
1419
*/

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

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.javaagent.instrumentation.activejhttp;
27

38
import io.activej.http.HttpHeader;
@@ -12,9 +17,9 @@
1217
import java.util.stream.Collectors;
1318

1419
/**
15-
* <p>This enum implements the {@code ExtendedTextMapGetter<HttpRequest>} interface and provides methods for
16-
* extracting HTTP headers from an ActiveJ {@code HttpRequest}. It is used in the context of OpenTelemetry
17-
* instrumentation to propagate trace context across service boundaries.</p>
20+
* This enum implements the {@code ExtendedTextMapGetter<HttpRequest>} interface and provides
21+
* methods for extracting HTTP headers from an ActiveJ {@code HttpRequest}. It is used in the
22+
* context of OpenTelemetry instrumentation to propagate trace context across service boundaries.
1823
*
1924
* @author Krishna Chaitanya Surapaneni
2025
*/
@@ -48,5 +53,4 @@ public Iterator<String> getAll(HttpRequest carrier, String key) {
4853
}
4954
return values.iterator();
5055
}
51-
5256
}

0 commit comments

Comments
 (0)