-
Notifications
You must be signed in to change notification settings - Fork 310
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
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 282ca70
Calculate pointer hash
nhulston 9106b50
Add span pointer to S3 request span
nhulston d95149e
Unit tests for SpanPointersHelper
nhulston c2e7727
Integration tests
nhulston 80803a6
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston 49a2179
Specify correct versions to instrument
nhulston 91f6670
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston fc9b696
code review improvements
nhulston a913e1f
Merge remote-tracking branch 'origin/nicholas.hulston/s3-span-pointer…
nhulston 1d445fd
update generatePointerHash; avoid operation. Approx 5-10% improvemen…
nhulston 9d3aa69
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston 204c49e
add 'implements Instrumenter.HasMethodAdvice' to S3ClientInstrumentation
nhulston f88201d
Add env var for disabling span pointers
nhulston 0350cc9
Move env var to Config
8000
class
nhulston cc6b675
Move hash calculation and span pointer modification to `SpanPointersP…
nhulston 7f49f82
update other implementations of TagsPostProcessor
nhulston d048f4b
update and migrate tests
nhulston 1645afe
update muzzle
nhulston 843f98d
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston 6ce63c7
update `ADD_SPAN_POINTERS` env var name
nhulston 9b35b30
improve `asString` helper method; improve hash performance
nhulston 6cd7e1f
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston a516c46
fix checksum flaky tests
nhulston 0362cd8
Merge branch 'master' into nicholas.hulston/s3-span-pointers
nhulston 42c62fe
use generic config. add defaults
amarziali 218c106
refactor constants and fix tests
amarziali File filter
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
commit 48d5d9fb1ceb53fc76916c9954f4730189d6917f
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
dd-java-agent/instrumentation/aws-java-s3-2.0/build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
48 changes: 48 additions & 0 deletions
48
...s3-2.0/src/main/java/datadog/trace/instrumentation/aws/v2/s3/S3ClientInstrumentation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
PerfectSlayer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
@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()); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../aws-java-s3-2.0/src/main/java/datadog/trace/instrumentation/aws/v2/s3/S3Interceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...va-s3-2.0/src/main/java/datadog/trace/instrumentation/aws/v2/s3/TextMapInjectAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("\","); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.