8000 Create S3 instrumentation + add span pointers by nhulston · Pull Request #8075 · DataDog/dd-trace-java · GitHub
[go: up one dir, main page]

Skip to content

Create S3 instrumentation + add span pointers #8075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
48d5d9f
Add basic S3 instrumentation
nhulston Dec 10, 2024
282ca70
Calculate pointer hash
nhulston Dec 10, 2024
9106b50
Add span pointer to S3 request span
nhulston Dec 10, 2024
d95149e
Unit tests for SpanPointersHelper
nhulston Dec 10, 2024
c2e7727
Integration tests
nhulston Dec 10, 2024
80803a6
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston Dec 10, 2024
49a2179
Specify correct versions to instrument
nhulston Dec 10, 2024
91f6670
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston Dec 11, 2024
fc9b696
code review improvements
nhulston Dec 12, 2024
a913e1f
Merge remote-tracking branch 'origin/nicholas.hulston/s3-span-pointer…
nhulston Dec 12, 2024
1d445fd
update generatePointerHash; avoid operation. Approx 5-10% improvemen…
nhulston Jan 7, 2025
9d3aa69
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston Jan 8, 2025
204c49e
add 'implements Instrumenter.HasMethodAdvice' to S3ClientInstrumentation
nhulston Jan 8, 2025
f88201d
Add env var for disabling span pointers
nhulston Jan 8, 2025
0350cc9
Move env var to Config 8000 class
nhulston Jan 13, 2025
cc6b675
Move hash calculation and span pointer modification to `SpanPointersP…
nhulston Jan 15, 2025
7f49f82
update other implementations of TagsPostProcessor
nhulston Jan 15, 2025
d048f4b
update and migrate tests
nhulston Jan 15, 2025
1645afe
update muzzle
nhulston Jan 16, 2025
843f98d
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston Jan 16, 2025
6ce63c7
update `ADD_SPAN_POINTERS` env var name
nhulston Jan 21, 2025
9b35b30
improve `asString` helper method; improve hash performance
nhulston Jan 21, 2025
6cd7e1f
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston Jan 21, 2025
a516c46
fix checksum flaky tests
nhulston Jan 21, 2025
0362cd8
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston Jan 21, 2025
42c62fe
use generic config. add defaults
amarziali Jan 22, 2025
218c106
refactor constants and fix tests
amarziali Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add basic S3 instrumentation
  • Loading branch information
nhulston committed Dec 10, 2024
commit 48d5d9fb1ceb53fc76916c9954f4730189d6917f
29 changes: 29 additions & 0 deletions dd-java-agent/instrumentation/aws-java-s3-2.0/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
muzzle {
pass {
group = "software.amazon.awssdk"
module = "s3"
versions = "[2.0,3)"
assertInverse = true
}
}

apply from: "$rootDir/gradle/java.gradle"

addTestSuiteForDir('latestDepTest', 'test')
addTestSuiteExtendingForDir('latestDepForkedTest', 'latestDepTest', 'test')

dependencies {
compileOnly group: 'software.amazon.awssdk', name: 's3', version: '2.29.26'

// Include httpclient instrumentation for testing because it is a dependency for aws-sdk.
testImplementation project(':dd-java-agent:instrumentation:apache-httpclient-4')
testImplementation project(':dd-java-agent:instrumentation:aws-java-sdk-2.2')
testImplementation 'software.amazon.awssdk:s3:2.29.26'
testImplementation 'org.testcontainers:localstack:1.20.1'

latestDepTestImplementation group: 'software.amazon.awssdk', name: 's3', version: '+'
}

tasks.withType(Test).configureEach {
usesService(testcontainersLimit)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package datadog.trace.instrumentation.aws.v2.s3;

import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import java.util.List;
import net.bytebuddy.asm.Advice;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;

@AutoService(InstrumenterModule.class)
public final class S3ClientInstrumentation extends InstrumenterModule.Tracing
implements Instrumenter.ForSingleType {
public S3ClientInstrumentation() {
super("s3");
}

@Override
public String instrumentedType() {
return "software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder";
}

@Override
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
isMethod().and(named("resolveExecutionInterceptors")),
S3ClientInstrumentation.class.getName() + "$AwsS3BuilderAdvice");
}

@Override
public String[] helperClassNames() {
return new String[] {packageName + ".S3Interceptor", packageName + ".TextMapInjectAdapter"};
}

public static class AwsS3BuilderAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
public static void addHandler(@Advice.Return final List<ExecutionInterceptor> interceptors) {
for (ExecutionInterceptor interceptor : interceptors) {
if (interceptor instanceof S3Interceptor) {
return; // list already has our interceptor, return to builder
}
}
interceptors.add(new S3Interceptor());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package datadog.trace.instrumentation.aws.v2.s3;

import software.amazon.awssdk.core.interceptor.Context;
import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;

public class S3Interceptor implements ExecutionInterceptor {
@Override
public void afterExecution(
Context.AfterExecution context, ExecutionAttributes executionAttributes) {
System.out.println("S3Interceptor afterExecution()");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package datadog.trace.instrumentation.aws.v2.s3;

import datadog.trace.bootstrap.instrumentation.api.AgentPropagation;

public class TextMapInjectAdapter implements AgentPropagation.Setter<StringBuilder> {

public static final TextMapInjectAdapter SETTER = new TextMapInjectAdapter();

@Override
public void set(final StringBuilder builder, final String key, final String value) {
builder.append('"').append(key).append("\":\"").append(value).append("\",");
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ include ':dd-java-agent:instrumentation:aws-java-sns-1.0'
include ':dd-java-agent:instrumentation:aws-java-sns-2.0'
include ':dd-java-agent:instrumentation:aws-java-sqs-1.0'
include ':dd-java-agent:instrumentation:aws-java-sqs-2.0'
include ':dd-java-agent:instrumentation:aws-java-s3-2.0'
include ':dd-java-agent:instrumentation:aws-lambda-handler'
include ':dd-java-agent:instrumentation:axis-2'
include ':dd-java-agent:instrumentation:axway-api'
Expand Down
0