From 4215789548aa26ca6ad57da4bdcc59d14a2a11cc Mon Sep 17 00:00:00 2001 From: Jordan Wong Date: Fri, 20 Mar 2026 10:02:27 -0400 Subject: [PATCH 1/2] eval: prepare blind test for jedis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove existing jedis instrumentation (1.4, 3.0, 4.0) so the agent generates from scratch without reference. Append collected review rules (R1-R11) to the add-apm-integrations skill file. Also includes spotless formatting fixes for unrelated files caught by pre-commit hook. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .claude/skills/add-apm-integrations/SKILL.md | 54 +++ .../java/datadog/json/JsonMapperTest.java | 52 +-- .../jedis/jedis-1.4/build.gradle | 25 -- .../jedis/jedis-1.4/gradle.lockfile | 127 ------- .../jedis/JedisClientDecorator.java | 57 --- .../jedis/JedisInstrumentation.java | 87 ----- .../src/test/groovy/JedisClientTest.groovy | 203 ---------- .../jedis/jedis-3.0/build.gradle | 30 -- .../jedis/jedis-3.0/gradle.lockfile | 129 ------- .../jedis30/JedisClientDecorator.java | 58 --- .../jedis30/JedisInstrumentation.java | 86 ----- .../src/test/groovy/Jedis30ClientTest.groovy | 359 ------------------ .../jedis/jedis-4.0/build.gradle | 31 -- .../jedis/jedis-4.0/gradle.lockfile | 132 ------- .../jedis40/JedisInstrumentation.java | 84 ---- .../clients/jedis/JedisClientDecorator.java | 58 --- .../src/test/groovy/Jedis40ClientTest.groovy | 359 ------------------ .../java/datadog/trace/api/DDSpanIdTest.java | 52 +-- .../java/datadog/trace/api/DDTraceIdTest.java | 104 ++--- .../trace/api/IdGenerationStrategyTest.java | 6 +- .../api/internal/util/HexStringUtilsTest.java | 8 +- 21 files changed, 165 insertions(+), 1936 deletions(-) delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-1.4/build.gradle delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-1.4/gradle.lockfile delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisClientDecorator.java delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-1.4/src/test/groovy/JedisClientTest.groovy delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-3.0/build.gradle delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-3.0/gradle.lockfile delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-3.0/src/main/java/datadog/trace/instrumentation/jedis30/JedisClientDecorator.java delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-3.0/src/main/java/datadog/trace/instrumentation/jedis30/JedisInstrumentation.java delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-3.0/src/test/groovy/Jedis30ClientTest.groovy delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-4.0/build.gradle delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-4.0/gradle.lockfile delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-4.0/src/main/java/datadog/trace/instrumentation/jedis40/JedisInstrumentation.java delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-4.0/src/main/java/redis/clients/jedis/JedisClientDecorator.java delete mode 100644 dd-java-agent/instrumentation/jedis/jedis-4.0/src/test/groovy/Jedis40ClientTest.groovy diff --git a/.claude/skills/add-apm-integrations/SKILL.md b/.claude/skills/add-apm-integrations/SKILL.md index e29b93ef3a2..a63f6c2ef8b 100644 --- a/.claude/skills/add-apm-integrations/SKILL.md +++ b/.claude/skills/add-apm-integrations/SKILL.md @@ -230,3 +230,57 @@ After the instrumentation is complete (or abandoned), review the full session an Keep each change minimal and targeted. Do not rewrite sections that worked correctly. After editing, confirm to the user which improvements were made to the skill. + +## Appendix: Collected review rules + +These rules are derived from expert feedback on generated PRs. They serve as a checklist for self-review before finishing. Some overlap with guidance in the steps above; they are collected here for completeness. + +### R1: No lambdas in advice classes (error) +Search for lambda expressions (`->` or `::`) in any file with "Advice" or "Instrumentation" in its name. Advice methods are inlined into bytecode by ByteBuddy, and lambdas create invokedynamic instructions that break when inlined into a different classloader context. +*Source: mcculls, PR #10579* + +### R2: Assign wrapped future back with `@Advice.Return(readOnly=false)` (error) +In async advice exit methods that wrap futures (CompletableFuture, ListenableFuture, etc.), verify the wrapped result is assigned back to the return value using `@Advice.Return(readOnly=false)`. Do not discard the return of `future.whenComplete`/`thenApply`/etc. +*Applies to: async instrumentations only. Source: mcculls, PR #10579* + +### R3: Single InstrumenterModule per integration (error) +There should be exactly one class extending `InstrumenterModule` (with `@AutoService(InstrumenterModule.class)`) per module. If the integration needs to instrument multiple classes, list them as separate `Instrumenter` implementations within the same module. +*Source: mcculls, PR #10579* + +### R4: Module name must end with version (error) +The module directory under `dd-java-agent/instrumentation/` must follow `{library}-{version}` (e.g., `feign-8.0`, `okhttp-3`). Do not use the Maven artifact name (e.g., `feign-core`). +*Source: mcculls, PR #10579* + +### R5: CallDepthThreadLocalMap must be reset on the same thread (error) +If `CallDepthThreadLocalMap` is used for reentrancy protection, `increment()` and `reset()` must be called on the same thread. In async code paths, callbacks may run on a different thread, so `CallDepthThreadLocalMap` cannot be used across async boundaries. +*Applies to: async instrumentations only. Source: mcculls, PR #10579* + +### R6: Code passes codeNarc checks (warning) +If there are Groovy test files, avoid common codeNarc violations: unused imports, unnecessary semicolons, missing spaces after keywords. Run `codenarcTest` in addition to `spotlessCheck`. +*Source: Runs 0, 1* + +### R7: Test against minimum supported version, not just latest (warning) +Compare the `testCompile`/`testImplementation` dependency version in `build.gradle` against the minimum version in the muzzle `pass` directive. If the test uses APIs that only exist in newer versions, it does not actually verify minimum version compatibility. +*Source: Run 1 (auto-detected)* + +### R8: Test extends correct base test class (warning) +The test superclass should match the integration type: +- HTTP clients: extend `HttpClientTest` +- HTTP servers: extend `HttpServerTest` +- Database clients: extend `DatabaseClientTest` +- Messaging: use the appropriate messaging base test + +If no base test class exists for the type, custom tests are acceptable but should cover span creation, error handling, and tag verification. +*Source: Run 1 (auto-detected)* + +### R9: Disabled base test methods must have justification (warning) +Methods that override base test class methods to return `false` (e.g., `testRedirects() { return false }`) must have a comment explaining why — what specific library limitation prevents the test from working. +*Source: Run 1 (auto-detected)* + +### R10: Test exercises real library, not just mocks (error) +The test must instantiate real library objects and make real calls (e.g., a real HTTP client calling a test server). Tests that only use mocks without exercising actual library code do not verify the instrumentation works. Base test classes typically provide real server infrastructure. +*Source: PR #10317 (Resilience4j)* + +### R11: Test compiles and runs against minimum supported version (warning) +Verify that the test code only uses APIs available in the minimum supported version. If the test uses a newer API (e.g., a static factory method added in a later version), it cannot verify minimum version compatibility. This extends R7 with API-level checking. +*Source: Run 1 (extends R7)* diff --git a/components/json/src/test/java/datadog/json/JsonMapperTest.java b/components/json/src/test/java/datadog/json/JsonMapperTest.java index 926702881bc..eef94bd5032 100644 --- a/components/json/src/test/java/datadog/json/JsonMapperTest.java +++ b/components/json/src/test/java/datadog/json/JsonMapperTest.java @@ -24,12 +24,12 @@ class JsonMapperTest { @TableTest({ - "Scenario | Input | Expected ", - "null input | | '{}' ", - "empty map | [:] | '{}' ", - "single entry | [key1: value1] | '{\"key1\":\"value1\"}' ", - "two entries | [key1: value1, key2: value2] | '{\"key1\":\"value1\",\"key2\":\"value2\"}' ", - "quoted entries | [key1: va\"lu\"e1, ke\"y2: value2] | '{\"key1\":\"va\\\"lu\\\"e1\",\"ke\\\"y2\":\"value2\"}'" + "Scenario | Input | Expected ", + "null input | | '{}' ", + "empty map | [:] | '{}' ", + "single entry | [key1: value1] | '{\"key1\":\"value1\"}' ", + "two entries | [key1: value1, key2: value2] | '{\"key1\":\"value1\",\"key2\":\"value2\"}' ", + "quoted entries | [key1: va\"lu\"e1, ke\"y2: value2] | '{\"key1\":\"va\\\"lu\\\"e1\",\"ke\\\"y2\":\"value2\"}'" }) @ParameterizedTest(name = "test mapping to JSON object: {0}") @MethodSource("testMappingToJsonObjectArguments") @@ -94,12 +94,12 @@ void testMappingToMapFromNonObjectJson(String json) { } @TableTest({ - "Scenario | Input | Expected ", - "null input | | '[]' ", - "empty list | [] | '[]' ", - "single value | [value1] | '[\"value1\"]' ", - "two values | [value1, value2] | '[\"value1\",\"value2\"]' ", - "quoted values | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]'" + "Scenario | Input | Expected ", + "null input | | '[]' ", + "empty list | [] | '[]' ", + "single value | [value1] | '[\"value1\"]' ", + "two values | [value1, value2] | '[\"value1\",\"value2\"]' ", + "quoted values | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]'" }) @ParameterizedTest(name = "test mapping iterable to JSON array: {0}") void testMappingIterableToJsonArray(List input, String expected) throws IOException { @@ -111,12 +111,12 @@ void testMappingIterableToJsonArray(List input, String expected) throws } @TableTest({ - "Scenario | Input | Expected ", - "null input | | '[]' ", - "empty array | [] | '[]' ", - "single element | [value1] | '[\"value1\"]' ", - "two elements | [value1, value2] | '[\"value1\",\"value2\"]' ", - "escaped quotes | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]'" + "Scenario | Input | Expected ", + "null input | | '[]' ", + "empty array | [] | '[]' ", + "single element | [value1] | '[\"value1\"]' ", + "two elements | [value1, value2] | '[\"value1\",\"value2\"]' ", + "escaped quotes | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]'" }) @ParameterizedTest(name = "test mapping array to JSON array: {0}") void testMappingArrayToJsonArray(String ignoredScenario, String[] input, String expected) @@ -137,14 +137,14 @@ void testMappingToListFromEmptyJsonObject(String json) throws IOException { } @TableTest({ - "Scenario | input | expected ", - "null value | | '' ", - "empty string | '' | '' ", - "\\b | '\b' | '\"\\b\"'", - "\\t | '\t' | '\"\\t\"'", - "\\f | '\f' | '\"\\f\"'", - "a | 'a' | '\"a\"' ", - "/ | '/' | '\"\\/\"'" + "Scenario | input | expected ", + "null value | | '' ", + "empty string | '' | '' ", + "\\b | '\b' | '\"\\b\"'", + "\\t | '\t' | '\"\\t\"'", + "\\f | '\f' | '\"\\f\"'", + "a | 'a' | '\"a\"' ", + "/ | '/' | '\"\\/\"'" }) @ParameterizedTest(name = "test mapping to JSON string: {0}") @MethodSource("testMappingToJsonStringArguments") diff --git a/dd-java-agent/instrumentation/jedis/jedis-1.4/build.gradle b/dd-java-agent/instrumentation/jedis/jedis-1.4/build.gradle deleted file mode 100644 index e1ca8af38da..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-1.4/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -muzzle { - pass { - group = "redis.clients" - module = "jedis" - versions = "[1.4.0,3.0.0)" - assertInverse = true - } -} - -apply from: "$rootDir/gradle/java.gradle" - -addTestSuiteForDir('latestDepTest', 'test') - -dependencies { - compileOnly group: 'redis.clients', name: 'jedis', version: '1.4.0' - testImplementation group: 'redis.clients', name: 'jedis', version: '1.4.0' - - testImplementation (group: 'com.github.codemonstur', name: 'embedded-redis', version: '1.4.3') { - // Excluding redis client to avoid conflicts in instrumentation code. - exclude group: 'redis.clients', module: 'jedis' - } - - // Jedis 3.0 has API changes that prevent instrumentation from applying - latestDepTestImplementation group: 'redis.clients', name: 'jedis', version: '2.+' -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-1.4/gradle.lockfile b/dd-java-agent/instrumentation/jedis/jedis-1.4/gradle.lockfile deleted file mode 100644 index 2987c059f0f..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-1.4/gradle.lockfile +++ /dev/null @@ -1,127 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -cafe.cryptography:curve25519-elisabeth:0.1.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -cafe.cryptography:ed25519-elisabeth:0.1.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -ch.qos.logback:logback-classic:1.2.13=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -ch.qos.logback:logback-core:1.2.13=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.blogspot.mydailyjava:weak-lock-free:0.17=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq.okhttp3:okhttp:3.12.15=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq.okio:okio:1.17.6=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq:dd-instrument-java:0.0.3=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq:dd-javac-plugin-client:0.2.2=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq:java-dogstatsd-client:4.4.3=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.datadoghq:sketches-java:0.8.3=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.codemonstur:embedded-redis:1.4.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.javaparser:javaparser-core:3.25.6=codenarc -com.github.jnr:jffi:1.3.14=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-a64asm:1.0.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-constants:0.10.4=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-enxio:0.32.19=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-ffi:2.2.18=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-posix:3.1.21=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-unixsocket:0.38.24=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-x86asm:1.0.2=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.spotbugs:spotbugs-annotations:4.9.8=compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.github.spotbugs:spotbugs:4.9.8=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.1.1=annotationProcessor,compileClasspath,latestDepTestAnnotationProcessor,latestDepTestCompileClasspath,testAnnotationProcessor,testCompileClasspath -com.google.auto.service:auto-service:1.1.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,compileClasspath,latestDepTestAnnotationProcessor,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotations:2.18.0=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.guava:failureaccess:1.0.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.guava:guava:20.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:guava:32.0.1-jre=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:2.8=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.re2j:re2j:1.7=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.squareup.moshi:moshi:1.11.0=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.squareup.okhttp3:logging-interceptor:3.12.12=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.squareup.okhttp3:okhttp:3.12.12=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.squareup.okio:okio:1.17.5=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.thoughtworks.qdox:qdox:1.12.1=codenarc -commons-fileupload:commons-fileupload:1.5=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -commons-io:commons-io:2.11.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -commons-io:commons-io:2.20.0=spotbugs -de.thetaphi:forbiddenapis:3.10=compileClasspath -io.leangen.geantyref:geantyref:1.3.16=latestDepTestRuntimeClasspath,testRuntimeClasspath -io.sqreen:libsqreen:17.3.0=latestDepTestRuntimeClasspath,testRuntimeClasspath -javax.servlet:javax.servlet-api:3.1.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -jaxen:jaxen:2.0.0=spotbugs -junit:junit:4.13.2=latestDepTestRuntimeClasspath,testRuntimeClasspath -net.bytebuddy:byte-buddy-agent:1.18.3=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -net.bytebuddy:byte-buddy:1.18.3=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -net.java.dev.jna:jna-platform:5.8.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -net.java.dev.jna:jna:5.8.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=spotbugs -org.apache.ant:ant-antlr:1.10.14=codenarc -org.apache.ant:ant-junit:1.10.14=codenarc -org.apache.bcel:bcel:6.11.0=spotbugs -org.apache.commons:commons-lang3:3.19.0=spotbugs -org.apache.commons:commons-pool2:2.4.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath -org.apache.commons:commons-text:1.14.0=spotbugs -org.apache.logging.log4j:log4j-api:2.25.2=spotbugs -org.apache.logging.log4j:log4j-core:2.25.2=spotbugs -org.apiguardian:apiguardian-api:1.1.2=latestDepTestCompileClasspath,testCompileClasspath -org.checkerframework:checker-qual:3.33.0=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -org.codehaus.groovy:groovy-ant:3.0.23=codenarc -org.codehaus.groovy:groovy-docgenerator:3.0.23=codenarc -org.codehaus.groovy:groovy-groovydoc:3.0.23=codenarc -org.codehaus.groovy:groovy-json:3.0.23=codenarc -org.codehaus.groovy:groovy-json:3.0.25=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codehaus.groovy:groovy-templates:3.0.23=codenarc -org.codehaus.groovy:groovy-xml:3.0.23=codenarc -org.codehaus.groovy:groovy:3.0.23=codenarc -org.codehaus.groovy:groovy:3.0.25=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codenarc:CodeNarc:3.7.0=codenarc -org.dom4j:dom4j:2.2.0=spotbugs -org.gmetrics:GMetrics:2.1.0=codenarc -org.hamcrest:hamcrest-core:1.3=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.hamcrest:hamcrest:3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.jctools:jctools-core-jdk11:4.0.6=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.jctools:jctools-core:4.0.6=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-api:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:5.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:1.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:1.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-launcher:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-runner:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-suite-api:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-suite-commons:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit:junit-bom:5.14.0=spotbugs -org.junit:junit-bom:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.mockito:mockito-core:4.4.0=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.objenesis:objenesis:3.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.opentest4j:opentest4j:1.3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.7.1=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.9=spotbugs -org.ow2.asm:asm-commons:9.7.1=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath -org.ow2.asm:asm-commons:9.9=spotbugs -org.ow2.asm:asm-commons:9.9.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-tree:9.7.1=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath -org.ow2.asm:asm-tree:9.9=spotbugs -org.ow2.asm:asm-tree:9.9.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-util:9.7.1=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-util:9.9=spotbugs -org.ow2.asm:asm:9.7.1=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath -org.ow2.asm:asm:9.9=spotbugs -org.ow2.asm:asm:9.9.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.slf4j:jcl-over-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:jul-to-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:log4j-over-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:1.7.30=buildTimeInstrumentationPlugin,compileClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath -org.slf4j:slf4j-api:1.7.32=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:2.0.17=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.snakeyaml:snakeyaml-engine:2.9=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.spockframework:spock-bom:2.4-groovy-3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.spockframework:spock-core:2.4-groovy-3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.xmlresolver:xmlresolver:5.3.3=spotbugs -redis.clients:jedis:1.4.0=compileClasspath,testCompileClasspath,testRuntimeClasspath -redis.clients:jedis:2.10.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath -empty=spotbugsPlugins diff --git a/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisClientDecorator.java b/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisClientDecorator.java deleted file mode 100644 index f85167f6ba2..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisClientDecorator.java +++ /dev/null @@ -1,57 +0,0 @@ -package datadog.trace.instrumentation.jedis; - -import datadog.trace.api.naming.SpanNaming; -import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; -import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; -import datadog.trace.bootstrap.instrumentation.decorator.DBTypeProcessingDatabaseClientDecorator; -import redis.clients.jedis.Connection; - -public class JedisClientDecorator extends DBTypeProcessingDatabaseClientDecorator { - private static final String REDIS = "redis"; - public static final CharSequence COMPONENT_NAME = UTF8BytesString.create("redis-command"); - public static final CharSequence OPERATION_NAME = - UTF8BytesString.create(SpanNaming.instance().namingSchema().cache().operation(REDIS)); - private static final String SERVICE_NAME = - SpanNaming.instance().namingSchema().cache().service(REDIS); - public static final JedisClientDecorator DECORATE = new JedisClientDecorator(); - - @Override - protected String[] instrumentationNames() { - return new String[] {"jedis", REDIS}; - } - - @Override - protected String service() { - return SERVICE_NAME; - } - - @Override - protected CharSequence component() { - return COMPONENT_NAME; - } - - @Override - protected CharSequence spanType() { - return InternalSpanTypes.REDIS; - } - - @Override - protected String dbType() { - return REDIS; - } - - @Override - protected String dbUser(final Connection connection) { - return null; - } - - @Override - protected String dbInstance(final Connection connection) { - return null; - } - - @Override - protected String dbHostname(Connection connection) { - return connection.getHost(); - } -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java b/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java deleted file mode 100644 index c82e3a9c60c..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java +++ /dev/null @@ -1,87 +0,0 @@ -package datadog.trace.instrumentation.jedis; - -import static datadog.trace.agent.tooling.bytebuddy.matcher.ClassLoaderMatchers.hasClassNamed; -import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan; -import static datadog.trace.instrumentation.jedis.JedisClientDecorator.DECORATE; -import static net.bytebuddy.matcher.ElementMatchers.isMethod; -import static net.bytebuddy.matcher.ElementMatchers.not; -import static net.bytebuddy.matcher.ElementMatchers.takesArgument; - -import com.google.auto.service.AutoService; -import datadog.trace.agent.tooling.Instrumenter; -import datadog.trace.agent.tooling.InstrumenterModule; -import datadog.trace.bootstrap.CallDepthThreadLocalMap; -import datadog.trace.bootstrap.instrumentation.api.AgentScope; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import net.bytebuddy.asm.Advice; -import net.bytebuddy.matcher.ElementMatcher; -import redis.clients.jedis.Connection; -import redis.clients.jedis.Protocol.Command; - -@AutoService(InstrumenterModule.class) -public final class JedisInstrumentation extends InstrumenterModule.Tracing - implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice { - - public JedisInstrumentation() { - super("jedis", "redis"); - } - - @Override - public ElementMatcher.Junction classLoaderMatcher() { - // Avoid matching Jedis 3+ which has its own instrumentation. - return not(hasClassNamed("redis.clients.jedis.commands.ProtocolCommand")); - } - - @Override - public String instrumentedType() { - return "redis.clients.jedis.Connection"; - } - - @Override - public String[] helperClassNames() { - return new String[] { - packageName + ".JedisClientDecorator", - }; - } - - @Override - public void methodAdvice(MethodTransformer transformer) { - transformer.applyAdvice( - isMethod() - .and(named("sendCommand")) - .and(takesArgument(0, named("redis.clients.jedis.Protocol$Command"))), - JedisInstrumentation.class.getName() + "$JedisAdvice"); - // FIXME: This instrumentation only incorporates sending the command, not processing the result. - } - - public static class JedisAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static AgentScope onEnter( - @Advice.Argument(0) final Command command, @Advice.This final Connection thiz) { - if (CallDepthThreadLocalMap.incrementCallDepth(Connection.class) > 0) { - return null; - } - final AgentSpan span = startSpan(JedisClientDecorator.OPERATION_NAME); - DECORATE.afterStart(span); - DECORATE.onConnection(span, thiz); - DECORATE.onStatement(span, command.name()); - return activateSpan(span); - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void stopSpan( - @Advice.Enter final AgentScope scope, @Advice.Thrown final Throwable throwable) { - if (scope == null) { - return; - } - CallDepthThreadLocalMap.reset(Connection.class); - DECORATE.onError(scope.span(), throwable); - DECORATE.beforeFinish(scope.span()); - scope.close(); - scope.span().finish(); - } - } -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-1.4/src/test/groovy/JedisClientTest.groovy b/dd-java-agent/instrumentation/jedis/jedis-1.4/src/test/groovy/JedisClientTest.groovy deleted file mode 100644 index 633eb1a496a..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-1.4/src/test/groovy/JedisClientTest.groovy +++ /dev/null @@ -1,203 +0,0 @@ -import datadog.trace.agent.test.naming.VersionedNamingTestBase -import datadog.trace.agent.test.utils.PortUtils -import datadog.trace.api.Config -import datadog.trace.api.DDSpanTypes -import datadog.trace.bootstrap.instrumentation.api.Tags -import redis.clients.jedis.Jedis -import redis.embedded.RedisServer -import spock.lang.Shared - -import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace -import static datadog.trace.api.config.TraceInstrumentationConfig.DB_CLIENT_HOST_SPLIT_BY_INSTANCE -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan - -abstract class JedisClientTest extends VersionedNamingTestBase { - - @Shared - int port = PortUtils.randomOpenPort() - - @Shared - RedisServer redisServer = RedisServer.newRedisServer() - // bind to localhost to avoid firewall popup - .setting("bind 127.0.0.1") - // set max memory to avoid problems in CI - .setting("maxmemory 128M") - .port(port).build() - - @Shared - Jedis jedis = new Jedis("localhost", port) - - @Override - void configurePreAgent() { - super.configurePreAgent() - - // This setting should have no effect since decorator returns null for the instance. - injectSysConfig(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true") - } - - def setupSpec() { - println "Using redis: $redisServer.@args" - redisServer.start() - } - - def cleanupSpec() { - redisServer.stop() - // jedis.close() // not available in the early version we're using. - } - - def setup() { - def cleanupSpan = runUnderTrace("cleanup") { - jedis.flushAll() - activeSpan() - } - TEST_WRITER.waitUntilReported(cleanupSpan) - TEST_WRITER.start() - } - - def "set command"() { - when: - jedis.set("foo", "bar") - - then: - assertTraces(1) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "SET" - spanType DDSpanTypes.REDIS - measured true - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - defaultTags() - } - } - } - } - } - - def "get command"() { - when: - jedis.set("foo", "bar") - def value = jedis.get("foo") - - then: - value == "bar" - - assertTraces(2) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "SET" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "GET" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } - - def "command with no arguments"() { - when: - jedis.set("foo", "bar") - def value = jedis.randomKey() - - then: - value == "foo" - - assertTraces(2) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "SET" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "RANDOMKEY" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } -} - -class JedisClientV0Test extends JedisClientTest { - @Override - int version() { - return 0 - } - - @Override - String service() { - return "redis" - } - - @Override - String operation() { - return "redis.query" - } -} - -class JedisClientV1ForkedTest extends JedisClientTest { - @Override - int version() { - return 1 - } - - @Override - String service() { - return Config.get().getServiceName() - } - - @Override - String operation() { - return "redis.command" - } -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-3.0/build.gradle b/dd-java-agent/instrumentation/jedis/jedis-3.0/build.gradle deleted file mode 100644 index b0adcf72ca6..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-3.0/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ -muzzle { - fail { - group = "redis.clients" - module = "jedis" - versions = "[,3.0.0)" - skipVersions += "jedis-3.6.2" // bad release version ("jedis-" prefix) - } - - pass { - group = "redis.clients" - module = "jedis" - versions = "[3.0.0,4.0.0)" - } -} - -apply from: "$rootDir/gradle/java.gradle" - -addTestSuiteForDir('latestDepTest', 'test') - -dependencies { - compileOnly group: 'redis.clients', name: 'jedis', version: '3.3.0' - - testImplementation group: 'com.github.codemonstur', name: 'embedded-redis', version: '1.4.3' - testImplementation group: 'redis.clients', name: 'jedis', version: '3.3.0' - // ensures jedis-1.4 instrumentation does not load with jedis 3.0+ by failing - // the tests in the event it does. The tests will end up with double spans - testImplementation project(':dd-java-agent:instrumentation:jedis:jedis-1.4') - - latestDepTestImplementation group: 'redis.clients', name: 'jedis', version: '3.+' -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-3.0/gradle.lockfile b/dd-java-agent/instrumentation/jedis/jedis-3.0/gradle.lockfile deleted file mode 100644 index f8e4dab5ac9..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-3.0/gradle.lockfile +++ /dev/null @@ -1,129 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -cafe.cryptography:curve25519-elisabeth:0.1.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -cafe.cryptography:ed25519-elisabeth:0.1.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -ch.qos.logback:logback-classic:1.2.13=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -ch.qos.logback:logback-core:1.2.13=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.blogspot.mydailyjava:weak-lock-free:0.17=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq.okhttp3:okhttp:3.12.15=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq.okio:okio:1.17.6=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq:dd-instrument-java:0.0.3=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq:dd-javac-plugin-client:0.2.2=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq:java-dogstatsd-client:4.4.3=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.datadoghq:sketches-java:0.8.3=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.codemonstur:embedded-redis:1.4.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.javaparser:javaparser-core:3.25.6=codenarc -com.github.jnr:jffi:1.3.14=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-a64asm:1.0.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-constants:0.10.4=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-enxio:0.32.19=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-ffi:2.2.18=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-posix:3.1.21=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-unixsocket:0.38.24=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-x86asm:1.0.2=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.spotbugs:spotbugs-annotations:4.9.8=compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.github.spotbugs:spotbugs:4.9.8=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.1.1=annotationProcessor,compileClasspath,latestDepTestAnnotationProcessor,latestDepTestCompileClasspath,testAnnotationProcessor,testCompileClasspath -com.google.auto.service:auto-service:1.1.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,compileClasspath,latestDepTestAnnotationProcessor,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotations:2.18.0=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.guava:failureaccess:1.0.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.guava:guava:20.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:guava:32.0.1-jre=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:2.8=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.re2j:re2j:1.7=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.squareup.moshi:moshi:1.11.0=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.squareup.okhttp3:logging-interceptor:3.12.12=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.squareup.okhttp3:okhttp:3.12.12=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.squareup.okio:okio:1.17.5=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.thoughtworks.qdox:qdox:1.12.1=codenarc -commons-fileupload:commons-fileupload:1.5=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -commons-io:commons-io:2.11.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -commons-io:commons-io:2.20.0=spotbugs -de.thetaphi:forbiddenapis:3.10=compileClasspath -io.leangen.geantyref:geantyref:1.3.16=latestDepTestRuntimeClasspath,testRuntimeClasspath -io.sqreen:libsqreen:17.3.0=latestDepTestRuntimeClasspath,testRuntimeClasspath -javax.servlet:javax.servlet-api:3.1.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -jaxen:jaxen:2.0.0=spotbugs -junit:junit:4.13.2=latestDepTestRuntimeClasspath,testRuntimeClasspath -net.bytebuddy:byte-buddy-agent:1.18.3=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -net.bytebuddy:byte-buddy:1.18.3=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -net.java.dev.jna:jna-platform:5.8.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -net.java.dev.jna:jna:5.8.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=spotbugs -org.apache.ant:ant-antlr:1.10.14=codenarc -org.apache.ant:ant-junit:1.10.14=codenarc -org.apache.bcel:bcel:6.11.0=spotbugs -org.apache.commons:commons-lang3:3.19.0=spotbugs -org.apache.commons:commons-pool2:2.11.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.commons:commons-pool2:2.6.2=compileClasspath -org.apache.commons:commons-text:1.14.0=spotbugs -org.apache.logging.log4j:log4j-api:2.25.2=spotbugs -org.apache.logging.log4j:log4j-core:2.25.2=spotbugs -org.apiguardian:apiguardian-api:1.1.2=latestDepTestCompileClasspath,testCompileClasspath -org.checkerframework:checker-qual:3.33.0=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -org.codehaus.groovy:groovy-ant:3.0.23=codenarc -org.codehaus.groovy:groovy-docgenerator:3.0.23=codenarc -org.codehaus.groovy:groovy-groovydoc:3.0.23=codenarc -org.codehaus.groovy:groovy-json:3.0.23=codenarc -org.codehaus.groovy:groovy-json:3.0.25=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codehaus.groovy:groovy-templates:3.0.23=codenarc -org.codehaus.groovy:groovy-xml:3.0.23=codenarc -org.codehaus.groovy:groovy:3.0.23=codenarc -org.codehaus.groovy:groovy:3.0.25=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codenarc:CodeNarc:3.7.0=codenarc -org.dom4j:dom4j:2.2.0=spotbugs -org.gmetrics:GMetrics:2.1.0=codenarc -org.hamcrest:hamcrest-core:1.3=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.hamcrest:hamcrest:3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.jctools:jctools-core-jdk11:4.0.6=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.jctools:jctools-core:4.0.6=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-api:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:5.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:1.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:1.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-launcher:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-runner:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-suite-api:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-suite-commons:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit:junit-bom:5.14.0=spotbugs -org.junit:junit-bom:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.mockito:mockito-core:4.4.0=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.objenesis:objenesis:3.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.opentest4j:opentest4j:1.3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.7.1=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.9=spotbugs -org.ow2.asm:asm-commons:9.7.1=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath -org.ow2.asm:asm-commons:9.9=spotbugs -org.ow2.asm:asm-commons:9.9.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-tree:9.7.1=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath -org.ow2.asm:asm-tree:9.9=spotbugs -org.ow2.asm:asm-tree:9.9.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-util:9.7.1=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-util:9.9=spotbugs -org.ow2.asm:asm:9.7.1=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath -org.ow2.asm:asm:9.9=spotbugs -org.ow2.asm:asm:9.9.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.slf4j:jcl-over-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:jul-to-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:log4j-over-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:1.7.30=buildTimeInstrumentationPlugin,compileClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath -org.slf4j:slf4j-api:1.7.32=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:2.0.17=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.snakeyaml:snakeyaml-engine:2.9=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.spockframework:spock-bom:2.4-groovy-3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.spockframework:spock-core:2.4-groovy-3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.xmlresolver:xmlresolver:5.3.3=spotbugs -redis.clients:jedis:3.10.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath -redis.clients:jedis:3.3.0=compileClasspath -redis.clients:jedis:3.8.0=testCompileClasspath,testRuntimeClasspath -empty=spotbugsPlugins diff --git a/dd-java-agent/instrumentation/jedis/jedis-3.0/src/main/java/datadog/trace/instrumentation/jedis30/JedisClientDecorator.java b/dd-java-agent/instrumentation/jedis/jedis-3.0/src/main/java/datadog/trace/instrumentation/jedis30/JedisClientDecorator.java deleted file mode 100644 index edaaa9278b3..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-3.0/src/main/java/datadog/trace/instrumentation/jedis30/JedisClientDecorator.java +++ /dev/null @@ -1,58 +0,0 @@ -package datadog.trace.instrumentation.jedis30; - -import datadog.trace.api.naming.SpanNaming; -import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; -import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; -import datadog.trace.bootstrap.instrumentation.decorator.DBTypeProcessingDatabaseClientDecorator; -import redis.clients.jedis.Connection; - -public class JedisClientDecorator extends DBTypeProcessingDatabaseClientDecorator { - public static final JedisClientDecorator DECORATE = new JedisClientDecorator(); - - private static final String REDIS = "redis"; - public static final CharSequence OPERATION_NAME = - UTF8BytesString.create(SpanNaming.instance().namingSchema().cache().operation(REDIS)); - private static final String SERVICE_NAME = - SpanNaming.instance().namingSchema().cache().service(REDIS); - private static final CharSequence COMPONENT_NAME = UTF8BytesString.create("redis-command"); - - @Override - protected String[] instrumentationNames() { - return new String[] {"jedis", REDIS}; - } - - @Override - protected String service() { - return SERVICE_NAME; - } - - @Override - protected CharSequence component() { - return COMPONENT_NAME; - } - - @Override - protected CharSequence spanType() { - return InternalSpanTypes.REDIS; - } - - @Override - protected String dbType() { - return REDIS; - } - - @Override - protected String dbUser(final Connection connection) { - return null; - } - - @Override - protected String dbInstance(final Connection connection) { - return null; - } - - @Override - protected String dbHostname(final Connection connection) { - return connection.getHost(); - } -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-3.0/src/main/java/datadog/trace/instrumentation/jedis30/JedisInstrumentation.java b/dd-java-agent/instrumentation/jedis/jedis-3.0/src/main/java/datadog/trace/instrumentation/jedis30/JedisInstrumentation.java deleted file mode 100644 index d9ff072c6a2..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-3.0/src/main/java/datadog/trace/instrumentation/jedis30/JedisInstrumentation.java +++ /dev/null @@ -1,86 +0,0 @@ -package datadog.trace.instrumentation.jedis30; - -import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan; -import static datadog.trace.instrumentation.jedis30.JedisClientDecorator.DECORATE; -import static net.bytebuddy.matcher.ElementMatchers.isMethod; -import static net.bytebuddy.matcher.ElementMatchers.takesArgument; - -import com.google.auto.service.AutoService; -import datadog.trace.agent.tooling.Instrumenter; -import datadog.trace.agent.tooling.InstrumenterModule; -import datadog.trace.bootstrap.CallDepthThreadLocalMap; -import datadog.trace.bootstrap.instrumentation.api.AgentScope; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import net.bytebuddy.asm.Advice; -import redis.clients.jedis.Connection; -import redis.clients.jedis.Protocol; -import redis.clients.jedis.commands.ProtocolCommand; - -@AutoService(InstrumenterModule.class) -public final class JedisInstrumentation extends InstrumenterModule.Tracing - implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice { - - public JedisInstrumentation() { - super("jedis", "redis"); - } - - @Override - public String[] helperClassNames() { - return new String[] { - packageName + ".JedisClientDecorator", - }; - } - - @Override - public String instrumentedType() { - return "redis.clients.jedis.Connection"; - } - - @Override - public void methodAdvice(MethodTransformer transformer) { - transformer.applyAdvice( - isMethod() - .and(named("sendCommand")) - .and(takesArgument(0, named("redis.clients.jedis.commands.ProtocolCommand"))), - JedisInstrumentation.class.getName() + "$JedisAdvice"); - // FIXME: This instrumentation only incorporates sending the command, not processing the result. - } - - public static class JedisAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static AgentScope onEnter( - @Advice.Argument(0) final ProtocolCommand command, @Advice.This final Connection thiz) { - if (CallDepthThreadLocalMap.incrementCallDepth(Connection.class) > 0) { - return null; - } - final AgentSpan span = startSpan(JedisClientDecorator.OPERATION_NAME); - DECORATE.afterStart(span); - DECORATE.onConnection(span, thiz); - - if (command instanceof Protocol.Command) { - DECORATE.onStatement(span, ((Protocol.Command) command).name()); - } else { - // Protocol.Command is the only implementation in the Jedis lib as of 3.1 but this will save - // us if that changes - DECORATE.onStatement(span, new String(command.getRaw())); - } - return activateSpan(span); - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void stopSpan( - @Advice.Enter final AgentScope scope, @Advice.Thrown final Throwable throwable) { - if (scope == null) { - return; - } - CallDepthThreadLocalMap.reset(Connection.class); - DECORATE.onError(scope.span(), throwable); - DECORATE.beforeFinish(scope.span()); - scope.close(); - scope.span().finish(); - } - } -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-3.0/src/test/groovy/Jedis30ClientTest.groovy b/dd-java-agent/instrumentation/jedis/jedis-3.0/src/test/groovy/Jedis30ClientTest.groovy deleted file mode 100644 index ad3ffb46153..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-3.0/src/test/groovy/Jedis30ClientTest.groovy +++ /dev/null @@ -1,359 +0,0 @@ -import datadog.trace.agent.test.naming.VersionedNamingTestBase -import datadog.trace.agent.test.utils.PortUtils -import datadog.trace.api.Config -import datadog.trace.api.DDSpanTypes -import datadog.trace.bootstrap.instrumentation.api.Tags -import redis.clients.jedis.Jedis -import redis.embedded.RedisServer -import spock.lang.Shared - -import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace -import static datadog.trace.api.config.TraceInstrumentationConfig.DB_CLIENT_HOST_SPLIT_BY_INSTANCE -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan - -abstract class Jedis30ClientTest extends VersionedNamingTestBase { - - @Shared - int port = PortUtils.randomOpenPort() - - @Shared - RedisServer redisServer = RedisServer.newRedisServer() - // bind to localhost to avoid firewall popup - .setting("bind 127.0.0.1") - // set max memory to avoid problems in CI - .setting("maxmemory 128M") - .port(port).build() - @Shared - Jedis jedis = new Jedis("localhost", port) - - @Override - void configurePreAgent() { - super.configurePreAgent() - - // This setting should have no effect since decorator returns null for the instance. - injectSysConfig(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true") - } - - def setupSpec() { - println "Using redis: $redisServer.@args" - redisServer.start() - } - - def cleanupSpec() { - redisServer.stop() - jedis.close() - } - - def setup() { - def cleanupSpan = runUnderTrace("cleanup") { - jedis.flushAll() - activeSpan() - } - TEST_WRITER.waitUntilReported(cleanupSpan) - TEST_WRITER.start() - } - - def "set command"() { - when: - jedis.set("foo", "bar") - - then: - assertTraces(1) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "SET" - spanType DDSpanTypes.REDIS - measured true - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } - - def "get command"() { - when: - jedis.set("foo", "bar") - def value = jedis.get("foo") - - then: - value == "bar" - - assertTraces(2) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "SET" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "GET" - spanType DDSpanTypes.REDIS - measured true - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } - - def "command with no arguments"() { - when: - jedis.set("foo", "bar") - def value = jedis.randomKey() - - then: - value == "foo" - - assertTraces(2) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "SET" - spanType DDSpanTypes.REDIS - measured true - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "RANDOMKEY" - spanType DDSpanTypes.REDIS - measured true - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } - - def "hmset and hgetAll commands"() { - when: - - Map h = new HashMap<>() - h.put("key1", "value1") - h.put("key2", "value2") - jedis.hmset("map", h) - - Map result = jedis.hgetAll("map") - - then: - result != null - result == h - - assertTraces(2) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "HMSET" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "HGETALL" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } - - def "zadd and zrangeByScore commands"() { - when: - jedis.zadd("foo", 1d, "a") - jedis.zadd("foo", 10d, "b") - jedis.zadd("foo", 0.1d, "c") - jedis.zadd("foo", 2d, "d") - - Set verify = new HashSet() - verify.add("a") - verify.add("c") - verify.add("d") - Set val = jedis.zrangeByScore("foo", 0d, 2d) - - then: - val != null - val == verify - - assertTraces(5) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZADD" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZADD" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZADD" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZADD" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZRANGEBYSCORE" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } -} - -class Jedis30ClientV0Test extends Jedis30ClientTest { - - @Override - int version() { - return 0 - } - - @Override - String service() { - return "redis" - } - - @Override - String operation() { - return "redis.query" - } -} - -class Jedis30ClientV1ForkedTest extends Jedis30ClientTest { - - @Override - int version() { - return 1 - } - - @Override - String service() { - return Config.get().getServiceName() - } - - @Override - String operation() { - return "redis.command" - } -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-4.0/build.gradle b/dd-java-agent/instrumentation/jedis/jedis-4.0/build.gradle deleted file mode 100644 index b3166b4d5f4..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-4.0/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ - -muzzle { - fail { - group = "redis.clients" - module = "jedis" - versions = "[,4.0.0)" - } - - pass { - group = "redis.clients" - module = "jedis" - versions = "[4.0.0,)" - } -} - -apply from: "$rootDir/gradle/java.gradle" - -addTestSuiteForDir('latestDepTest', 'test') - -dependencies { - compileOnly group: 'redis.clients', name: 'jedis', version: '4.0.0' - - testImplementation group: 'com.github.codemonstur', name: 'embedded-redis', version: '1.4.3' - testImplementation group: 'redis.clients', name: 'jedis', version: '4.0.0' - // ensures jedis-1.4 and jedis-3.0 instrumentation does not load with jedis 4.0+ by failing - // the tests in the event it does. The tests will end up with double spans - testImplementation project(':dd-java-agent:instrumentation:jedis:jedis-1.4') - testImplementation project(':dd-java-agent:instrumentation:jedis:jedis-3.0') - - latestDepTestImplementation group: 'redis.clients', name: 'jedis', version: '4.+' -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-4.0/gradle.lockfile b/dd-java-agent/instrumentation/jedis/jedis-4.0/gradle.lockfile deleted file mode 100644 index ac52623c5ea..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-4.0/gradle.lockfile +++ /dev/null @@ -1,132 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -cafe.cryptography:curve25519-elisabeth:0.1.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -cafe.cryptography:ed25519-elisabeth:0.1.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -ch.qos.logback:logback-classic:1.2.13=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -ch.qos.logback:logback-core:1.2.13=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.blogspot.mydailyjava:weak-lock-free:0.17=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq.okhttp3:okhttp:3.12.15=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq.okio:okio:1.17.6=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq:dd-instrument-java:0.0.3=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq:dd-javac-plugin-client:0.2.2=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.datadoghq:java-dogstatsd-client:4.4.3=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.datadoghq:sketches-java:0.8.3=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.codemonstur:embedded-redis:1.4.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.github.javaparser:javaparser-core:3.25.6=codenarc -com.github.jnr:jffi:1.3.14=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-a64asm:1.0.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-constants:0.10.4=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-enxio:0.32.19=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-ffi:2.2.18=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-posix:3.1.21=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-unixsocket:0.38.24=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.jnr:jnr-x86asm:1.0.2=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.github.spotbugs:spotbugs-annotations:4.9.8=compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.github.spotbugs:spotbugs:4.9.8=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.1.1=annotationProcessor,compileClasspath,latestDepTestAnnotationProcessor,latestDepTestCompileClasspath,testAnnotationProcessor,testCompileClasspath -com.google.auto.service:auto-service:1.1.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,compileClasspath,latestDepTestAnnotationProcessor,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.10.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath -com.google.code.gson:gson:2.13.2=spotbugs -com.google.code.gson:gson:2.8.9=compileClasspath,testCompileClasspath,testRuntimeClasspath -com.google.errorprone:error_prone_annotations:2.18.0=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.guava:failureaccess:1.0.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.guava:guava:20.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:guava:32.0.1-jre=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:2.8=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -com.google.re2j:re2j:1.7=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -com.squareup.moshi:moshi:1.11.0=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.squareup.okhttp3:logging-interceptor:3.12.12=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.squareup.okhttp3:okhttp:3.12.12=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.squareup.okio:okio:1.17.5=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.thoughtworks.qdox:qdox:1.12.1=codenarc -commons-fileupload:commons-fileupload:1.5=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -commons-io:commons-io:2.11.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -commons-io:commons-io:2.20.0=spotbugs -de.thetaphi:forbiddenapis:3.10=compileClasspath -io.leangen.geantyref:geantyref:1.3.16=latestDepTestRuntimeClasspath,testRuntimeClasspath -io.sqreen:libsqreen:17.3.0=latestDepTestRuntimeClasspath,testRuntimeClasspath -javax.servlet:javax.servlet-api:3.1.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -jaxen:jaxen:2.0.0=spotbugs -junit:junit:4.13.2=latestDepTestRuntimeClasspath,testRuntimeClasspath -net.bytebuddy:byte-buddy-agent:1.18.3=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -net.bytebuddy:byte-buddy:1.18.3=buildTimeInstrumentationPlugin,compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -net.java.dev.jna:jna-platform:5.8.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -net.java.dev.jna:jna:5.8.0=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=spotbugs -org.apache.ant:ant-antlr:1.10.14=codenarc -org.apache.ant:ant-junit:1.10.14=codenarc -org.apache.bcel:bcel:6.11.0=spotbugs -org.apache.commons:commons-lang3:3.19.0=spotbugs -org.apache.commons:commons-pool2:2.11.1=compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.commons:commons-text:1.14.0=spotbugs -org.apache.logging.log4j:log4j-api:2.25.2=spotbugs -org.apache.logging.log4j:log4j-core:2.25.2=spotbugs -org.apiguardian:apiguardian-api:1.1.2=latestDepTestCompileClasspath,testCompileClasspath -org.checkerframework:checker-qual:3.33.0=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor -org.codehaus.groovy:groovy-ant:3.0.23=codenarc -org.codehaus.groovy:groovy-docgenerator:3.0.23=codenarc -org.codehaus.groovy:groovy-groovydoc:3.0.23=codenarc -org.codehaus.groovy:groovy-json:3.0.23=codenarc -org.codehaus.groovy:groovy-json:3.0.25=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codehaus.groovy:groovy-templates:3.0.23=codenarc -org.codehaus.groovy:groovy-xml:3.0.23=codenarc -org.codehaus.groovy:groovy:3.0.23=codenarc -org.codehaus.groovy:groovy:3.0.25=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codenarc:CodeNarc:3.7.0=codenarc -org.dom4j:dom4j:2.2.0=spotbugs -org.gmetrics:GMetrics:2.1.0=codenarc -org.hamcrest:hamcrest-core:1.3=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.hamcrest:hamcrest:3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.jctools:jctools-core-jdk11:4.0.6=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.jctools:jctools-core:4.0.6=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.json:json:20211205=compileClasspath,testCompileClasspath,testRuntimeClasspath -org.json:json:20231013=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath -org.junit.jupiter:junit-jupiter-api:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:5.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:1.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:1.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-launcher:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-runner:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-suite-api:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-suite-commons:1.14.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.junit:junit-bom:5.14.0=spotbugs -org.junit:junit-bom:5.14.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.mockito:mockito-core:4.4.0=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.objenesis:objenesis:3.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.opentest4j:opentest4j:1.3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.7.1=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.9=spotbugs -org.ow2.asm:asm-commons:9.7.1=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath -org.ow2.asm:asm-commons:9.9=spotbugs -org.ow2.asm:asm-commons:9.9.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-tree:9.7.1=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath -org.ow2.asm:asm-tree:9.9=spotbugs -org.ow2.asm:asm-tree:9.9.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-util:9.7.1=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.ow2.asm:asm-util:9.9=spotbugs -org.ow2.asm:asm:9.7.1=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath -org.ow2.asm:asm:9.9=spotbugs -org.ow2.asm:asm:9.9.1=latestDepTestRuntimeClasspath,testRuntimeClasspath -org.slf4j:jcl-over-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:jul-to-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:log4j-over-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:1.7.30=buildTimeInstrumentationPlugin,muzzleBootstrap,muzzleTooling,runtimeClasspath -org.slf4j:slf4j-api:1.7.32=compileClasspath,testCompileClasspath,testRuntimeClasspath -org.slf4j:slf4j-api:1.7.36=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath -org.slf4j:slf4j-api:2.0.17=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.snakeyaml:snakeyaml-engine:2.9=buildTimeInstrumentationPlugin,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath -org.spockframework:spock-bom:2.4-groovy-3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.spockframework:spock-core:2.4-groovy-3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.xmlresolver:xmlresolver:5.3.3=spotbugs -redis.clients:jedis:4.0.0=compileClasspath,testCompileClasspath,testRuntimeClasspath -redis.clients:jedis:4.4.8=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath -empty=spotbugsPlugins diff --git a/dd-java-agent/instrumentation/jedis/jedis-4.0/src/main/java/datadog/trace/instrumentation/jedis40/JedisInstrumentation.java b/dd-java-agent/instrumentation/jedis/jedis-4.0/src/main/java/datadog/trace/instrumentation/jedis40/JedisInstrumentation.java deleted file mode 100644 index a40bc392c00..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-4.0/src/main/java/datadog/trace/instrumentation/jedis40/JedisInstrumentation.java +++ /dev/null @@ -1,84 +0,0 @@ -package datadog.trace.instrumentation.jedis40; - -import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan; -import static net.bytebuddy.matcher.ElementMatchers.isMethod; -import static net.bytebuddy.matcher.ElementMatchers.isPublic; -import static net.bytebuddy.matcher.ElementMatchers.takesArgument; -import static redis.clients.jedis.JedisClientDecorator.DECORATE; - -import com.google.auto.service.AutoService; -import datadog.trace.agent.tooling.Instrumenter; -import datadog.trace.agent.tooling.InstrumenterModule; -import datadog.trace.bootstrap.instrumentation.api.AgentScope; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import net.bytebuddy.asm.Advice; -import redis.clients.jedis.CommandObject; -import redis.clients.jedis.Connection; -import redis.clients.jedis.JedisClientDecorator; -import redis.clients.jedis.Protocol; -import redis.clients.jedis.commands.ProtocolCommand; - -@AutoService(InstrumenterModule.class) -public final class JedisInstrumentation extends InstrumenterModule.Tracing - implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice { - - public JedisInstrumentation() { - super("jedis", "redis"); - } - - @Override - public String instrumentedType() { - return "redis.clients.jedis.Connection"; - } - - @Override - public String[] helperClassNames() { - return new String[] { - "redis.clients.jedis.JedisClientDecorator", - }; - } - - @Override - public void methodAdvice(MethodTransformer transformer) { - transformer.applyAdvice( - isMethod() - .and(isPublic()) - .and(named("executeCommand")) - .and(takesArgument(0, named("redis.clients.jedis.CommandObject"))), - JedisInstrumentation.class.getName() + "$JedisAdvice"); - } - - public static class JedisAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static AgentScope onEnter( - @Advice.Argument(0) final CommandObject commandObject, - @Advice.This final Connection thiz) { - final AgentSpan span = startSpan(JedisClientDecorator.OPERATION_NAME); - DECORATE.afterStart(span); - DECORATE.onConnection(span, thiz); - - final ProtocolCommand command = commandObject.getArguments().getCommand(); - - if (command instanceof Protocol.Command) { - DECORATE.onStatement(span, ((Protocol.Command) command).name()); - } else { - // Protocol.Command is the only implementation in the Jedis lib as of 3.1 but this will save - // us if that changes - DECORATE.onStatement(span, new String(command.getRaw())); - } - return activateSpan(span); - } - - @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void stopSpan( - @Advice.Enter final AgentScope scope, @Advice.Thrown final Throwable throwable) { - DECORATE.onError(scope.span(), throwable); - DECORATE.beforeFinish(scope.span()); - scope.close(); - scope.span().finish(); - } - } -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-4.0/src/main/java/redis/clients/jedis/JedisClientDecorator.java b/dd-java-agent/instrumentation/jedis/jedis-4.0/src/main/java/redis/clients/jedis/JedisClientDecorator.java deleted file mode 100644 index ccbfc3d3418..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-4.0/src/main/java/redis/clients/jedis/JedisClientDecorator.java +++ /dev/null @@ -1,58 +0,0 @@ -package redis.clients.jedis; - -import datadog.trace.api.naming.SpanNaming; -import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; -import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; -import datadog.trace.bootstrap.instrumentation.decorator.DBTypeProcessingDatabaseClientDecorator; - -public class JedisClientDecorator extends DBTypeProcessingDatabaseClientDecorator { - public static final JedisClientDecorator DECORATE = new JedisClientDecorator(); - - private static final String REDIS = "redis"; - public static final CharSequence OPERATION_NAME = - UTF8BytesString.create(SpanNaming.instance().namingSchema().cache().operation(REDIS)); - private static final String SERVICE_NAME = - SpanNaming.instance().namingSchema().cache().service(REDIS); - private static final CharSequence COMPONENT_NAME = UTF8BytesString.create("redis-command"); - - @Override - protected String[] instrumentationNames() { - return new String[] {"jedis", REDIS}; - } - - @Override - protected String service() { - return SERVICE_NAME; - } - - @Override - protected CharSequence component() { - return COMPONENT_NAME; - } - - @Override - protected CharSequence spanType() { - return InternalSpanTypes.REDIS; - } - - @Override - protected String dbType() { - return REDIS; - } - - @Override - protected String dbUser(final Connection connection) { - return null; - } - - @Override - protected String dbInstance(final Connection connection) { - return null; - } - - @Override - protected String dbHostname(Connection connection) { - // getHostAndPort is protected hence the decorator sits in the same package - return connection.getHostAndPort().getHost(); - } -} diff --git a/dd-java-agent/instrumentation/jedis/jedis-4.0/src/test/groovy/Jedis40ClientTest.groovy b/dd-java-agent/instrumentation/jedis/jedis-4.0/src/test/groovy/Jedis40ClientTest.groovy deleted file mode 100644 index d793192a114..00000000000 --- a/dd-java-agent/instrumentation/jedis/jedis-4.0/src/test/groovy/Jedis40ClientTest.groovy +++ /dev/null @@ -1,359 +0,0 @@ -import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace -import static datadog.trace.api.config.TraceInstrumentationConfig.DB_CLIENT_HOST_SPLIT_BY_INSTANCE -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan - -import datadog.trace.agent.test.naming.VersionedNamingTestBase -import datadog.trace.agent.test.utils.PortUtils -import datadog.trace.api.Config -import datadog.trace.api.DDSpanTypes -import datadog.trace.bootstrap.instrumentation.api.Tags -import redis.clients.jedis.Jedis -import redis.embedded.RedisServer -import spock.lang.Shared - -abstract class Jedis40ClientTest extends VersionedNamingTestBase { - - @Shared - int port = PortUtils.randomOpenPort() - - @Shared - RedisServer redisServer = RedisServer.newRedisServer() - // bind to localhost to avoid firewall popup - .setting("bind 127.0.0.1") - // set max memory to avoid problems in CI - .setting("maxmemory 128M") - .port(port).build() - @Shared - Jedis jedis = new Jedis("localhost", port) - - @Override - void configurePreAgent() { - super.configurePreAgent() - - // This setting should have no effect since decorator returns null for the instance. - injectSysConfig(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true") - } - - def setupSpec() { - println "Using redis: $redisServer.@args" - redisServer.start() - } - - def cleanupSpec() { - redisServer.stop() - jedis.close() - } - - def setup() { - def cleanupSpan = runUnderTrace("cleanup") { - jedis.flushAll() - activeSpan() - } - TEST_WRITER.waitUntilReported(cleanupSpan) - TEST_WRITER.start() - } - - def "set command"() { - when: - jedis.set("foo", "bar") - - then: - assertTraces(1) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "SET" - spanType DDSpanTypes.REDIS - measured true - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } - - def "get command"() { - when: - jedis.set("foo", "bar") - def value = jedis.get("foo") - - then: - value == "bar" - - assertTraces(2) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "SET" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "GET" - spanType DDSpanTypes.REDIS - measured true - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } - - def "command with no arguments"() { - when: - jedis.set("foo", "bar") - def value = jedis.randomKey() - - then: - value == "foo" - - assertTraces(2) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "SET" - spanType DDSpanTypes.REDIS - measured true - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "RANDOMKEY" - spanType DDSpanTypes.REDIS - measured true - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } - - def "hmset and hgetAll commands"() { - when: - - Map h = new HashMap<>() - h.put("key1", "value1") - h.put("key2", "value2") - jedis.hmset("map", h) - - Map result = jedis.hgetAll("map") - - then: - result != null - result == h - - assertTraces(2) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "HMSET" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "HGETALL" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } - - def "zadd and zrangeByScore commands"() { - when: - jedis.zadd("foo", 1d, "a") - jedis.zadd("foo", 10d, "b") - jedis.zadd("foo", 0.1d, "c") - jedis.zadd("foo", 2d, "d") - - Set verify = new HashSet() - verify.add("a") - verify.add("c") - verify.add("d") - Set val = jedis.zrangeByScore("foo", 0d, 2d) - - then: - val != null - val == verify - - assertTraces(5) { - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZADD" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZADD" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZADD" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZADD" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - trace(1) { - span { - serviceName service() - operationName operation() - resourceName "ZRANGEBYSCORE" - spanType DDSpanTypes.REDIS - tags { - "$Tags.COMPONENT" "redis-command" - "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT - "$Tags.DB_TYPE" "redis" - "$Tags.PEER_HOSTNAME" "localhost" - peerServiceFrom(Tags.PEER_HOSTNAME) - defaultTags() - } - } - } - } - } -} - -class Jedis40ClientV0ForkedTest extends Jedis40ClientTest { - - @Override - int version() { - return 0 - } - - @Override - String service() { - return "redis" - } - - @Override - String operation() { - return "redis.query" - } -} - -class Jedis40ClientV1ForkedTest extends Jedis40ClientTest { - - @Override - int version() { - return 1 - } - - @Override - String service() { - return Config.get().getServiceName() - } - - @Override - String operation() { - return "redis.command" - } -} diff --git a/dd-trace-api/src/test/java/datadog/trace/api/DDSpanIdTest.java b/dd-trace-api/src/test/java/datadog/trace/api/DDSpanIdTest.java index 2499173f29f..cb2af17dcc0 100644 --- a/dd-trace-api/src/test/java/datadog/trace/api/DDSpanIdTest.java +++ b/dd-trace-api/src/test/java/datadog/trace/api/DDSpanIdTest.java @@ -19,12 +19,12 @@ class DDSpanIdTest { @TableTest({ - "scenario | stringId | expectedId ", - "zero | '0' | 0 ", - "one | '1' | 1 ", - "max | '18446744073709551615' | DDSpanId.MAX ", - "long max | '9223372036854775807' | Long.MAX_VALUE", - "long max plus one | '9223372036854775808' | Long.MIN_VALUE" + "scenario | stringId | expectedId ", + "zero | '0' | 0 ", + "one | '1' | 1 ", + "max | '18446744073709551615' | DDSpanId.MAX ", + "long max | '9223372036854775807' | Long.MAX_VALUE", + "long max plus one | '9223372036854775808' | Long.MIN_VALUE" }) @ParameterizedTest(name = "convert ids from/to String [{index}]") void convertIdsFromToString(String stringId, long expectedId) { @@ -51,15 +51,15 @@ void failOnIllegalString(String stringId) { } @TableTest({ - "scenario | hexId | expectedId ", - "zero | '0' | 0 ", - "one | '1' | 1 ", - "max | 'ffffffffffffffff' | DDSpanId.MAX ", - "long max | '7fffffffffffffff' | Long.MAX_VALUE ", - "long min | '8000000000000000' | Long.MIN_VALUE ", - "long min with leading zeros | '00008000000000000000' | Long.MIN_VALUE ", - "hex sample | 'cafebabe' | 3405691582 ", - "fifteen hex digits | '123456789abcdef' | 81985529216486895" + "scenario | hexId | expectedId ", + "zero | '0' | 0 ", + "one | '1' | 1 ", + "max | 'ffffffffffffffff' | DDSpanId.MAX ", + "long max | '7fffffffffffffff' | Long.MAX_VALUE ", + "long min | '8000000000000000' | Long.MIN_VALUE ", + "long min with leading zeros | '00008000000000000000' | Long.MIN_VALUE ", + "hex sample | 'cafebabe' | 3405691582 ", + "fifteen hex digits | '123456789abcdef' | 81985529216486895" }) @ParameterizedTest(name = "convert ids from/to hex String [{index}]") void convertIdsFromToHexString(String hexId, long expectedId) { @@ -77,17 +77,17 @@ void convertIdsFromToHexString(String hexId, long expectedId) { } @TableTest({ - "scenario | hexId | start | length | lowerCaseOnly | expectedId ", - "null input | | 1 | 1 | false | ", - "empty input | '' | 1 | 1 | false | ", - "negative start | '00' | -1 | 1 | false | ", - "zero length | '00' | 0 | 0 | false | ", - "single zero at index 0 | '00' | 0 | 1 | false | DDSpanId.ZERO", - "single zero at index 1 | '00' | 1 | 1 | false | DDSpanId.ZERO", - "single zero at index 1 duplicate | '00' | 1 | 1 | false | DDSpanId.ZERO", - "max lower-case | 'ffffffffffffffff' | 0 | 16 | true | DDSpanId.MAX ", - "upper-case rejected when lower-case only | 'ffffffffffffFfff' | 0 | 16 | true | ", - "upper-case accepted when lower disabled | 'ffffffffffffFfff' | 0 | 16 | false | DDSpanId.MAX " + "scenario | hexId | start | length | lowerCaseOnly | expectedId ", + "null input | | 1 | 1 | false | ", + "empty input | '' | 1 | 1 | false | ", + "negative start | '00' | -1 | 1 | false | ", + "zero length | '00' | 0 | 0 | false | ", + "single zero at index 0 | '00' | 0 | 1 | false | DDSpanId.ZERO", + "single zero at index 1 | '00' | 1 | 1 | false | DDSpanId.ZERO", + "single zero at index 1 duplicate | '00' | 1 | 1 | false | DDSpanId.ZERO", + "max lower-case | 'ffffffffffffffff' | 0 | 16 | true | DDSpanId.MAX ", + "upper-case rejected when lower-case only | 'ffffffffffffFfff' | 0 | 16 | true | ", + "upper-case accepted when lower disabled | 'ffffffffffffFfff' | 0 | 16 | false | DDSpanId.MAX " }) @ParameterizedTest(name = "convert ids from part of hex String [{index}]") void convertIdsFromPartOfHexString( diff --git a/dd-trace-api/src/test/java/datadog/trace/api/DDTraceIdTest.java b/dd-trace-api/src/test/java/datadog/trace/api/DDTraceIdTest.java index 3820b17c256..2cb4da9bf21 100644 --- a/dd-trace-api/src/test/java/datadog/trace/api/DDTraceIdTest.java +++ b/dd-trace-api/src/test/java/datadog/trace/api/DDTraceIdTest.java @@ -16,12 +16,12 @@ class DDTraceIdTest { @TableTest({ - "scenario | longId | expectedString | expectedHex ", - "zero | 0 | '0' | '00000000000000000000000000000000'", - "one | 1 | '1' | '00000000000000000000000000000001'", - "minus one | -1 | '18446744073709551615' | '0000000000000000ffffffffffffffff'", - "long max | Long.MAX_VALUE | '9223372036854775807' | '00000000000000007fffffffffffffff'", - "long min | Long.MIN_VALUE | '9223372036854775808' | '00000000000000008000000000000000'" + "scenario | longId | expectedString | expectedHex ", + "zero | 0 | '0' | '00000000000000000000000000000000'", + "one | 1 | '1' | '00000000000000000000000000000001'", + "minus one | -1 | '18446744073709551615' | '0000000000000000ffffffffffffffff'", + "long max | Long.MAX_VALUE | '9223372036854775807' | '00000000000000007fffffffffffffff'", + "long min | Long.MIN_VALUE | '9223372036854775808' | '00000000000000008000000000000000'" }) @ParameterizedTest(name = "convert 64-bit ids from/to long and check strings [{index}]") void convert64BitIdsFromToLongAndCheckStrings( @@ -39,12 +39,12 @@ void convert64BitIdsFromToLongAndCheckStrings( } @TableTest({ - "scenario | stringId | expectedId ", - "zero | '0' | DD64bTraceId.ZERO ", - "one | '1' | DD64bTraceId.ONE ", - "max | '18446744073709551615' | DD64bTraceId.MAX ", - "long max | '9223372036854775807' | DD64bTraceId.LONG_MAX", - "long max plus one | '9223372036854775808' | DD64bTraceId.LONG_MIN" + "scenario | stringId | expectedId ", + "zero | '0' | DD64bTraceId.ZERO ", + "one | '1' | DD64bTraceId.ONE ", + "max | '18446744073709551615' | DD64bTraceId.MAX ", + "long max | '9223372036854775807' | DD64bTraceId.LONG_MAX", + "long max plus one | '9223372036854775808' | DD64bTraceId.LONG_MIN" }) @ParameterizedTest(name = "convert 64-bit ids from/to String representation [{index}]") void convert64BitIdsFromToStringRepresentation(String stringId, DD64bTraceId expectedId) { @@ -71,15 +71,15 @@ void failParsingIllegal64BitIdStringRepresentation(String stringId) { } @TableTest({ - "scenario | hexId | expectedId ", - "zero | '0' | DD64bTraceId.ZERO ", - "one | '1' | DD64bTraceId.ONE ", - "max | 'ffffffffffffffff' | DD64bTraceId.MAX ", - "long max | '7fffffffffffffff' | DD64bTraceId.LONG_MAX", - "long min | '8000000000000000' | DD64bTraceId.LONG_MIN", - "long min with leading zeros | '00008000000000000000' | DD64bTraceId.LONG_MIN", - "hex sample | 'cafebabe' | DD64bTraceId.CAFEBABE", - "fifteen hex digits | '123456789abcdef' | DD64bTraceId.HEX " + "scenario | hexId | expectedId ", + "zero | '0' | DD64bTraceId.ZERO ", + "one | '1' | DD64bTraceId.ONE ", + "max | 'ffffffffffffffff' | DD64bTraceId.MAX ", + "long max | '7fffffffffffffff' | DD64bTraceId.LONG_MAX", + "long min | '8000000000000000' | DD64bTraceId.LONG_MIN", + "long min with leading zeros | '00008000000000000000' | DD64bTraceId.LONG_MIN", + "hex sample | 'cafebabe' | DD64bTraceId.CAFEBABE", + "fifteen hex digits | '123456789abcdef' | DD64bTraceId.HEX " }) @ParameterizedTest(name = "convert 64-bit ids from/to hex String representation [{index}]") void convert64BitIdsFromToHexStringRepresentation(String hexId, DD64bTraceId expectedId) { @@ -103,25 +103,25 @@ void failParsingIllegal64BitHexadecimalStringRepresentation(String hexId) { } @TableTest({ - "scenario | highOrderBits | lowOrderBits | hexId ", - "both long min | Long.MIN_VALUE | Long.MIN_VALUE | '80000000000000008000000000000000'", - "high long min low one | Long.MIN_VALUE | 1 | '80000000000000000000000000000001'", - "high long min low long max | Long.MIN_VALUE | Long.MAX_VALUE | '80000000000000007fffffffffffffff'", - "high one low long min | 1 | Long.MIN_VALUE | '00000000000000018000000000000000'", - "high one low one | 1 | 1 | '00000000000000010000000000000001'", - "high one low long max | 1 | Long.MAX_VALUE | '00000000000000017fffffffffffffff'", - "high long max low long min | Long.MAX_VALUE | Long.MIN_VALUE | '7fffffffffffffff8000000000000000'", - "high long max low one | Long.MAX_VALUE | 1 | '7fffffffffffffff0000000000000001'", - "high long max low long max | Long.MAX_VALUE | Long.MAX_VALUE | '7fffffffffffffff7fffffffffffffff'", - "all zeros length one | 0 | 0 | '0' ", - "all zeros length sixteen | 0 | 0 | '0000000000000000' ", - "all zeros length seventeen | 0 | 0 | '00000000000000000' ", - "all zeros length thirty-two | 0 | 0 | '00000000000000000000000000000000'", - "low fifteen | 0 | 15 | 'f' ", - "low minus one | 0 | -1 | 'ffffffffffffffff' ", - "high fifteen low minus one | 15 | -1 | 'fffffffffffffffff' ", - "all f | -1 | -1 | 'ffffffffffffffffffffffffffffffff'", - "hex literal | 1311768467463790320 | 1311768467463790320 | '123456789abcdef0123456789abcdef0'" + "scenario | highOrderBits | lowOrderBits | hexId ", + "both long min | Long.MIN_VALUE | Long.MIN_VALUE | '80000000000000008000000000000000'", + "high long min low one | Long.MIN_VALUE | 1 | '80000000000000000000000000000001'", + "high long min low long max | Long.MIN_VALUE | Long.MAX_VALUE | '80000000000000007fffffffffffffff'", + "high one low long min | 1 | Long.MIN_VALUE | '00000000000000018000000000000000'", + "high one low one | 1 | 1 | '00000000000000010000000000000001'", + "high one low long max | 1 | Long.MAX_VALUE | '00000000000000017fffffffffffffff'", + "high long max low long min | Long.MAX_VALUE | Long.MIN_VALUE | '7fffffffffffffff8000000000000000'", + "high long max low one | Long.MAX_VALUE | 1 | '7fffffffffffffff0000000000000001'", + "high long max low long max | Long.MAX_VALUE | Long.MAX_VALUE | '7fffffffffffffff7fffffffffffffff'", + "all zeros length one | 0 | 0 | '0' ", + "all zeros length sixteen | 0 | 0 | '0000000000000000' ", + "all zeros length seventeen | 0 | 0 | '00000000000000000' ", + "all zeros length thirty-two | 0 | 0 | '00000000000000000000000000000000'", + "low fifteen | 0 | 15 | 'f' ", + "low minus one | 0 | -1 | 'ffffffffffffffff' ", + "high fifteen low minus one | 15 | -1 | 'fffffffffffffffff' ", + "all f | -1 | -1 | 'ffffffffffffffffffffffffffffffff'", + "hex literal | 1311768467463790320 | 1311768467463790320 | '123456789abcdef0123456789abcdef0'" }) @ParameterizedTest( name = "convert 128-bit ids from/to hexadecimal String representation [{index}]") @@ -149,18 +149,18 @@ void failParsingIllegal128BitIdHexadecimalStringRepresentation(String hexId) { } @TableTest({ - "scenario | hexId | start | length | lowerCaseOnly", - "null string | | 0 | 0 | true ", - "empty string | '' | 0 | 0 | true ", - "out of bound length | '123456789abcdef0' | 0 | 17 | true ", - "out of bound end | '123456789abcdef0' | 7 | 10 | true ", - "out of bound start | '123456789abcdef0' | 17 | 0 | true ", - "invalid minus one | '-1' | 0 | 1 | true ", - "invalid minus a | '-a' | 0 | 1 | true ", - "invalid character | '123abcg' | 0 | 7 | true ", - "invalid upper case A | 'A' | 0 | 1 | true ", - "invalid upper case | '123ABC' | 0 | 6 | true ", - "too long | '111111111111111111111111111111111' | 0 | 33 | true " + "scenario | hexId | start | length | lowerCaseOnly", + "null string | | 0 | 0 | true ", + "empty string | '' | 0 | 0 | true ", + "out of bound length | '123456789abcdef0' | 0 | 17 | true ", + "out of bound end | '123456789abcdef0' | 7 | 10 | true ", + "out of bound start | '123456789abcdef0' | 17 | 0 | true ", + "invalid minus one | '-1' | 0 | 1 | true ", + "invalid minus a | '-a' | 0 | 1 | true ", + "invalid character | '123abcg' | 0 | 7 | true ", + "invalid upper case A | 'A' | 0 | 1 | true ", + "invalid upper case | '123ABC' | 0 | 6 | true ", + "too long | '111111111111111111111111111111111' | 0 | 33 | true " }) @ParameterizedTest( name = diff --git a/dd-trace-api/src/test/java/datadog/trace/api/IdGenerationStrategyTest.java b/dd-trace-api/src/test/java/datadog/trace/api/IdGenerationStrategyTest.java index e5b5a8efcf9..d01bcc6082a 100644 --- a/dd-trace-api/src/test/java/datadog/trace/api/IdGenerationStrategyTest.java +++ b/dd-trace-api/src/test/java/datadog/trace/api/IdGenerationStrategyTest.java @@ -18,9 +18,9 @@ class IdGenerationStrategyTest { @TableTest({ - "scenario | traceId128BitGenerationEnabled | strategyName ", - "strategies-64-bit | false | {RANDOM, SEQUENTIAL, SECURE_RANDOM}", - "strategies-128-bit | true | {RANDOM, SEQUENTIAL, SECURE_RANDOM}" + "scenario | traceId128BitGenerationEnabled | strategyName ", + "strategies-64-bit | false | {RANDOM, SEQUENTIAL, SECURE_RANDOM}", + "strategies-128-bit | true | {RANDOM, SEQUENTIAL, SECURE_RANDOM}" }) @ParameterizedTest(name = "generate id with {1} and {0} bits") void generateIdWithStrategyAndBitSize( diff --git a/dd-trace-api/src/test/java/datadog/trace/api/internal/util/HexStringUtilsTest.java b/dd-trace-api/src/test/java/datadog/trace/api/internal/util/HexStringUtilsTest.java index 14eb065607d..d3cf14a8624 100644 --- a/dd-trace-api/src/test/java/datadog/trace/api/internal/util/HexStringUtilsTest.java +++ b/dd-trace-api/src/test/java/datadog/trace/api/internal/util/HexStringUtilsTest.java @@ -8,10 +8,10 @@ class HexStringUtilsTest { @TableTest({ - "scenario | highOrderBits | lowOrderBits | size ", - "zero | 0 | 0 | {10, 16, 20, 32, 40}", - "one-two | 1 | 2 | {10, 16, 20, 32, 40}", - "large | 6536977903480360123 | 3270264562721133536 | {10, 16, 20, 32, 40}" + "scenario | highOrderBits | lowOrderBits | size ", + "zero | 0 | 0 | {10, 16, 20, 32, 40}", + "one-two | 1 | 2 | {10, 16, 20, 32, 40}", + "large | 6536977903480360123 | 3270264562721133536 | {10, 16, 20, 32, 40}" }) @ParameterizedTest(name = "test hexadecimal String representations high={0} low={1} size={2}") void testHexadecimalStringRepresentations(long highOrderBits, long lowOrderBits, int size) { From 5ce42231e29bc41b6f5f42ba085885fdc7ef00c2 Mon Sep 17 00:00:00 2001 From: Jordan Wong Date: Fri, 20 Mar 2026 14:53:24 -0400 Subject: [PATCH 2/2] eval: add generated jedis 1.4 instrumentation (blind test, config v1) Generated by apm-instrumentation-toolkit using add-apm-integrations skill v1. This is a blind test run - jedis was deleted from the repo before generation. Agent metrics: 423.2s, 96 turns, $3.29 Layer 1 checks all pass: - compileJava, spotlessCheck, codenarcTest, muzzle, test, latestDepTest --- .../jedis/jedis-1.4/build.gradle | 25 ++ .../jedis/JedisClientDecorator.java | 57 +++++ .../jedis/JedisInstrumentation.java | 86 +++++++ .../src/test/groovy/JedisClientTest.groovy | 215 ++++++++++++++++++ 4 files changed, 383 insertions(+) create mode 100644 dd-java-agent/instrumentation/jedis/jedis-1.4/build.gradle create mode 100644 dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisClientDecorator.java create mode 100644 dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java create mode 100644 dd-java-agent/instrumentation/jedis/jedis-1.4/src/test/groovy/JedisClientTest.groovy diff --git a/dd-java-agent/instrumentation/jedis/jedis-1.4/build.gradle b/dd-java-agent/instrumentation/jedis/jedis-1.4/build.gradle new file mode 100644 index 00000000000..e1ca8af38da --- /dev/null +++ b/dd-java-agent/instrumentation/jedis/jedis-1.4/build.gradle @@ -0,0 +1,25 @@ +muzzle { + pass { + group = "redis.clients" + module = "jedis" + versions = "[1.4.0,3.0.0)" + assertInverse = true + } +} + +apply from: "$rootDir/gradle/java.gradle" + +addTestSuiteForDir('latestDepTest', 'test') + +dependencies { + compileOnly group: 'redis.clients', name: 'jedis', version: '1.4.0' + testImplementation group: 'redis.clients', name: 'jedis', version: '1.4.0' + + testImplementation (group: 'com.github.codemonstur', name: 'embedded-redis', version: '1.4.3') { + // Excluding redis client to avoid conflicts in instrumentation code. + exclude group: 'redis.clients', module: 'jedis' + } + + // Jedis 3.0 has API changes that prevent instrumentation from applying + latestDepTestImplementation group: 'redis.clients', name: 'jedis', version: '2.+' +} diff --git a/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisClientDecorator.java b/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisClientDecorator.java new file mode 100644 index 00000000000..f85167f6ba2 --- /dev/null +++ b/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisClientDecorator.java @@ -0,0 +1,57 @@ +package datadog.trace.instrumentation.jedis; + +import datadog.trace.api.naming.SpanNaming; +import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes; +import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; +import datadog.trace.bootstrap.instrumentation.decorator.DBTypeProcessingDatabaseClientDecorator; +import redis.clients.jedis.Connection; + +public class JedisClientDecorator extends DBTypeProcessingDatabaseClientDecorator { + private static final String REDIS = "redis"; + public static final CharSequence COMPONENT_NAME = UTF8BytesString.create("redis-command"); + public static final CharSequence OPERATION_NAME = + UTF8BytesString.create(SpanNaming.instance().namingSchema().cache().operation(REDIS)); + private static final String SERVICE_NAME = + SpanNaming.instance().namingSchema().cache().service(REDIS); + public static final JedisClientDecorator DECORATE = new JedisClientDecorator(); + + @Override + protected String[] instrumentationNames() { + return new String[] {"jedis", REDIS}; + } + + @Override + protected String service() { + return SERVICE_NAME; + } + + @Override + protected CharSequence component() { + return COMPONENT_NAME; + } + + @Override + protected CharSequence spanType() { + return InternalSpanTypes.REDIS; + } + + @Override + protected String dbType() { + return REDIS; + } + + @Override + protected String dbUser(final Connection connection) { + return null; + } + + @Override + protected String dbInstance(final Connection connection) { + return null; + } + + @Override + protected String dbHostname(Connection connection) { + return connection.getHost(); + } +} diff --git a/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java b/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java new file mode 100644 index 00000000000..79a25c859cf --- /dev/null +++ b/dd-java-agent/instrumentation/jedis/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java @@ -0,0 +1,86 @@ +package datadog.trace.instrumentation.jedis; + +import static datadog.trace.agent.tooling.bytebuddy.matcher.ClassLoaderMatchers.hasClassNamed; +import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; +import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; +import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan; +import static datadog.trace.instrumentation.jedis.JedisClientDecorator.DECORATE; +import static net.bytebuddy.matcher.ElementMatchers.isMethod; +import static net.bytebuddy.matcher.ElementMatchers.not; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; + +import com.google.auto.service.AutoService; +import datadog.trace.agent.tooling.Instrumenter; +import datadog.trace.agent.tooling.InstrumenterModule; +import datadog.trace.bootstrap.CallDepthThreadLocalMap; +import datadog.trace.bootstrap.instrumentation.api.AgentScope; +import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.matcher.ElementMatcher; +import redis.clients.jedis.Connection; +import redis.clients.jedis.Protocol.Command; + +@AutoService(InstrumenterModule.class) +public final class JedisInstrumentation extends InstrumenterModule.Tracing + implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice { + + public JedisInstrumentation() { + super("jedis", "redis"); + } + + @Override + public ElementMatcher.Junction classLoaderMatcher() { + // Avoid matching Jedis 3+ which has its own instrumentation. + return not(hasClassNamed("redis.clients.jedis.commands.ProtocolCommand")); + } + + @Override + public String instrumentedType() { + return "redis.clients.jedis.Connection"; + } + + @Override + public String[] helperClassNames() { + return new String[] { + packageName + ".JedisClientDecorator", + }; + } + + @Override + public void methodAdvice(MethodTransformer transformer) { + transformer.applyAdvice( + isMethod() + .and(named("sendCommand")) + .and(takesArgument(0, named("redis.clients.jedis.Protocol$Command"))), + JedisInstrumentation.class.getName() + "$JedisAdvice"); + } + + public static class JedisAdvice { + + @Advice.OnMethodEnter(suppress = Throwable.class) + public static AgentScope onEnter( + @Advice.Argument(0) final Command command, @Advice.This final Connection thiz) { + if (CallDepthThreadLocalMap.incrementCallDepth(Connection.class) > 0) { + return null; + } + final AgentSpan span = startSpan(JedisClientDecorator.OPERATION_NAME); + DECORATE.afterStart(span); + DECORATE.onConnection(span, thiz); + DECORATE.onStatement(span, command.name()); + return activateSpan(span); + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void stopSpan( + @Advice.Enter final AgentScope scope, @Advice.Thrown final Throwable throwable) { + if (scope == null) { + return; + } + CallDepthThreadLocalMap.reset(Connection.class); + DECORATE.onError(scope.span(), throwable); + DECORATE.beforeFinish(scope.span()); + scope.close(); + scope.span().finish(); + } + } +} diff --git a/dd-java-agent/instrumentation/jedis/jedis-1.4/src/test/groovy/JedisClientTest.groovy b/dd-java-agent/instrumentation/jedis/jedis-1.4/src/test/groovy/JedisClientTest.groovy new file mode 100644 index 00000000000..2e319ced104 --- /dev/null +++ b/dd-java-agent/instrumentation/jedis/jedis-1.4/src/test/groovy/JedisClientTest.groovy @@ -0,0 +1,215 @@ +import datadog.trace.agent.test.naming.VersionedNamingTestBase +import datadog.trace.agent.test.utils.PortUtils +import datadog.trace.api.Config +import datadog.trace.api.DDSpanTypes +import datadog.trace.bootstrap.instrumentation.api.Tags +import redis.clients.jedis.Jedis +import redis.embedded.RedisServer +import spock.lang.Shared + +import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace +import static datadog.trace.api.config.TraceInstrumentationConfig.DB_CLIENT_HOST_SPLIT_BY_INSTANCE +import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan + +abstract class JedisClientTest extends VersionedNamingTestBase { + + @Shared + int port = PortUtils.randomOpenPort() + + @Shared + RedisServer redisServer = RedisServer.newRedisServer() + // bind to localhost to avoid firewall popup + .setting("bind 127.0.0.1") + // set max memory to avoid problems in CI + .setting("maxmemory 128M") + .port(port).build() + + @Shared + Jedis jedis = new Jedis("localhost", port) + + @Override + void configurePreAgent() { + super.configurePreAgent() + + // This setting should have no effect since decorator returns null for the instance. + injectSysConfig(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true") + } + + def setupSpec() { + println "Using redis: $redisServer.@args" + redisServer.start() + } + + def cleanupSpec() { + redisServer.stop() + // jedis.close() // not available in the early version we're using. + } + + def setup() { + def cleanupSpan = runUnderTrace("cleanup") { + jedis.flushAll() + activeSpan() + } + TEST_WRITER.waitUntilReported(cleanupSpan) + TEST_WRITER.start() + } + + def "set command"() { + when: + jedis.set("foo", "bar") + + then: + assertTraces(1) { + trace(1) { + span { + serviceName service() + operationName operation() + resourceName "SET" + spanType DDSpanTypes.REDIS + measured true + tags { + "$Tags.COMPONENT" "redis-command" + "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT + "$Tags.DB_TYPE" "redis" + "$Tags.PEER_HOSTNAME" "localhost" + defaultTags() + } + } + } + } + } + + def "get command"() { + when: + jedis.set("foo", "bar") + def value = jedis.get("foo") + + then: + value == "bar" + + assertTraces(2) { + trace(1) { + span { + serviceName service() + operationName operation() + resourceName "SET" + spanType DDSpanTypes.REDIS + tags { + "$Tags.COMPONENT" "redis-command" + "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT + "$Tags.DB_TYPE" "redis" + "$Tags.PEER_HOSTNAME" "localhost" + peerServiceFrom(Tags.PEER_HOSTNAME) + defaultTags() + } + } + } + trace(1) { + span { + serviceName service() + operationName operation() + resourceName "GET" + spanType DDSpanTypes.REDIS + tags { + "$Tags.COMPONENT" "redis-command" + "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT + "$Tags.DB_TYPE" "redis" + "$Tags.PEER_HOSTNAME" "localhost" + peerServiceFrom(Tags.PEER_HOSTNAME) + defaultTags() + } + } + } + } + } + + def "command with no arguments"() { + when: + jedis.set("foo", "bar") + def value = jedis.randomKey() + + then: + value == "foo" + + assertTraces(2) { + trace(1) { + span { + serviceName service() + operationName operation() + resourceName "SET" + spanType DDSpanTypes.REDIS + tags { + "$Tags.COMPONENT" "redis-command" + "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT + "$Tags.DB_TYPE" "redis" + "$Tags.PEER_HOSTNAME" "localhost" + peerServiceFrom(Tags.PEER_HOSTNAME) + defaultTags() + } + } + } + trace(1) { + span { + serviceName service() + operationName operation() + resourceName "RANDOMKEY" + spanType DDSpanTypes.REDIS + tags { + "$Tags.COMPONENT" "redis-command" + "$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT + "$Tags.DB_TYPE" "redis" + "$Tags.PEER_HOSTNAME" "localhost" + peerServiceFrom(Tags.PEER_HOSTNAME) + defaultTags() + } + } + } + } + } + + @Override + String operation() { + return "redis.query" + } + + @Override + String service() { + return Config.get().getServiceName() + } +} + +class JedisClientV0Test extends JedisClientTest { + + @Override + int version() { + return 0 + } + + @Override + String service() { + return "redis" + } + + @Override + String operation() { + return "redis.query" + } +} + +class JedisClientV1ForkedTest extends JedisClientTest { + + @Override + int version() { + return 1 + } + + @Override + String service() { + return Config.get().getServiceName() + } + + @Override + String operation() { + return "redis.query" + } +}