Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter exit errors by operation name #18850

Merged
merged 3 commits into from
Nov 2, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package io.airbyte.workers.tracing;

import static io.airbyte.metrics.lib.ApmTraceConstants.WORKFLOW_TRACE_OPERATION_NAME;

import com.google.common.annotations.VisibleForTesting;
import datadog.trace.api.interceptor.MutableSpan;
import datadog.trace.api.interceptor.TraceInterceptor;
Expand All @@ -19,11 +21,6 @@
@Slf4j
public class TemporalSdkInterceptor implements TraceInterceptor {

/**
* Trace resource name used to scope the filtering performed by this interceptor.
*/
static final String CONNECTION_MANAGER_WORKFLOW_IMPL_RESOURCE_NAME = "ConnectionManagerWorkflowImpl.run";

/**
* Error message tag key name that contains the Temporal exit error message.
*/
Expand Down Expand Up @@ -76,7 +73,7 @@ boolean isExitTrace(final MutableSpan trace) {

return trace.isError() &&
EXIT_ERROR_MESSAGE.equalsIgnoreCase(trace.getTags().getOrDefault(ERROR_MESSAGE_TAG_KEY, "").toString()) &&
CONNECTION_MANAGER_WORKFLOW_IMPL_RESOURCE_NAME.equalsIgnoreCase(trace.getResourceName().toString());
WORKFLOW_TRACE_OPERATION_NAME.equalsIgnoreCase(trace.getOperationName().toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DummySpan implements MutableSpan {

private final Map<String, Object> tags = new HashMap<>();
private boolean error = false;

private String operationName = null;
private String resourceName = null;

@Override
Expand All @@ -27,12 +27,13 @@ public long getDurationNano() {

@Override
public CharSequence getOperationName() {
return null;
return operationName;
}

@Override
public MutableSpan setOperationName(final CharSequence serviceName) {
return null;
public MutableSpan setOperationName(final CharSequence operationName) {
this.operationName = operationName != null ? operationName.toString() : null;
return this;
}

@Override
Expand All @@ -52,7 +53,7 @@ public CharSequence getResourceName() {

@Override
public MutableSpan setResourceName(final CharSequence resourceName) {
this.resourceName = resourceName.toString();
this.resourceName = resourceName != null ? resourceName.toString() : null;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package io.airbyte.workers.tracing;

import static io.airbyte.workers.tracing.TemporalSdkInterceptor.CONNECTION_MANAGER_WORKFLOW_IMPL_RESOURCE_NAME;
import static io.airbyte.metrics.lib.ApmTraceConstants.WORKFLOW_TRACE_OPERATION_NAME;
import static io.airbyte.workers.tracing.TemporalSdkInterceptor.ERROR_MESSAGE_TAG_KEY;
import static io.airbyte.workers.tracing.TemporalSdkInterceptor.EXIT_ERROR_MESSAGE;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -25,23 +25,23 @@ void testOnTraceComplete() {

final var noError = new DummySpan();
noError.setError(false);
noError.setResourceName(CONNECTION_MANAGER_WORKFLOW_IMPL_RESOURCE_NAME);
noError.setOperationName(WORKFLOW_TRACE_OPERATION_NAME);
noError.setTag("tag", "value");

final var otherError = new DummySpan();
otherError.setError(true);
otherError.setResourceName(CONNECTION_MANAGER_WORKFLOW_IMPL_RESOURCE_NAME);
otherError.setOperationName(WORKFLOW_TRACE_OPERATION_NAME);
otherError.setTag("error.message", "some other error");

final var temporalExitMsgError = new DummySpan();
temporalExitMsgError.setError(true);
temporalExitMsgError.setOperationName(WORKFLOW_TRACE_OPERATION_NAME);
temporalExitMsgError.setTag(ERROR_MESSAGE_TAG_KEY, EXIT_ERROR_MESSAGE);
temporalExitMsgError.setResourceName(CONNECTION_MANAGER_WORKFLOW_IMPL_RESOURCE_NAME);

final var temporalExitMsgOtherResourceError = new DummySpan();
temporalExitMsgOtherResourceError.setError(true);
temporalExitMsgOtherResourceError.setOperationName("OtherOperation");
temporalExitMsgOtherResourceError.setTag(ERROR_MESSAGE_TAG_KEY, EXIT_ERROR_MESSAGE);
temporalExitMsgOtherResourceError.setResourceName("OtherResource.run");

final var spans = List.of(
simple, noError, otherError, temporalExitMsgError, temporalExitMsgOtherResourceError);
Expand All @@ -65,24 +65,24 @@ void testIsExitTrace() {
assertEquals(false, interceptor.isExitTrace(new DummySpan()));

final var temporalTrace = new DummySpan();
temporalTrace.setResourceName(CONNECTION_MANAGER_WORKFLOW_IMPL_RESOURCE_NAME);
temporalTrace.setOperationName(WORKFLOW_TRACE_OPERATION_NAME);
assertEquals(false, interceptor.isExitTrace(temporalTrace));

final var temporalTraceWithError = new DummySpan();
temporalTraceWithError.setError(true);
temporalTraceWithError.setResourceName(CONNECTION_MANAGER_WORKFLOW_IMPL_RESOURCE_NAME);
temporalTraceWithError.setOperationName(WORKFLOW_TRACE_OPERATION_NAME);
assertEquals(false, interceptor.isExitTrace(temporalTraceWithError));

final var temporalTraceWithExitError = new DummySpan();
temporalTraceWithExitError.setError(true);
temporalTraceWithExitError.setOperationName(WORKFLOW_TRACE_OPERATION_NAME);
temporalTraceWithExitError.setTag(ERROR_MESSAGE_TAG_KEY, EXIT_ERROR_MESSAGE);
temporalTraceWithExitError.setResourceName(CONNECTION_MANAGER_WORKFLOW_IMPL_RESOURCE_NAME);
assertEquals(true, interceptor.isExitTrace(temporalTraceWithExitError));

final var otherTemporalTraceWithExitError = new DummySpan();
otherTemporalTraceWithExitError.setError(true);
otherTemporalTraceWithExitError.setOperationName("OtherOperation");
otherTemporalTraceWithExitError.setTag(ERROR_MESSAGE_TAG_KEY, EXIT_ERROR_MESSAGE);
otherTemporalTraceWithExitError.setResourceName("OtherResource");
assertEquals(false, interceptor.isExitTrace(otherTemporalTraceWithExitError));
}

Expand Down