Skip to content

Commit 655f7a5

Browse files
committed
Remove span collector
1 parent 334e922 commit 655f7a5

14 files changed

Lines changed: 15 additions & 526 deletions

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,13 @@ apitally:
9191
client-id: "your-client-id"
9292
env: "dev" # or "prod" etc.
9393

94-
# Optional: configure request logging and tracing
94+
# Optional: configure request logging
9595
request-logging:
9696
enabled: true
9797
request-headers-included: true
9898
request-body-included: true
9999
response-body-included: true
100100
log-capture-enabled: true
101-
tracing-enabled: true
102101
```
103102
104103
For further instructions, see our

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@
5454
<artifactId>oshi-core</artifactId>
5555
<version>6.9.2</version>
5656
</dependency>
57-
<dependency>
58-
<groupId>io.opentelemetry</groupId>
59-
<artifactId>opentelemetry-sdk</artifactId>
60-
<version>1.58.0</version>
61-
</dependency>
6257
<dependency>
6358
<groupId>com.github.spotbugs</groupId>
6459
<artifactId>spotbugs-annotations</artifactId>

src/main/java/io/apitally/common/ApitallyClient.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public enum HubRequestStatus {
6767

6868
public final RequestCounter requestCounter;
6969
public final RequestLogger requestLogger;
70-
public final SpanCollector spanCollector;
7170
public final ValidationErrorCounter validationErrorCounter;
7271
public final ServerErrorCounter serverErrorCounter;
7372
public final ConsumerRegistry consumerRegistry;
@@ -84,8 +83,6 @@ public ApitallyClient(String clientId, String env, RequestLoggingConfig requestL
8483

8584
this.requestCounter = new RequestCounter();
8685
this.requestLogger = new RequestLogger(requestLoggingConfig);
87-
this.spanCollector =
88-
new SpanCollector(requestLoggingConfig.isEnabled() && requestLoggingConfig.isTracingEnabled());
8986
this.validationErrorCounter = new ValidationErrorCounter();
9087
this.serverErrorCounter = new ServerErrorCounter();
9188
this.consumerRegistry = new ConsumerRegistry();

src/main/java/io/apitally/common/RequestLogger.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ public void logRequest(
131131
Request request,
132132
Response response,
133133
Exception exception,
134-
List<LogRecord> logs,
135-
List<SpanData> spans,
136-
String traceId) {
134+
List<LogRecord> logs) {
137135
if (!enabled || suspendUntil != null && suspendUntil > System.currentTimeMillis()) {
138136
return;
139137
}
@@ -171,12 +169,7 @@ public void logRequest(
171169
logs = null;
172170
}
173171

174-
if (!config.isTracingEnabled()) {
175-
spans = null;
176-
traceId = null;
177-
}
178-
179-
RequestLogItem item = new RequestLogItem(request, response, exceptionDto, logs, spans, traceId);
172+
RequestLogItem item = new RequestLogItem(request, response, exceptionDto, logs);
180173
pendingWrites.add(item);
181174

182175
if (pendingWrites.size() > MAX_PENDING_WRITES) {
@@ -284,12 +277,6 @@ public void writeToFile() throws IOException {
284277
if (item.getLogs() != null && !item.getLogs().isEmpty()) {
285278
itemNode.set("logs", objectMapper.valueToTree(item.getLogs()));
286279
}
287-
if (item.getSpans() != null && !item.getSpans().isEmpty()) {
288-
itemNode.set("spans", objectMapper.valueToTree(item.getSpans()));
289-
}
290-
if (item.getTraceId() != null && !item.getTraceId().isEmpty()) {
291-
itemNode.put("trace_id", item.getTraceId());
292-
}
293280

294281
String serializedItem = objectMapper.writeValueAsString(itemNode);
295282
currentFile.writeLine(serializedItem.getBytes(StandardCharsets.UTF_8));

src/main/java/io/apitally/common/SpanCollector.java

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

src/main/java/io/apitally/common/dto/RequestLogItem.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,17 @@ public class RequestLogItem extends BaseDto {
1010
private final Response response;
1111
private final ExceptionDto exception;
1212
private final List<LogRecord> logs;
13-
private final List<SpanData> spans;
14-
private final String traceId;
1513

1614
public RequestLogItem(
1715
Request request,
1816
Response response,
1917
ExceptionDto exception,
20-
List<LogRecord> logs,
21-
List<SpanData> spans,
22-
String traceId) {
18+
List<LogRecord> logs) {
2319
this.uuid = UUID.randomUUID().toString();
2420
this.request = request;
2521
this.response = response;
2622
this.exception = exception;
2723
this.logs = logs;
28-
this.spans = spans;
29-
this.traceId = traceId;
3024
}
3125

3226
@JsonProperty("uuid")
@@ -53,14 +47,4 @@ public ExceptionDto getException() {
5347
public List<LogRecord> getLogs() {
5448
return logs;
5549
}
56-
57-
@JsonProperty("spans")
58-
public List<SpanData> getSpans() {
59-
return spans;
60-
}
61-
62-
@JsonProperty("trace_id")
63-
public String getTraceId() {
64-
return traceId;
65-
}
6650
}

src/main/java/io/apitally/spring/ApitallyAutoConfiguration.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ public ApitallyClient apitallyClient(
2929
&& properties.getRequestLogging().isLogCaptureEnabled()) {
3030
LogAppender.register();
3131
}
32-
if (properties.getRequestLogging().isEnabled()
33-
&& properties.getRequestLogging().isTracingEnabled()) {
34-
ApitallySpanCollector.getInstance().setDelegate(client.spanCollector);
35-
}
3632

3733
return client;
3834
}

src/main/java/io/apitally/spring/ApitallyFilter.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import io.apitally.common.LogAppender;
66
import io.apitally.common.RequestLogger;
77
import io.apitally.common.RequestLoggingConfig;
8-
import io.apitally.common.SpanCollector;
98
import io.apitally.common.dto.Consumer;
109
import io.apitally.common.dto.Header;
1110
import io.apitally.common.dto.LogRecord;
@@ -82,8 +81,6 @@ protected void doFilterInternal(
8281
LogAppender.startCapture();
8382
}
8483

85-
final SpanCollector.SpanHandle spanHandle = shouldCaptureSpans ? client.spanCollector.startCollection() : null;
86-
8784
try {
8885
filterChain.doFilter(
8986
cachingRequest != null ? cachingRequest : request,
@@ -96,20 +93,6 @@ protected void doFilterInternal(
9693
final long responseTimeInMillis = System.currentTimeMillis() - startTime;
9794
final String path = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
9895

99-
// End span collection and get spans
100-
List<SpanData> spans = null;
101-
String traceId = null;
102-
if (spanHandle != null) {
103-
Object handler = request.getAttribute(HandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE);
104-
if (handler instanceof HandlerMethod handlerMethod) {
105-
String controllerName = handlerMethod.getBeanType().getSimpleName();
106-
String methodName = handlerMethod.getMethod().getName();
107-
spanHandle.setName(controllerName + "." + methodName);
108-
}
109-
spans = spanHandle.end();
110-
traceId = spanHandle.getTraceId();
111-
}
112-
11396
// End log capture and get logs
11497
final List<LogRecord> capturedLogs = shouldCaptureLogs ? LogAppender.endCapture() : null;
11598

@@ -180,9 +163,7 @@ protected void doFilterInternal(
180163
responseSize,
181164
responseBody),
182165
exception,
183-
capturedLogs,
184-
spans,
185-
traceId);
166+
capturedLogs);
186167
}
187168

188169
// Add validation error to counter

0 commit comments

Comments
 (0)