Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ apitally:
client-id: "your-client-id"
env: "dev" # or "prod" etc.

# Optional: configure request logging and tracing
# Optional: configure request logging
request-logging:
enabled: true
request-headers-included: true
request-body-included: true
response-body-included: true
log-capture-enabled: true
tracing-enabled: true
```

For further instructions, see our
Expand Down
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
<artifactId>oshi-core</artifactId>
<version>6.9.2</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<version>1.58.0</version>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/io/apitally/common/ApitallyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public enum HubRequestStatus {

public final RequestCounter requestCounter;
public final RequestLogger requestLogger;
public final SpanCollector spanCollector;
public final ValidationErrorCounter validationErrorCounter;
public final ServerErrorCounter serverErrorCounter;
public final ConsumerRegistry consumerRegistry;
Expand All @@ -84,8 +83,6 @@ public ApitallyClient(String clientId, String env, RequestLoggingConfig requestL

this.requestCounter = new RequestCounter();
this.requestLogger = new RequestLogger(requestLoggingConfig);
this.spanCollector =
new SpanCollector(requestLoggingConfig.isEnabled() && requestLoggingConfig.isTracingEnabled());
this.validationErrorCounter = new ValidationErrorCounter();
this.serverErrorCounter = new ServerErrorCounter();
this.consumerRegistry = new ConsumerRegistry();
Expand Down
17 changes: 2 additions & 15 deletions src/main/java/io/apitally/common/RequestLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ public void logRequest(
Request request,
Response response,
Exception exception,
List<LogRecord> logs,
List<SpanData> spans,
String traceId) {
List<LogRecord> logs) {
if (!enabled || suspendUntil != null && suspendUntil > System.currentTimeMillis()) {
return;
}
Expand Down Expand Up @@ -171,12 +169,7 @@ public void logRequest(
logs = null;
}

if (!config.isTracingEnabled()) {
spans = null;
traceId = null;
}

RequestLogItem item = new RequestLogItem(request, response, exceptionDto, logs, spans, traceId);
RequestLogItem item = new RequestLogItem(request, response, exceptionDto, logs);
pendingWrites.add(item);

if (pendingWrites.size() > MAX_PENDING_WRITES) {
Expand Down Expand Up @@ -284,12 +277,6 @@ public void writeToFile() throws IOException {
if (item.getLogs() != null && !item.getLogs().isEmpty()) {
itemNode.set("logs", objectMapper.valueToTree(item.getLogs()));
}
if (item.getSpans() != null && !item.getSpans().isEmpty()) {
itemNode.set("spans", objectMapper.valueToTree(item.getSpans()));
}
if (item.getTraceId() != null && !item.getTraceId().isEmpty()) {
itemNode.put("trace_id", item.getTraceId());
}

String serializedItem = objectMapper.writeValueAsString(itemNode);
currentFile.writeLine(serializedItem.getBytes(StandardCharsets.UTF_8));
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/io/apitally/common/RequestLoggingConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class RequestLoggingConfig {
private boolean responseBodyIncluded = false;
private boolean exceptionIncluded = true;
private boolean logCaptureEnabled = false;
private boolean tracingEnabled = false;
private List<String> queryParamMaskPatterns = new ArrayList<>();
private List<String> headerMaskPatterns = new ArrayList<>();
private List<String> bodyFieldMaskPatterns = new ArrayList<>();
Expand Down Expand Up @@ -83,14 +82,6 @@ public void setLogCaptureEnabled(boolean logCaptureEnabled) {
this.logCaptureEnabled = logCaptureEnabled;
}

public boolean isTracingEnabled() {
return tracingEnabled;
}

public void setTracingEnabled(boolean tracingEnabled) {
this.tracingEnabled = tracingEnabled;
}

public List<String> getQueryParamMaskPatterns() {
return queryParamMaskPatterns;
}
Expand Down
178 changes: 0 additions & 178 deletions src/main/java/io/apitally/common/SpanCollector.java

This file was deleted.

18 changes: 1 addition & 17 deletions src/main/java/io/apitally/common/dto/RequestLogItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,17 @@ public class RequestLogItem extends BaseDto {
private final Response response;
private final ExceptionDto exception;
private final List<LogRecord> logs;
private final List<SpanData> spans;
private final String traceId;

public RequestLogItem(
Request request,
Response response,
ExceptionDto exception,
List<LogRecord> logs,
List<SpanData> spans,
String traceId) {
List<LogRecord> logs) {
this.uuid = UUID.randomUUID().toString();
this.request = request;
this.response = response;
this.exception = exception;
this.logs = logs;
this.spans = spans;
this.traceId = traceId;
}

@JsonProperty("uuid")
Expand All @@ -53,14 +47,4 @@ public ExceptionDto getException() {
public List<LogRecord> getLogs() {
return logs;
}

@JsonProperty("spans")
public List<SpanData> getSpans() {
return spans;
}

@JsonProperty("trace_id")
public String getTraceId() {
return traceId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ public ApitallyClient apitallyClient(
&& properties.getRequestLogging().isLogCaptureEnabled()) {
LogAppender.register();
}
if (properties.getRequestLogging().isEnabled()
&& properties.getRequestLogging().isTracingEnabled()) {
ApitallySpanCollector.getInstance().setDelegate(client.spanCollector);
}

return client;
}
Expand Down
22 changes: 1 addition & 21 deletions src/main/java/io/apitally/spring/ApitallyFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.apitally.common.LogAppender;
import io.apitally.common.RequestLogger;
import io.apitally.common.RequestLoggingConfig;
import io.apitally.common.SpanCollector;
import io.apitally.common.dto.Consumer;
import io.apitally.common.dto.Header;
import io.apitally.common.dto.LogRecord;
Expand Down Expand Up @@ -73,7 +72,6 @@ protected void doFilterInternal(
cachingResponse == null ? new CountingResponseWrapper(response) : null;

final boolean shouldCaptureLogs = requestLoggingEnabled && requestLoggingConfig.isLogCaptureEnabled();
final boolean shouldCaptureSpans = requestLoggingEnabled && requestLoggingConfig.isTracingEnabled();

Exception exception = null;
final long startTime = System.currentTimeMillis();
Expand All @@ -82,8 +80,6 @@ protected void doFilterInternal(
LogAppender.startCapture();
}

final SpanCollector.SpanHandle spanHandle = shouldCaptureSpans ? client.spanCollector.startCollection() : null;

try {
filterChain.doFilter(
cachingRequest != null ? cachingRequest : request,
Expand All @@ -96,20 +92,6 @@ protected void doFilterInternal(
final long responseTimeInMillis = System.currentTimeMillis() - startTime;
final String path = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);

// End span collection and get spans
List<SpanData> spans = null;
String traceId = null;
if (spanHandle != null) {
Object handler = request.getAttribute(HandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE);
if (handler instanceof HandlerMethod handlerMethod) {
String controllerName = handlerMethod.getBeanType().getSimpleName();
String methodName = handlerMethod.getMethod().getName();
spanHandle.setName(controllerName + "." + methodName);
}
spans = spanHandle.end();
traceId = spanHandle.getTraceId();
}

// End log capture and get logs
final List<LogRecord> capturedLogs = shouldCaptureLogs ? LogAppender.endCapture() : null;

Expand Down Expand Up @@ -180,9 +162,7 @@ protected void doFilterInternal(
responseSize,
responseBody),
exception,
capturedLogs,
spans,
traceId);
capturedLogs);
}

// Add validation error to counter
Expand Down
Loading
Loading