Skip to content

Commit

Permalink
Merge branch 'mattalp/handcrafted-smap-parser' of github.com:DataDog/…
Browse files Browse the repository at this point in the history
…dd-trace-java into mattalp/handcrafted-smap-parser
  • Loading branch information
MattAlp committed Dec 5, 2024
2 parents 57eccb1 + d576a02 commit 11c7ea0
Show file tree
Hide file tree
Showing 954 changed files with 14,385 additions and 4,491 deletions.
32 changes: 22 additions & 10 deletions .circleci/collect_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,32 @@ set -e
#Enable '**' support
shopt -s globstar

TEST_RESULTS_DIR=./results
mkdir -p $TEST_RESULTS_DIR >/dev/null 2>&1

TEST_RESULTS_DIR=results
WORKSPACE_DIR=workspace
mkdir -p $TEST_RESULTS_DIR
mkdir -p $WORKSPACE_DIR

mkdir -p workspace
mapfile -t test_result_dirs < <(find workspace -name test-results -type d)
mapfile -t TEST_RESULT_DIRS < <(find $WORKSPACE_DIR -name test-results -type d)

if [[ ${#test_result_dirs[@]} -eq 0 ]]; then
if [[ ${#TEST_RESULT_DIRS[@]} -eq 0 ]]; then
echo "No test results found"
exit 0
fi

echo "saving test results"
find "${test_result_dirs[@]}" -name \*.xml -exec sh -c '
file=$(echo "$0" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
cp "$0" "$1/$file"' {} $TEST_RESULTS_DIR \;
echo "Saving test results:"
while IFS= read -r -d '' RESULT_XML_FILE
do
echo -n "- $RESULT_XML_FILE"
AGGREGATED_FILE_NAME=$(echo "$RESULT_XML_FILE" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
echo -n " as $AGGREGATED_FILE_NAME"
cp "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
# Replace Java Object hashCode by marker in testcase XML nodes to get stable test names
sed -i '/<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
# Replace random port numbers by marker in testcase XML nodes to get stable test names
sed -i '/<testcase/ s/localhost:[0-9]\{2,5\}/localhost:PORT/g' "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
if cmp -s "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"; then
echo ""
else
echo -n " (non-stable test names detected)"
fi
done < <(find "${TEST_RESULT_DIRS[@]}" -name \*.xml -print0)
18 changes: 15 additions & 3 deletions .circleci/config.continue.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation
debugger_modules: &debugger_modules "dd-java-agent/agent-debugger|dd-java-agent/agent-bootstrap|dd-java-agent/agent-builder|internal-api|communication|dd-trace-core"
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"

default_system_tests_commit: &default_system_tests_commit 53d9b2c43876a39e5c0426f4df4dd5fd79d062e8
default_system_tests_commit: &default_system_tests_commit 67fe30ac7504997685859d31feae1782f3527f39

parameters:
nightly:
Expand Down Expand Up @@ -816,7 +816,7 @@ jobs:
parameters:
weblog-variant:
type: string
parallelism: 3
parallelism: 4
steps:
- setup_system_tests
Expand All @@ -838,11 +838,22 @@ jobs:
no_output_timeout: 5m
command: |
cd system-tests
(
echo "
DEFAULT
APM_TRACING_E2E
APM_TRACING_E2E_SINGLE_SPAN
" | circleci tests split > scenarios.list
"
if ! [[ << parameters.weblog-variant >> =~ .*native ]]; then
echo "
APPSEC_BLOCKING
APPSEC_REQUEST_BLOCKING
APPSEC_RASP
APPSEC_RUNTIME_ACTIVATION
REMOTE_CONFIG_MOCKED_BACKEND_ASM_DD
"
fi
) | circleci tests split > scenarios.list
for scenario in $(<scenarios.list); do
if [[ $scenario =~ .*_E2E.* ]]; then
export DD_SITE=datadoghq.com
Expand All @@ -860,6 +871,7 @@ jobs:
command: |
mkdir -p artifacts
cd system-tests
shopt -s nullglob
for log_dir in logs*; do
tar -cvzf ../artifacts/${log_dir}_<< parameters.weblog-variant >>.tar.gz $log_dir
done
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-pull-requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
const ignoreReleaseNotes = labels.filter(label => label == 'tag: no release notes').length > 0
const hasTypeLabel = labels.filter(label => label.startsWith('type:')).length > 0
const hasComponentLabel = labels.filter(label => label.startsWith('comp:')).length > 0
const hasInstrumentationLabel = labels.filter(label => label.startsWith('instr:')).length > 0
const hasInstrumentationLabel = labels.filter(label => label.startsWith('inst:')).length > 0
const labelsCheckFailed = !ignoreReleaseNotes && (!hasTypeLabel || (!hasComponentLabel && !hasInstrumentationLabel));
if (labelsCheckFailed) {
core.setFailed('Please add at least one type, and one component or instrumentation label to the pull request.')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"pull_request": {
"number": 7884,
"draft": false,
"labels": [
{
"name": "inst: java"
},
{
"name": "type: bug"
}
],
"title": "Adding some new features"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
source "$(dirname "$0")/../env.sh"
testworkflow pull_request && \
testworkflow pull_request instrumentation && \
testworkflow pull_request draft && \
testworkflow pull_request no-release-notes && \
! testworkflow pull_request missing-label && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,10 @@ private static void writeAdviceMethodCall(
final MethodCallExpr invokeStatic =
new MethodCallExpr()
.setScope(new NameExpr("handler"))
.setName("method")
.addArgument(opCode("INVOKESTATIC"))
.setName("advice")
.addArgument(new StringLiteralExpr(method.getOwner().getInternalName()))
.addArgument(new StringLiteralExpr(method.getMethodName()))
.addArgument(new StringLiteralExpr(method.getMethodType().getDescriptor()))
.addArgument(new BooleanLiteralExpr(false));
.addArgument(new StringLiteralExpr(method.getMethodType().getDescriptor()));
body.addStatement(invokeStatic);
}
if (requiresCast(advice)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
pointcut('java/security/MessageDigest', 'getInstance', '(Ljava/lang/String;)Ljava/security/MessageDigest;')
statements(
'handler.dupParameters(descriptor, StackDupMode.COPY);',
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$BeforeAdvice", "before", "(Ljava/lang/String;)V", false);',
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$BeforeAdvice", "before", "(Ljava/lang/String;)V");',
'handler.method(opcode, owner, name, descriptor, isInterface);'
)
}
Expand Down Expand Up @@ -78,7 +78,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
advices(0) {
pointcut('java/lang/String', 'replaceAll', '(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;')
statements(
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AroundAdvice", "around", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", false);'
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AroundAdvice", "around", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");'
)
}
}
Expand Down Expand Up @@ -110,7 +110,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
statements(
'handler.dupInvoke(owner, descriptor, StackDupMode.COPY);',
'handler.method(opcode, owner, name, descriptor, isInterface);',
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AfterAdvice", "after", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", false);',
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AfterAdvice", "after", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");',
)
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
statements(
'handler.dupParameters(descriptor, StackDupMode.PREPEND_ARRAY_CTOR);',
'handler.method(opcode, owner, name, descriptor, isInterface);',
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AfterAdviceCtor", "after", "([Ljava/lang/Object;Ljava/net/URL;)Ljava/net/URL;", false);',
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AfterAdviceCtor", "after", "([Ljava/lang/Object;Ljava/net/URL;)Ljava/net/URL;");',
)
}
}
Expand Down Expand Up @@ -208,7 +208,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
statements(
'handler.dupParameters(descriptor, StackDupMode.PREPEND_ARRAY);',
'handler.invokeDynamic(name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments);',
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$InvokeDynamicAfterAdvice", "after", "([Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;", false);'
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$InvokeDynamicAfterAdvice", "after", "([Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;");'
)
}
}
Expand Down Expand Up @@ -297,7 +297,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
'handler.dupParameters(descriptor, StackDupMode.PREPEND_ARRAY);',
'handler.invokeDynamic(name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments);',
'handler.loadConstantArray(bootstrapMethodArguments);',
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$InvokeDynamicWithConstantsAdvice", "after", "([Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;", false);'
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$InvokeDynamicWithConstantsAdvice", "after", "([Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");'
)
}
}
Expand Down Expand Up @@ -393,7 +393,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
statements(
'int[] parameterIndices = new int[] { 0 };',
'handler.dupParameters(descriptor, parameterIndices, owner);',
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "(Ljava/lang/String;)V", false);',
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "(Ljava/lang/String;)V");',
'handler.method(opcode, owner, name, descriptor, isInterface);',
)
}
Expand All @@ -402,7 +402,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
statements(
'int[] parameterIndices = new int[] { 1 };',
'handler.dupParameters(descriptor, parameterIndices, null);',
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "([Ljava/lang/Object;)V", false);',
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "([Ljava/lang/Object;)V");',
'handler.method(opcode, owner, name, descriptor, isInterface);',
)
}
Expand All @@ -411,7 +411,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
statements(
'int[] parameterIndices = new int[] { 0 };',
'handler.dupInvoke(owner, descriptor, parameterIndices);',
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "(Ljava/lang/String;I)V", false);',
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$PartialArgumentsBeforeAdvice", "before", "(Ljava/lang/String;I)V");',
'handler.method(opcode, owner, name, descriptor, isInterface);',
)
}
Expand Down Expand Up @@ -443,7 +443,7 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
statements(
'handler.dupParameters(descriptor, StackDupMode.PREPEND_ARRAY_CTOR);',
'handler.method(opcode, owner, name, descriptor, isInterface);',
'handler.method(Opcodes.INVOKESTATIC, "datadog/trace/plugin/csi/impl/AdviceGeneratorTest$SuperTypeReturnAdvice", "after", "([Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", false);',
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$SuperTypeReturnAdvice", "after", "([Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");',
'handler.instruction(Opcodes.CHECKCAST, "java/lang/StringBuilder");'
)
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/InstrumentPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class InstrumentPlugin implements Plugin<Project> {
InstrumentExtension extension = project.extensions.create('instrument', InstrumentExtension)

project.tasks.matching {
it.name in ['compileJava', 'compileScala', 'compileKotlin'] ||
it.name in ['compileJava', 'compileScala', 'compileKotlin', 'compileGroovy'] ||
it.name =~ /compileMain_.+Java/
}.all {
AbstractCompile compileTask = it as AbstractCompile
Expand Down
8 changes: 6 additions & 2 deletions buildSrc/src/main/groovy/MuzzlePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,12 @@ class MuzzlePlugin implements Plugin<Project> {
config.dependencies.add(dep)
}
for (String additionalDependency : muzzleDirective.additionalDependencies) {
config.dependencies.add(instrumentationProject.dependencies.create(additionalDependency) {
transitive = true
config.dependencies.add(instrumentationProject.dependencies.create(additionalDependency) { dep ->
for (String excluded : muzzleDirective.excludedDependencies) {
String[] parts = excluded.split(':')
dep.exclude group: parts[0], module: parts[1]
}
dep.transitive = true
})
}

Expand Down
2 changes: 1 addition & 1 deletion communication/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ch.qos.logback:logback-core:1.2.3=testCompileClasspath,testRuntimeClasspath
com.beust:jcommander:1.78=testRuntimeClasspath
com.datadoghq.okhttp3:okhttp:3.12.15=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq.okio:okio:1.17.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq:dd-javac-plugin-client:0.1.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq:dd-javac-plugin-client:0.2.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq:java-dogstatsd-client:4.4.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.fasterxml.jackson.core:jackson-annotations:2.9.0=testCompileClasspath,testRuntimeClasspath
com.fasterxml.jackson.core:jackson-core:2.9.9=testCompileClasspath,testRuntimeClasspath
Expand Down
9 changes: 9 additions & 0 deletions components/json/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id("me.champeau.jmh")
}

apply(from = "$rootDir/gradle/java.gradle")

jmh {
version = "1.28"
}
106 changes: 106 additions & 0 deletions components/json/src/jmh/java/datadog/json/JsonWriterBenchmark.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package datadog.json;

import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static org.openjdk.jmh.annotations.Mode.AverageTime;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.infra.Blackhole;

@BenchmarkMode(AverageTime)
@OutputTimeUnit(MICROSECONDS)
@Fork(value = 1)
@SuppressWarnings("unused")
public class JsonWriterBenchmark {
@Benchmark
public void writeSimpleArray(Blackhole blackhole) {
try (JsonWriter writer = new JsonWriter()) {
writer
.beginArray()
.beginObject()
.name("true")
.value(true)
.endObject()
.beginObject()
.name("false")
.value(false)
.endObject()
.endArray();
blackhole.consume(writer.toString());
}
}

@Benchmark
public void writeComplexArray(Blackhole blackhole) {
try (JsonWriter writer = new JsonWriter()) {
writer
.beginArray()
.value("first level")
.beginArray()
.value("second level")
.beginArray()
.value("third level")
.beginObject()
.name("key")
.value("value")
.endObject()
.beginObject()
.name("key")
.value("value")
.endObject()
.endArray() // second level
.beginObject()
.name("key")
.value("value")
.endObject()
.endArray() // first level
.beginObject()
.name("key")
.value("value")
.endObject()
.value("last value")
.endArray();
blackhole.consume(writer.toString());
}
}

@Benchmark
public void writeComplexObject(Blackhole blackhole) {
try (JsonWriter writer = new JsonWriter()) {
writer
.beginObject()
.name("attrs")
.beginObject()
.name("attr1")
.value("value1")
.name("attr2")
.value("value2")
.endObject()
.name("data")
.beginArray()
.beginObject()
.name("x")
.value(1)
.name("y")
.value(12.3)
.endObject()
.beginObject()
.name("x")
.value(2)
.name("y")
.value(4.56)
.endObject()
.beginObject()
.name("x")
.value(3)
.name("y")
.value(789)
.endObject()
.endArray()
.endObject();
blackhole.consume(writer.toString());
}
}
}
Loading

0 comments on commit 11c7ea0

Please sign in to comment.