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

Fix CI Visibility Manual API to not fail when there is no tracer injected #6192

Merged
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
4 changes: 4 additions & 0 deletions dd-trace-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ excludedClassesCoverage += [
'datadog.trace.api.internal.TraceSegment.NoOp',
'datadog.trace.api.civisibility.CIVisibility',
'datadog.trace.api.civisibility.DDTestModule',
'datadog.trace.api.civisibility.noop.NoOpDDTest',
'datadog.trace.api.civisibility.noop.NoOpDDTestModule',
'datadog.trace.api.civisibility.noop.NoOpDDTestSession',
'datadog.trace.api.civisibility.noop.NoOpDDTestSuite',
'datadog.trace.api.config.ProfilingConfig',
'datadog.trace.api.interceptor.MutableSpan',
'datadog.trace.api.profiling.Profiling',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package datadog.trace.api.civisibility;

import datadog.trace.api.civisibility.noop.NoOpDDTestSession;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.annotation.Nullable;

public class CIVisibility {

private static volatile SessionFactory SESSION_FACTORY =
(projectName, projectRoot, component, startTime) -> {
throw new UnsupportedOperationException(
"session factory not registered, please ensure CI Visibility feature is enabled");
};
(projectName, projectRoot, component, startTime) -> NoOpDDTestSession.INSTANCE;

/**
* This a hook for injecting SessionFactory implementation. It should only be used internally by
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package datadog.trace.api.civisibility.noop;

import datadog.trace.api.civisibility.DDTest;
import javax.annotation.Nullable;

public class NoOpDDTest implements DDTest {
static final DDTest INSTANCE = new NoOpDDTest();

@Override
public void setTag(String key, Object value) {}

@Override
public void setErrorInfo(@Nullable Throwable error) {}

@Override
public void setSkipReason(@Nullable String skipReason) {}

@Override
public void end(@Nullable Long endTime) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package datadog.trace.api.civisibility.noop;

import datadog.trace.api.civisibility.DDTestModule;
import datadog.trace.api.civisibility.DDTestSuite;
import javax.annotation.Nullable;

public class NoOpDDTestModule implements DDTestModule {
static final DDTestModule INSTANCE = new NoOpDDTestModule();

@Override
public void setTag(String key, Object value) {}

@Override
public void setErrorInfo(Throwable error) {}

@Override
public void setSkipReason(String skipReason) {}

@Override
public void end(@Nullable Long endTime) {}

@Override
public DDTestSuite testSuiteStart(
String testSuiteName,
@Nullable Class<?> testClass,
@Nullable Long startTime,
boolean parallelized) {
return NoOpDDTestSuite.INSTANCE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package datadog.trace.api.civisibility.noop;

import datadog.trace.api.civisibility.DDTestModule;
import datadog.trace.api.civisibility.DDTestSession;
import javax.annotation.Nullable;

public class NoOpDDTestSession implements DDTestSession {
public static final DDTestSession INSTANCE = new NoOpDDTestSession();

@Override
public void setTag(String key, Object value) {}

@Override
public void setErrorInfo(Throwable error) {}

@Override
public void setSkipReason(String skipReason) {}

@Override
public void end(@Nullable Long endTime) {}

@Override
public DDTestModule testModuleStart(String moduleName, @Nullable Long startTime) {
return NoOpDDTestModule.INSTANCE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package datadog.trace.api.civisibility.noop;

import datadog.trace.api.civisibility.DDTest;
import datadog.trace.api.civisibility.DDTestSuite;
import java.lang.reflect.Method;
import javax.annotation.Nullable;

public class NoOpDDTestSuite implements DDTestSuite {
static final DDTestSuite INSTANCE = new NoOpDDTestSuite();

@Override
public void setTag(String key, Object value) {}

@Override
public void setErrorInfo(Throwable error) {}

@Override
public void setSkipReason(String skipReason) {}

@Override
public void end(@Nullable Long endTime) {}

@Override
public DDTest testStart(String testName, @Nullable Method testMethod, @Nullable Long startTime) {
return NoOpDDTest.INSTANCE;
}
}
Loading