Skip to content

Commit d703e90

Browse files
Merge branch 'master' into paul.laffon/data-jobs-enabled
2 parents 57d83ad + 6978c8e commit d703e90

42 files changed

Lines changed: 883 additions & 455 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

buildSrc/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
groovy
33
`java-gradle-plugin`
4+
`kotlin-dsl`
45
id("com.diffplug.spotless") version "6.13.0"
56
}
67

@@ -16,7 +17,7 @@ gradlePlugin {
1617
}
1718
create("call-site-instrumentation-plugin") {
1819
id = "call-site-instrumentation"
19-
implementationClass = "CallSiteInstrumentationPlugin"
20+
implementationClass = "datadog.gradle.plugin.CallSiteInstrumentationPlugin"
2021
}
2122
create("otel-converter-plugin") {
2223
id = "otel-converter"
@@ -53,7 +54,7 @@ dependencies {
5354
testImplementation("io.opentelemetry.javaagent.instrumentation", "opentelemetry-javaagent-grpc-1.6", "1.32.0-alpha")
5455
}
5556

56-
tasks.compileGroovy {
57+
tasks.compileKotlin {
5758
dependsOn(":call-site-instrumentation-plugin:build")
5859
}
5960

buildSrc/call-site-instrumentation-plugin/src/main/java/datadog/trace/plugin/csi/CallSiteReporter.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,31 @@
44
import freemarker.template.Configuration;
55
import freemarker.template.Template;
66
import java.io.PrintStream;
7+
import java.io.PrintWriter;
78
import java.io.StringWriter;
89
import java.io.Writer;
910
import java.util.HashMap;
11+
import java.util.HashSet;
1012
import java.util.List;
1113
import java.util.Map;
14+
import java.util.Set;
1215

1316
public interface CallSiteReporter {
1417

1518
void report(List<CallSiteResult> results, boolean error);
1619

17-
static CallSiteReporter getReporter(final String type) {
18-
if ("CONSOLE".equals(type)) {
19-
return new ConsoleReporter();
20+
static Set<CallSiteReporter> getReporter(PluginApplication.Configuration configuration) {
21+
Set<CallSiteReporter> reporters = new HashSet<>();
22+
for (String type : configuration.getReporters()) {
23+
if ("CONSOLE".equals(type)) {
24+
reporters.add(new ConsoleReporter());
25+
} else if ("ERROR_CONSOLE".equals(type)) {
26+
reporters.add(new ErrorConsoleReporter());
27+
} else {
28+
throw new IllegalArgumentException("Reporter of type '" + type + "' not supported");
29+
}
2030
}
21-
throw new IllegalArgumentException("Reporter of type '" + type + "' not supported");
31+
return reporters;
2232
}
2333

2434
abstract class FreemarkerReporter implements CallSiteReporter {
@@ -44,7 +54,6 @@ protected void write(final List<CallSiteResult> results, final Writer writer) {
4454
}
4555

4656
class ConsoleReporter extends FreemarkerReporter {
47-
4857
protected ConsoleReporter() {
4958
super("console.ftl");
5059
}
@@ -57,4 +66,17 @@ public void report(final List<CallSiteResult> results, final boolean error) {
5766
stream.println(writer);
5867
}
5968
}
69+
70+
class ErrorConsoleReporter extends FreemarkerReporter {
71+
protected ErrorConsoleReporter() {
72+
super("console.ftl");
73+
}
74+
75+
@Override
76+
public void report(final List<CallSiteResult> results, final boolean error) {
77+
if (error) {
78+
write(results, new PrintWriter(System.err));
79+
}
80+
}
81+
}
6082
}

buildSrc/call-site-instrumentation-plugin/src/main/java/datadog/trace/plugin/csi/PluginApplication.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ private static Function<CallSiteSpecification, CallSiteResult> generateAdviceClo
6565

6666
private static void printReport(
6767
final Configuration configuration, final List<CallSiteResult> result, final boolean failed) {
68-
configuration.reporters.forEach(
69-
reporter -> CallSiteReporter.getReporter(reporter).report(result, failed));
68+
CallSiteReporter.getReporter(configuration)
69+
.forEach(reporter -> reporter.report(result, failed));
7070
}
7171

7272
private static List<CallSiteSpecification> searchForCallSites(final Configuration configuration) {
@@ -77,8 +77,7 @@ private static List<CallSiteSpecification> searchForCallSites(final Configuratio
7777
Files.walkFileTree(
7878
configuration.classesFolder,
7979
new SimpleFileVisitor<Path>() {
80-
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs)
81-
throws IOException {
80+
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) {
8281
if (Files.isRegularFile(file)
8382
&& pattern.matcher(file.getFileName().toString()).matches()) {
8483
builder.build(file.toFile()).ifPresent(result::add);

buildSrc/settings.gradle

Lines changed: 0 additions & 1 deletion
This file was deleted.

buildSrc/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include(":call-site-instrumentation-plugin")

buildSrc/src/main/groovy/CallSiteInstrumentationPlugin.groovy

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

0 commit comments

Comments
 (0)