Skip to content

Commit

Permalink
Merge branch 'master' into kr-igor/dsm-spark-streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
kr-igor authored Dec 31, 2024
2 parents ed9dab8 + c99c2c2 commit d566c95
Show file tree
Hide file tree
Showing 669 changed files with 8,828 additions and 1,973 deletions.
8 changes: 7 additions & 1 deletion .circleci/config.continue.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation
debugger_modules: &debugger_modules "dd-java-agent/agent-debugger|dd-java-agent/agent-bootstrap|dd-java-agent/agent-builder|internal-api|communication|dd-trace-core"
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"

default_system_tests_commit: &default_system_tests_commit 67fe30ac7504997685859d31feae1782f3527f39
default_system_tests_commit: &default_system_tests_commit 6a8c4e9ba065bc52a630051a5b7bb7a4ec84e245

parameters:
nightly:
Expand Down Expand Up @@ -273,6 +273,12 @@ commands:
git fetch origin << parameters.systemTestsCommit >>
git reset --hard FETCH_HEAD

- run:
name: Install dependencies
command: |
sudo apt-get update
sudo apt-get install -y python3.12-venv

jobs:
build:
<<: *defaults
Expand Down
9 changes: 4 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

# Contributor Checklist

- [ ] Format the title [according the contribution guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#title-format)
- [ ] Assign the `type:` and (`comp:` or `inst:`) labels in addition to [any usefull labels](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#labels)
- [ ] Squash your commits prior merging or merge using GitHub's [Squash and merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits)
- [ ] Don't use `close`, `fix` or any [linking keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) when referencing an issue.
- Format the title [according the contribution guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#title-format)
- Assign the `type:` and (`comp:` or `inst:`) labels in addition to [any usefull labels](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#labels)
- Don't use `close`, `fix` or any [linking keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) when referencing an issue.
Use `solves` instead, and assign the PR [milestone](https://github.com/DataDog/dd-trace-java/milestones) to the issue
- [ ] Update the [public documentation](https://docs.datadoghq.com/tracing/trace_collection/library_config/java/) in case of new configuration flag or behavior
- Update the [public documentation](https://docs.datadoghq.com/tracing/trace_collection/library_config/java/) in case of new configuration flag or behavior

Jira ticket: [PROJ-IDENT]

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/analyze-changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
# The branches below must be a subset of the branches above
branches: [ master ]

# Cancel long-running jobs when a new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
datadog-static-analyzer:
name: Analyze changes with DataDog Static Analyzer
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/check-pull-requests.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Check pull requests
on:
pull_request:
types: [opened, edited, labeled, unlabeled]
types: [opened, edited, ready_for_review, labeled, unlabeled]
branches:
- master
- release/v*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
check_pull_requests:
name: Check pull requests
Expand Down Expand Up @@ -38,14 +40,22 @@ jobs:
if (titleCheckFailed) {
core.setFailed('Please remove the tag from the pull request title.')
}
// Check body does
const linkingKeywords = ['closes', 'closed', 'fix', 'fixes', 'fixed', 'resolve', 'resolves', 'resolved']
const body = context.payload.pull_request.body
const bodyCheckFailed = linkingKeywords.some(keyword => body.search(new RegExp(`${keyword}\\s\\d+`, "im")) !== -1)
if (bodyCheckFailed) {
core.setFailed('Please remove the issue linking keyword from the pull request body.')
}
// Add comment to the pull request
if (labelsCheckFailed || titleCheckFailed) {
if (labelsCheckFailed || titleCheckFailed || bodyCheckFailed) {
// Define comment body
const commentMarker = '<!-- dd-trace-java-check-pull-requests-workflow -->'
const commentBody = 'Hi! 👋 Thanks for your pull request! 🎉\n\n' +
'To help us review it, please make sure to:\n\n' +
(labelsCheckFailed ? '* Add at least one type, and one component or instrumentation label to the pull request\n' : '') +
(titleCheckFailed ? '* Remove the tag from the pull request title\n' : '') +
(bodyCheckFailed ? '* Remove the issue linking keyword\n' : '') +
'\nIf you need help, please check our [contributing guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md).' +
'\n\n' + commentMarker
// Look for previous comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"number": 7884,
"draft": true,
"labels": [],
"title": "Adding some new features"
"title": "Adding some new features",
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"name": "type: bug"
}
],
"title": "Adding some new features"
"title": "Adding some new features",
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"pull_request": {
"number": 7884,
"draft": false,
"labels": [
{
"name": "comp: api"
},
{
"name": "type: enhancement"
}
],
"title": "Adding some new features",
"body": "# What Does This Do\n\nThis PR introduces a workflow to check that PRs labels and title match the contributing guidelines.\nIt fixes #1234 amoung other issues."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"name": "comp: api"
}
],
"title": "Adding some new features"
"title": "Adding some new features",
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"name": "tag: no release notes"
}
],
"title": "Adding some new features"
"title": "Adding some new features",
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"name": "type: enhancement"
}
],
"title": "[API] Adding some new features"
"title": "[API] Adding some new features",
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"name": "type: enhancement"
}
],
"title": "Adding some new features"
"title": "Adding some new features",
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ testworkflow pull_request instrumentation && \
testworkflow pull_request draft && \
testworkflow pull_request no-release-notes && \
! testworkflow pull_request missing-label && \
! testworkflow pull_request title-tag
! testworkflow pull_request title-tag && \
! testworkflow pull_request linking-issue
2 changes: 2 additions & 0 deletions .github/workflows/update-download-releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
types:
- released
workflow_dispatch:
concurrency: # Avoid running multiple instances to prevent asset conflicts
group: ${{ github.workflow }}
jobs:
update-releases:
permissions:
Expand Down
5 changes: 3 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ onboarding_tests_installer:
SCENARIO: [ SIMPLE_INSTALLER_AUTO_INJECTION, SIMPLE_AUTO_INJECTION_PROFILING ]

onboarding_tests_k8s_injection:
variables:
WEBLOG_VARIANT: dd-lib-java-init-test-app
parallel:
matrix:
- WEBLOG_VARIANT: [dd-lib-java-init-test-app]

create_key:
stage: generate-signing-key
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ dependencies {
implementation("org.apache.maven", "maven-aether-provider", "3.3.9")

implementation("com.google.guava", "guava", "20.0")
implementation("org.ow2.asm", "asm", "9.7")
implementation("org.ow2.asm", "asm-tree", "9.7")
implementation("org.ow2.asm", "asm", "9.7.1")
implementation("org.ow2.asm", "asm-tree", "9.7.1")

testImplementation("org.spockframework", "spock-core", "2.2-groovy-3.0")
testImplementation("org.codehaus.groovy", "groovy-all", "3.0.17")
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/call-site-instrumentation-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ dependencies {
compileOnly("com.google.code.findbugs", "jsr305", "3.0.2")

implementation("org.freemarker", "freemarker", "2.3.30")
implementation("org.ow2.asm", "asm", "9.7")
implementation("org.ow2.asm", "asm-tree", "9.7")
implementation("org.ow2.asm", "asm", "9.7.1")
implementation("org.ow2.asm", "asm-tree", "9.7.1")
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")

testImplementation("net.bytebuddy", "byte-buddy", "1.14.18")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,20 @@ public AfterSpecification(

@Override
protected void validateAdvice(@Nonnull final ValidationContext context) {
if (advice.isVoidReturn()) {
context.addError(ErrorCode.ADVICE_AFTER_SHOULD_NOT_RETURN_VOID);
}
if (findReturn() == null) {
context.addError(ErrorCode.ADVICE_AFTER_SHOULD_HAVE_RETURN);
if (shouldNotUseReturn(pointcut)) {
if (!advice.isVoidReturn()) {
context.addError(ErrorCode.ADVICE_AFTER_VOID_METHOD_SHOULD_RETURN_VOID);
}
if (findReturn() != null) {
context.addError(ErrorCode.ADVICE_AFTER_VOID_METHOD_SHOULD_NOT_HAVE_RETURN);
}
} else {
if (advice.isVoidReturn()) {
context.addError(ErrorCode.ADVICE_AFTER_SHOULD_NOT_RETURN_VOID);
}
if (findReturn() == null) {
context.addError(ErrorCode.ADVICE_AFTER_SHOULD_HAVE_RETURN);
}
}
if (!pointcut.isConstructor()) {
if (!isStaticPointcut() && !includeThis()) {
Expand All @@ -588,6 +597,10 @@ protected void validateAdvice(@Nonnull final ValidationContext context) {
super.validateAdvice(context);
}

private boolean shouldNotUseReturn(final MethodType type) {
return !type.isConstructor() && type.isVoidReturn();
}

@Override
public String toString() {
return "@CallSite.After(" + signature + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,20 @@ public String apply(final Object[] objects) {
}
},

ADVICE_AFTER_VOID_METHOD_SHOULD_RETURN_VOID {
@Override
public String apply(final Object[] objects) {
return "After advice for void method should return void";
}
},

ADVICE_AFTER_VOID_METHOD_SHOULD_NOT_HAVE_RETURN {
@Override
public String apply(final Object[] objects) {
return "After advice for void method should not contain @Return annotated parameters";
}
},

ADVICE_AFTER_SHOULD_HAVE_RETURN {
@Override
public String apply(final Object[] objects) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,36 @@ final class AdviceGeneratorTest extends BaseCsiPluginTest {
}
}


@CallSite(spi = CallSites)
class AfterAdviceWithVoidReturn {
@CallSite.After("void java.lang.StringBuilder.setLength(int)")
static void after(@CallSite.This StringBuilder self, @CallSite.Argument(0) int length) {
}
}

void 'test after advice with void return'() {
setup:
final spec = buildClassSpecification(AfterAdviceWithVoidReturn)
final generator = buildAdviceGenerator(buildDir)

when:
final result = generator.generate(spec)

then:
assertNoErrors result
assertCallSites(result.file) {
advices(0) {
pointcut('java/lang/StringBuilder', 'setLength', '(I)V')
statements(
'handler.dupInvoke(owner, descriptor, StackDupMode.COPY);',
'handler.method(opcode, owner, name, descriptor, isInterface);',
'handler.advice("datadog/trace/plugin/csi/impl/AdviceGeneratorTest$AfterAdviceWithVoidReturn", "after", "(Ljava/lang/StringBuilder;I)V");',
)
}
}
}

private static AdviceGenerator buildAdviceGenerator(final File targetFolder) {
return new AdviceGeneratorImpl(targetFolder, pointcutParser())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,26 @@ class AdviceSpecificationTest extends BaseCsiPluginTest {
then:
0 * context.addError(_, _)
}


@CallSite(spi = CallSites)
class AfterWithVoidWrongAdvice {
@CallSite.After("void java.lang.String.getChars(int, int, char[], int)")
static String after(@CallSite.AllArguments final Object[] args, @CallSite.Return final String result) {
return result;
}
}

void 'test after advice with void should not use @Return'() {
setup:
final context = mockValidationContext()
final spec = buildClassSpecification(AfterWithVoidWrongAdvice)

when:
spec.advices.each { it.validate(context) }

then:
1 * context.addError(ErrorCode.ADVICE_AFTER_VOID_METHOD_SHOULD_RETURN_VOID, _)
1 * context.addError(ErrorCode.ADVICE_AFTER_VOID_METHOD_SHOULD_NOT_HAVE_RETURN, _)
}
}
2 changes: 1 addition & 1 deletion communication/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
}

ext {
minimumBranchCoverage = 0.6
minimumBranchCoverage = 0.5
minimumInstructionCoverage = 0.8
excludedClassesCoverage = [
'datadog.communication.ddagent.ExternalAgentLauncher',
Expand Down
2 changes: 1 addition & 1 deletion communication/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ com.beust:jcommander:1.78=testRuntimeClasspath
com.datadoghq.okhttp3:okhttp:3.12.15=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq.okio:okio:1.17.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq:dd-javac-plugin-client:0.2.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq:java-dogstatsd-client:4.4.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq:java-dogstatsd-client:4.4.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.fasterxml.jackson.core:jackson-annotations:2.9.0=testCompileClasspath,testRuntimeClasspath
com.fasterxml.jackson.core:jackson-core:2.9.9=testCompileClasspath,testRuntimeClasspath
com.fasterxml.jackson.core:jackson-databind:2.9.9.3=testCompileClasspath,testRuntimeClasspath
Expand Down
Loading

0 comments on commit d566c95

Please sign in to comment.