Skip to content

Commit 4be2999

Browse files
authored
Merge branch 'master' into mhlidd/pending_traces
2 parents 97e8bef + 7afe313 commit 4be2999

File tree

186 files changed

+4932
-1554
lines changed

Some content is hidden

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

186 files changed

+4932
-1554
lines changed

.circleci/config.continue.yml.j2

+13-3
Original file line numberDiff line numberDiff line change
@@ -953,13 +953,23 @@ jobs:
953953
no_output_timeout: 5m
954954
command: |
955955
cd system-tests
956-
DD_SITE=datadoghq.com DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY DD_APPLICATION_KEY=$SYSTEM_TESTS_E2E_DD_APP_KEY ./run.sh DEBUGGER_SCENARIOS
956+
export DD_API_KEY=$SYSTEM_TESTS_E2E_DD_API_KEY
957+
./run.sh DEBUGGER_SCENARIOS
958+
959+
- run:
960+
name: Collect log files
961+
no_output_timeout: 5m
962+
command: |
963+
mkdir -p logs_debugger
964+
for dir in system-tests/logs*/; do
965+
cp -r "$dir" logs_debugger
966+
done
957967
958968
- store_test_results:
959-
path: system-tests/logs_debugger*
969+
path: logs_debugger
960970
961971
- store_artifacts:
962-
path: system-tests/logs_debugger*
972+
path: logs_debugger
963973
964974
parametric-tests:
965975
machine:

components/json/build.gradle.kts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id("me.champeau.jmh")
3+
}
4+
5+
apply(from = "$rootDir/gradle/java.gradle")
6+
7+
jmh {
8+
version = "1.28"
9+
}

components/json/gradle.lockfile

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# This is a Gradle generated file for dependency locking.
2+
# Manual edits can break the build and are not advised.
3+
# This file is expected to be part of source control.
4+
ch.qos.logback:logback-classic:1.2.3=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
5+
ch.qos.logback:logback-core:1.2.3=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
6+
com.beust:jcommander:1.78=jmhRuntimeClasspath,testRuntimeClasspath
7+
com.github.javaparser:javaparser-core:3.25.1=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
8+
com.github.spotbugs:spotbugs-annotations:4.2.0=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
9+
com.github.spotbugs:spotbugs-annotations:4.7.3=spotbugs
10+
com.github.spotbugs:spotbugs:4.7.3=spotbugs
11+
com.google.code.findbugs:jsr305:3.0.2=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
12+
com.google.code.gson:gson:2.9.1=spotbugs
13+
com.thoughtworks.qdox:qdox:1.12.1=jmhRuntimeClasspath,testRuntimeClasspath
14+
commons-codec:commons-codec:1.15=spotbugs
15+
de.thetaphi:forbiddenapis:3.1=compileClasspath,jmhCompileClasspath
16+
info.picocli:picocli:4.6.3=jmhRuntimeClasspath,testRuntimeClasspath
17+
jaxen:jaxen:1.2.0=spotbugs
18+
jline:jline:2.14.6=jmhRuntimeClasspath,testRuntimeClasspath
19+
junit:junit:4.13.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
20+
net.jcip:jcip-annotations:1.0=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
21+
net.sf.jopt-simple:jopt-simple:5.0.4=jmh,jmhCompileClasspath,jmhRuntimeClasspath
22+
net.sf.saxon:Saxon-HE:11.4=spotbugs
23+
org.apache.ant:ant-antlr:1.10.12=jmhRuntimeClasspath,testRuntimeClasspath
24+
org.apache.ant:ant-antlr:1.9.15=codenarc
25+
org.apache.ant:ant-junit:1.10.12=jmhRuntimeClasspath,testRuntimeClasspath
26+
org.apache.ant:ant-junit:1.9.15=codenarc
27+
org.apache.ant:ant-launcher:1.10.12=jmhRuntimeClasspath,testRuntimeClasspath
28+
org.apache.ant:ant:1.10.12=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
29+
org.apache.bcel:bcel:6.5.0=spotbugs
30+
org.apache.commons:commons-lang3:3.12.0=pitest,spotbugs
31+
org.apache.commons:commons-math3:3.2=jmh,jmhCompileClasspath,jmhRuntimeClasspath
32+
org.apache.commons:commons-text:1.10.0=pitest,spotbugs
33+
org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs
34+
org.apache.httpcomponents.core5:httpcore5-h2:5.1.3=spotbugs
35+
org.apache.httpcomponents.core5:httpcore5:5.1.3=spotbugs
36+
org.apache.logging.log4j:log4j-api:2.19.0=spotbugs
37+
org.apache.logging.log4j:log4j-core:2.19.0=spotbugs
38+
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
39+
org.codehaus.groovy:groovy-all:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
40+
org.codehaus.groovy:groovy-ant:2.5.14=codenarc
41+
org.codehaus.groovy:groovy-ant:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
42+
org.codehaus.groovy:groovy-astbuilder:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
43+
org.codehaus.groovy:groovy-cli-picocli:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
44+
org.codehaus.groovy:groovy-console:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
45+
org.codehaus.groovy:groovy-datetime:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
46+
org.codehaus.groovy:groovy-docgenerator:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
47+
org.codehaus.groovy:groovy-groovydoc:2.5.14=codenarc
48+
org.codehaus.groovy:groovy-groovydoc:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
49+
org.codehaus.groovy:groovy-groovysh:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
50+
org.codehaus.groovy:groovy-jmx:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
51+
org.codehaus.groovy:groovy-json:2.5.14=codenarc
52+
org.codehaus.groovy:groovy-json:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
53+
org.codehaus.groovy:groovy-jsr223:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
54+
org.codehaus.groovy:groovy-macro:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
55+
org.codehaus.groovy:groovy-nio:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
56+
org.codehaus.groovy:groovy-servlet:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
57+
org.codehaus.groovy:groovy-sql:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
58+
org.codehaus.groovy:groovy-swing:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
59+
org.codehaus.groovy:groovy-templates:2.5.14=codenarc
60+
org.codehaus.groovy:groovy-templates:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
61+
org.codehaus.groovy:groovy-test-junit5:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
62+
org.codehaus.groovy:groovy-test:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
63+
org.codehaus.groovy:groovy-testng:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
64+
org.codehaus.groovy:groovy-xml:2.5.14=codenarc
65+
org.codehaus.groovy:groovy-xml:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
66+
org.codehaus.groovy:groovy:2.5.14=codenarc
67+
org.codehaus.groovy:groovy:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
68+
org.codenarc:CodeNarc:2.2.0=codenarc
69+
org.dom4j:dom4j:2.1.3=spotbugs
70+
org.gmetrics:GMetrics:1.1=codenarc
71+
org.hamcrest:hamcrest-core:1.3=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
72+
org.hamcrest:hamcrest:2.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
73+
org.jacoco:org.jacoco.agent:0.8.5=jacocoAgent,jacocoAnt
74+
org.jacoco:org.jacoco.ant:0.8.5=jacocoAnt
75+
org.jacoco:org.jacoco.core:0.8.5=jacocoAnt
76+
org.jacoco:org.jacoco.report:0.8.5=jacocoAnt
77+
org.junit.jupiter:junit-jupiter-api:5.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
78+
org.junit.jupiter:junit-jupiter-engine:5.9.2=jmhRuntimeClasspath,testRuntimeClasspath
79+
org.junit.jupiter:junit-jupiter-params:5.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
80+
org.junit.jupiter:junit-jupiter:5.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
81+
org.junit.platform:junit-platform-commons:1.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
82+
org.junit.platform:junit-platform-engine:1.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
83+
org.junit.platform:junit-platform-launcher:1.9.2=jmhRuntimeClasspath,testRuntimeClasspath
84+
org.junit:junit-bom:5.9.1=spotbugs
85+
org.junit:junit-bom:5.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
86+
org.objenesis:objenesis:3.3=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
87+
org.openjdk.jmh:jmh-core:1.36=jmh,jmhCompileClasspath,jmhRuntimeClasspath
88+
org.openjdk.jmh:jmh-generator-asm:1.36=jmh,jmhCompileClasspath,jmhRuntimeClasspath
89+
org.openjdk.jmh:jmh-generator-bytecode:1.36=jmh,jmhCompileClasspath,jmhRuntimeClasspath
90+
org.openjdk.jmh:jmh-generator-reflection:1.36=jmh,jmhCompileClasspath,jmhRuntimeClasspath
91+
org.opentest4j:opentest4j:1.2.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
92+
org.ow2.asm:asm-analysis:7.2=jacocoAnt
93+
org.ow2.asm:asm-analysis:9.4=spotbugs
94+
org.ow2.asm:asm-commons:7.2=jacocoAnt
95+
org.ow2.asm:asm-commons:9.4=spotbugs
96+
org.ow2.asm:asm-tree:7.2=jacocoAnt
97+
org.ow2.asm:asm-tree:9.4=spotbugs
98+
org.ow2.asm:asm-util:9.4=spotbugs
99+
org.ow2.asm:asm:7.2=jacocoAnt
100+
org.ow2.asm:asm:9.0=jmh,jmhCompileClasspath,jmhRuntimeClasspath
101+
org.ow2.asm:asm:9.4=spotbugs
102+
org.pitest:pitest-command-line:1.9.11=pitest
103+
org.pitest:pitest-entry:1.9.11=pitest
104+
org.pitest:pitest:1.9.11=pitest
105+
org.slf4j:jcl-over-slf4j:1.7.30=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
106+
org.slf4j:jul-to-slf4j:1.7.30=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
107+
org.slf4j:log4j-over-slf4j:1.7.30=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
108+
org.slf4j:slf4j-api:1.7.30=testCompileClasspath
109+
org.slf4j:slf4j-api:1.7.32=jmhRuntimeClasspath,testRuntimeClasspath
110+
org.slf4j:slf4j-api:2.0.0=spotbugs,spotbugsSlf4j
111+
org.slf4j:slf4j-simple:2.0.0=spotbugsSlf4j
112+
org.spockframework:spock-core:2.2-groovy-3.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
113+
org.spockframework:spock-junit4:2.2-groovy-3.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
114+
org.testng:testng:7.5=jmhRuntimeClasspath,testRuntimeClasspath
115+
org.webjars:jquery:3.5.1=jmhRuntimeClasspath,testRuntimeClasspath
116+
org.xmlresolver:xmlresolver:4.4.3=spotbugs
117+
xml-apis:xml-apis:1.4.01=spotbugs
118+
empty=annotationProcessor,jmhAnnotationProcessor,runtimeClasspath,spotbugsPlugins,testAnnotationProcessor
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package datadog.json;
2+
3+
import static java.util.concurrent.TimeUnit.MICROSECONDS;
4+
import static org.openjdk.jmh.annotations.Mode.AverageTime;
5+
6+
import org.openjdk.jmh.annotations.Benchmark;
7+
import org.openjdk.jmh.annotations.BenchmarkMode;
8+
import org.openjdk.jmh.annotations.Fork;
9+
import org.openjdk.jmh.annotations.OutputTimeUnit;
10+
import org.openjdk.jmh.infra.Blackhole;
11+
12+
@BenchmarkMode(AverageTime)
13+
@OutputTimeUnit(MICROSECONDS)
14+
@Fork(value = 1)
15+
@SuppressWarnings("unused")
16+
public class JsonWriterBenchmark {
17+
@Benchmark
18+
public void writeSimpleArray(Blackhole blackhole) {
19+
try (JsonWriter writer = new JsonWriter()) {
20+
writer
21+
.beginArray()
22+
.beginObject()
23+
.name("true")
24+
.value(true)
25+
.endObject()
26+
.beginObject()
27+
.name("false")
28+
.value(false)
29+
.endObject()
30+
.endArray();
31+
blackhole.consume(writer.toString());
32+
}
33+
}
34+
35+
@Benchmark
36+
public void writeComplexArray(Blackhole blackhole) {
37+
try (JsonWriter writer = new JsonWriter()) {
38+
writer
39+
.beginArray()
40+
.value("first level")
41+
.beginArray()
42+
.value("second level")
43+
.beginArray()
44+
.value("third level")
45+
.beginObject()
46+
.name("key")
47+
.value("value")
48+
.endObject()
49+
.beginObject()
50+
.name("key")
51+
.value("value")
52+
.endObject()
53+
.endArray() // second level
54+
.beginObject()
55+
.name("key")
56+
.value("value")
57+
.endObject()
58+
.endArray() // first level
59+
.beginObject()
60+
.name("key")
61+
.value("value")
62+
.endObject()
63+
.value("last value")
64+
.endArray();
65+
blackhole.consume(writer.toString());
66+
}
67+
}
68+
69+
@Benchmark
70+
public void writeComplexObject(Blackhole blackhole) {
71+
try (JsonWriter writer = new JsonWriter()) {
72+
writer
73+
.beginObject()
74+
.name("attrs")
75+
.beginObject()
76+
.name("attr1")
77+
.value("value1")
78+
.name("attr2")
79+
.value("value2")
80+
.endObject()
81+
.name("data")
82+
.beginArray()
83+
.beginObject()
84+
.name("x")
85+
.value(1)
86+
.name("y")
87+
.value(12.3)
88+
.endObject()
89+
.beginObject()
90+
.name("x")
91+
.value(2)
92+
.name("y")
93+
.value(4.56)
94+
.endObject()
95+
.beginObject()
96+
.name("x")
97+
.value(3)
98+
.name("y")
99+
.value(789)
100+
.endObject()
101+
.endArray()
102+
.endObject();
103+
blackhole.consume(writer.toString());
104+
}
105+
}
106+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package datadog.json;
2+
3+
import java.util.Collection;
4+
import java.util.Map;
5+
6+
/** Utility class for simple Java structure mapping into JSON strings. */
7+
public final class JsonMapper {
8+
9+
private JsonMapper() {}
10+
11+
/**
12+
* Converts a {@link String} to a JSON string.
13+
*
14+
* @param string The string to convert.
15+
* @return The converted JSON string.
16+
*/
17+
public static String toJson(String string) {
18+
if (string == null || string.isEmpty()) {
19+
return "";
20+
}
21+
try (JsonWriter writer = new JsonWriter()) {
22+
writer.value(string);
23+
return writer.toString();
24+
}
25+
}
26+
27+
/**
28+
* Converts a {@link Map} to a JSON object.
29+
*
30+
* @param map The map to convert.
31+
* @return The converted JSON object as Java string.
32+
*/
33+
public static String toJson(Map<String, ?> map) {
34+
if (map == null || map.isEmpty()) {
35+
return "{}";
36+
}
37+
try (JsonWriter writer = new JsonWriter()) {
38+
writer.beginObject();
39+
for (Map.Entry<String, ?> entry : map.entrySet()) {
40+
writer.name(entry.getKey());
41+
Object value = entry.getValue();
42+
if (value == null) {
43+
writer.nullValue();
44+
} else if (value instanceof String) {
45+
writer.value((String) value);
46+
} else if (value instanceof Double) {
47+
writer.value((Double) value);
48+
} else if (value instanceof Float) {
49+
writer.value((Float) value);
50+
} else if (value instanceof Long) {
51+
writer.value((Long) value);
52+
} else if (value instanceof Integer) {
53+
writer.value((Integer) value);
54+
} else if (value instanceof Boolean) {
55+
writer.value((Boolean) value);
56+
} else {
57+
writer.value(value.toString());
58+
}
59+
}
60+
writer.endObject();
61+
return writer.toString();
62+
}
63+
}
64+
65+
/**
66+
* Converts a {@link Iterable<String>} to a JSON array.
67+
*
68+
* @param items The iterable to convert.
69+
* @return The converted JSON array as Java string.
70+
*/
71+
@SuppressWarnings("DuplicatedCode")
72+
public static String toJson(Collection<String> items) {
73+
if (items == null || items.isEmpty()) {
74+
return "[]";
75+
}
76+
try (JsonWriter writer = new JsonWriter()) {
77+
writer.beginArray();
78+
for (String item : items) {
79+
writer.value(item);
80+
}
81+
writer.endArray();
82+
return writer.toString();
83+
}
84+
}
85+
86+
/**
87+
* Converts a String array to a JSON array.
88+
*
89+
* @param items The array to convert.
90+
* @return The converted JSON array as Java string.
91+
*/
92+
@SuppressWarnings("DuplicatedCode")
93+
public static String toJson(String[] items) {
94+
if (items == null) {
95+
return "[]";
96+
}
97+
try (JsonWriter writer = new JsonWriter()) {
98+
writer.beginArray();
99+
for (String item : items) {
100+
writer.value(item);
101+
}
102+
writer.endArray();
103+
return writer.toString();
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)