Skip to content

Commit bf5af32

Browse files
authored
Merge branch 'master' into kr-igor/dsm-service-name-override
2 parents aa7341b + 24ccbaa commit bf5af32

File tree

586 files changed

+4718
-3142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

586 files changed

+4718
-3142
lines changed

.circleci/config.continue.yml.j2

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation
3636
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"
3737
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"
3838

39-
default_system_tests_commit: &default_system_tests_commit c87bd359aad64a29f280fc5c70a879f7c7f4846e
39+
default_system_tests_commit: &default_system_tests_commit 53d9b2c43876a39e5c0426f4df4dd5fd79d062e8
4040

4141
parameters:
4242
nightly:
@@ -971,19 +971,20 @@ jobs:
971971
cd system-tests
972972
set +e
973973
RUN_ATTEMPTS=1
974-
while [ $RUN_ATTEMPTS -le 3 ]; do
974+
MAX_ATTEMPTS=1 # Disable retries as the runner is supposed to be stable. Revert to 3 if needed.
975+
while [ $RUN_ATTEMPTS -le $MAX_ATTEMPTS ]; do
975976
echo "Running parametric test attempt $RUN_ATTEMPTS"
976-
timeout 20m ./run.sh PARAMETRIC -L java --log-cli-level=DEBUG --durations=30 -vv
977+
timeout 20m ./run.sh PARAMETRIC --library java --durations=30 -vv
977978
status=$?
978-
#timneout returns 124 if it times out
979-
#if the return code is not 124, then we exit with the status
979+
# timeout returns 124 if it times out
980+
# if the return code is not 124, then we exit with the status
980981
if [ $status -ne 124 ]; then
981982
exit $status
982983
break
983984
fi
984985
RUN_ATTEMPTS=$((RUN_ATTEMPTS+1))
985-
if [ $RUN_ATTEMPTS -eq 4 ]; then
986-
#Max attempts reached, exit with 124
986+
if [ $RUN_ATTEMPTS -gt $MAX_ATTEMPTS ]; then
987+
# Max attempts reached, exit with 124
987988
exit 124
988989
fi
989990
done
@@ -994,9 +995,11 @@ jobs:
994995
- run:
995996
name: Collect artifacts
996997
command: tar -cvzf logs_java_parametric_dev.tar.gz -C system-tests logs_parametric
998+
when: always
997999
9981000
- store_artifacts:
9991001
path: logs_java_parametric_dev.tar.gz
1002+
when: always
10001003
10011004
10021005
build_test_jobs: &build_test_jobs

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Bug Report
4+
url: https://help.datadoghq.com/hc/en-us/requests/new?tf_1260824651490=pt_product_type:apm&tf_1900004146284=pt_apm_language:java
5+
about: This option creates an expedited Bug Report via the helpdesk (no login required). This will allow us to look up your account and allows you to provide additional information in private.
6+
- name: Feature Request
7+
url: https://help.datadoghq.com/hc/en-us/requests/new?tf_1260824651490=pt_product_type:apm&tf_1900004146284=pt_apm_language:java&tf_1260825272270=pt_apm_category_feature_request
8+
about: This option creates an expedited Feature Request via the helpdesk (no login required). This helps with prioritization and allows you to provide additional information in private.

.github/workflows/analyze-changes.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ jobs:
132132
ls -laR "./workspace/.trivy"
133133
134134
- name: Run Trivy security scanner
135-
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # v0.24.0
135+
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # v0.28.0
136136
with:
137137
scan-type: rootfs
138138
scan-ref: './workspace/.trivy/'

.github/workflows/update-gradle-dependencies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ jobs:
7777
--base master \
7878
--head $BRANCH_NAME \
7979
--label "tag: dependencies" \
80-
--label "tag: no release notes"
80+
--label "tag: no release notes" \
8181
--body-file -

BUILDING.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Requirements to build the full project:
5454
`brew install --cask zulu@8 zulu@11 zulu@17 zulu@21 graalvm/tap/graalvm-ce-java17`
5555
* Fix the GraalVM installation by [removing the quarantine flag](https://www.graalvm.org/latest/docs/getting-started/macos/).
5656
`sudo xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-<current version of graalvm>`
57-
* Add the required environment variables to your shell using the `export` command.
57+
* Add the required environment variables to your shell using the `export` command. You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `.bashrc` or other.
5858
```shell
5959
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
6060
export JAVA_11_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
@@ -63,6 +63,7 @@ export JAVA_21_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home
6363
export JAVA_GRAALVM17_HOME=/Library/Java/JavaVirtualMachines/graalvm-<current version of graalvm>/Contents/Home
6464
export JAVA_HOME=$JAVA_8_HOME
6565
```
66+
* Restart your shell after applying the changes if you appended the commands to your shell configuration file.
6667

6768
> [!NOTE]
6869
> ARM users: there is no Oracle JDK v8 for ARM.
@@ -72,15 +73,11 @@ export JAVA_HOME=$JAVA_8_HOME
7273
> [!NOTE]
7374
> MacOS users: remember that `/usr/libexec/java_home` may control which JDK is in your path.
7475
75-
> [!NOTE]
76-
> You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `.bashrc` or other.
77-
> You will need to restart your shell after applying the changes.
78-
7976
**On Linux:**
8077

8178
* Download and extract JDK 8, 11, 17 and 21 from [Eclipse Temurin releases](https://adoptium.net/temurin/releases/) and GraalVM from [Oracle downloads](https://www.graalvm.org/downloads/).
8279
* Install the GraalVM native image requirements for native builds by following [the GraalVM official documentation](https://www.graalvm.org/latest/reference-manual/native-image/#prerequisites).
83-
* Add the required environment variables to your shell using the `export` command.
80+
* Add the required environment variables to your shell using the `export` command. You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `~/.bashrc` or other.
8481
```shell
8582
export JAVA_8_HOME=/<path to extracted archive>/jdk8u<current version of JDK 8>
8683
export JAVA_11_HOME=/<path to extracted archive>/jdk-11.<current version of JDK 11>
@@ -89,10 +86,7 @@ export JAVA_21_HOME=/<path to extracted archive>/jdk-21.<current version of JDK
8986
export JAVA_GRAALVM17_HOME=/<path to extracted archive>/graalvm-jdk-17.<current version of graalvm>/Contents/Home
9087
export JAVA_HOME=$JAVA_8_HOME
9188
```
92-
93-
> [!NOTE]
94-
> You can permanently install the environment variables by appending the `export` commands into your shell configuration file `~/.zshrc` or `.bashrc` or other.
95-
> You will need to restart your shell after applying the changes.
89+
* Restart your shell after applying the changes if you appended the commands to your shell configuration file.
9690

9791
**On Windows:**
9892

CONTRIBUTING.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Pull requests for bug fixes are welcome, but before submitting new features or changes to current
66
functionality, please [open an issue](https://github.com/DataDog/dd-trace-java/issues/new)
7-
and discuss your ideas or propose the changes you wish to make first. After a resolution is reached a [PR can be
7+
and discuss your ideas or propose the changes you wish to make first. After a resolution is reached, a [PR can be
88
submitted](#pull-request-guidelines) for review.
99

1010
## Adding instrumentations
@@ -18,7 +18,7 @@ Check [How Instrumentations Work](docs/how_instrumentations_work.md) for a deep
1818
### Development environment quick check
1919

2020
Prior to contributing to the project, you can quickly check your development environment using the `./setup.sh` command
21-
line, and fix any issue found using the [Building documentation](BUILDING.md).
21+
line and fix any issue found using the [Building documentation](BUILDING.md).
2222

2323
### Automatic code formatting
2424

@@ -27,73 +27,73 @@ This file is supported by most common text editors.
2727

2828
We have automatic code formatting enabled in Gradle configuration using [Spotless](https://github.com/diffplug/spotless)
2929
[Gradle plugin](https://github.com/diffplug/spotless/tree/master/plugin-gradle).
30-
Main goal is to avoid extensive reformatting caused by different IDEs having different opinion about how things should
31-
be formatted by establishing single _point of truth_.
30+
Our main goal is to avoid extensive reformatting caused by different IDEs with different opinions about how things should
31+
be formatted by establishing a single _point of truth_.
3232

3333
To reformat all the files that need reformatting:
3434

3535
```bash
3636
./gradlew spotlessApply
3737
```
3838

39-
To run formatting verify task only:
39+
To run the formatting verify task only:
4040

4141
```bash
4242
./gradlew spotlessCheck
4343
```
4444

4545
#### IntelliJ IDEA
4646

47-
For IntelliJ IDEA, we suggest the following settings and plugin:
47+
For IntelliJ IDEA, we suggest the following settings and plugin.
4848

49-
In contrast to the [IntelliJ IDEA set up](CONTRIBUTING.md#intellij-idea) the default JVM to build and run tests from the
50-
command line should be Java 8.
49+
The default JVM to build and run tests from the command line should be Java 8.
5150

52-
* Use Java 8 to build and run tests:
53-
`Project Structure` > `Project` > `SDK` > Use a JDK 1.8
54-
* Configure import formatting:
55-
`Editor` > `Code Style` > `Java/Groovy` > `Imports`
51+
* Use Java 8 to build and run tests:
52+
* `Project Structure` -> `Project` -> `SDK` -> `Download JDK...` -> `Version: 1.8` -> `Download`
53+
* Configure Java and Groovy import formatting:
54+
* `Settings...` ->`Editor` > `Code Style` > `Java` > `Imports`
5655
* `Class count to use import with '*'`: `9999` (some number sufficiently large that is unlikely to matter)
5756
* `Names count to use static import with '*'`: `9999`
58-
* With java use the following import layout (groovy should still use the default) to ensure consistency with
59-
google-java-format:
57+
* Use the following import layout to ensure consistency with google-java-format:
6058
![import layout](https://user-images.githubusercontent.com/734411/43430811-28442636-94ae-11e8-86f1-f270ddcba023.png)
61-
* [Google Java Format](https://plugins.jetbrains.com/plugin/8527-google-java-format) plugin
59+
* top right Settings icon -> `Settings...` ->`Editor` > `Code Style` > `Groovy` > `Imports`
60+
* `Class count to use import with '*'`: `9999` (some number sufficiently large that is unlikely to matter)
61+
* `Names count to use static import with '*'`: `9999`
62+
* Install the [Google Java Format](https://plugins.jetbrains.com/plugin/8527-google-java-format) plugin
6263

6364
### Troubleshooting
6465

6566
* Gradle fails with a "too many open files" error.
66-
* You can check the `ulimit` for open files in your current shell by doing `ulimit -n` and raise it by
67-
calling `ulimit -n <new number>`
67+
* You can check the `ulimit` for open files in your current shell by running `ulimit -n`.
68+
* You can raise the `ulimit` by running `ulimit -n <new number>`
6869

6970
<details>
70-
<summary>More past issues</summary>
71+
<summary>Past issues</summary>
7172

7273
* When Gradle is building the project, the
7374
error `Could not find netty-transport-native-epoll-4.1.43.Final-linux-x86_64.jar` is shown.
74-
* Execute `rm -rf ~/.m2/repository/io/netty/netty-transport*` in a Terminal and re-build again.
75+
* Execute `rm -rf ~/.m2/repository/io/netty/netty-transport*` in a Terminal and re-build.
7576

7677
* IntelliJ 2021.3
77-
complains `Failed to find KotlinGradleProjectData for GradleSourceSetData` https://youtrack.jetbrains.com/issue/KTIJ-20173
78-
* Switch to `IntelliJ IDEA CE 2021.2.3`
79-
80-
* IntelliJ Gradle fails to import the project with `JAVA_11_HOME must be set to build Java 11 code`
81-
* A workaround is to run IntelliJ from terminal with `JAVA_11_HOME`
82-
* In order to verify what's visible from IntelliJ use `Add Configuration` bar and go
83-
to `Add New` -> `Gradle` -> `Environmental Variables`
78+
complains `Failed to find KotlinGradleProjectData for GradleSourceSetData` https://youtrack.jetbrains.com/issue/KTIJ-20173.
79+
* Switch to `IntelliJ IDEA CE 2021.2.3`.
8480

81+
* IntelliJ Gradle fails to import the project with `JAVA_11_HOME must be set to build Java 11 code`.
82+
* A workaround is to run IntelliJ from your terminal with `JAVA_11_HOME`.
83+
* In order to verify what's visible from IntelliJ, use the `Add Configuration` bar and go
84+
to `Add New` -> `Gradle` -> `Environmental Variables`.
8585
</details>
8686

87-
## Pull Request Guidelines
87+
## Pull request guidelines
8888

8989
### Draft first
9090

91-
When opening a pull request, please open it as a [draft](https://github.blog/2019-02-14-introducing-draft-pull-requests/) to not auto assign reviewers before you feel the pull request is in a reviewable state.
91+
When opening a pull request, please open it as a [draft](https://github.blog/2019-02-14-introducing-draft-pull-requests/) to not auto-assign reviewers before the pull request is in a reviewable state.
9292

93-
### Title Format
93+
### Title format
9494

9595
Pull request titles should briefly describe the proposed changes in a way that makes sense for the users.
96-
They should be a sentence starting with an infinitive verb, and avoid using prefixes like `[PROD]` or `PROD - ` in favor of [labels](#labels).
96+
They should be a sentence starting with an infinitive verb and avoid using prefixes like `[PROD]` or `PROD - ` in favor of [labels](#labels).
9797

9898
>[!CAUTION]
9999
> Don't title:
@@ -119,7 +119,7 @@ Both pull requests and issues should be labelled with at least a component or an
119119
>[!TIP]
120120
> Always add a `comp:` or `inst:` label, and a `type:` label.
121121
122-
Labels are not only used to categorize but also alter the continuous integration behavior:
122+
Labels are used to not only categorize but also alter the continuous integration behavior:
123123

124124
* `tag: no release note` to exclude a pull request from the next release changelog. Use it when changes are not relevant to the users like:
125125
* Internal features changes
@@ -133,16 +133,16 @@ Labels are not only used to categorize but also alter the continuous integration
133133
> For reference, the [full list of all labels available](https://github.com/DataDog/dd-trace-java/labels).
134134
> If you feel one is missing, let [the maintainer team](https://github.com/orgs/DataDog/teams/apm-java) know!
135135
136-
## Pull Request Reviews
136+
## Pull request reviews
137137

138-
### Review Expectations
138+
### Review expectations
139139

140-
After making you pull request ready for review by converting it from draft, you can expect getting an initial review comment within two working days, and a full review within a week of work.
140+
After making your pull request ready for review by converting it from a draft, you can expect to get an initial review comment within two working days and a full review within a week of work.
141141
If you don't receive any update, feel free to send a nice reminder to the assigned reviewers using pull request comments or our internal Slack channel.
142142

143-
### Stale Pull Requests
143+
### Stale pull requests
144144

145145
A pull request is considered "stale" if it has had no activity (comments, updates) for the last quarter.
146-
Stale PRs will be commented and labelled as such (using the `tag: stale` label), then closed if they still receive no update for a week after.
146+
Stale PRs will be commented and labeled as such (using the `tag: stale` label), and then closed if they receive no update after a week.
147147

148-
Closed PRs can be reopened at any time, but may be closed again if they ever meet the same stale conditions.
148+
Closed PRs can be reopened at any time, but they may be closed again if they meet the same stale conditions.

communication/gradle.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ org.apache.httpcomponents.core5:httpcore5-h2:5.1.3=spotbugs
7373
org.apache.httpcomponents.core5:httpcore5:5.1.3=spotbugs
7474
org.apache.logging.log4j:log4j-api:2.19.0=spotbugs
7575
org.apache.logging.log4j:log4j-core:2.19.0=spotbugs
76-
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testRuntimeClasspath
76+
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
7777
org.checkerframework:checker-compat-qual:2.5.5=testCompileClasspath,testRuntimeClasspath
7878
org.checkerframework:checker-qual:3.13.0=testCompileClasspath,testRuntimeClasspath
7979
org.codehaus.groovy:groovy-all:3.0.17=testCompileClasspath,testRuntimeClasspath

communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import datadog.communication.monitor.Recording;
1010
import datadog.trace.api.telemetry.LogCollector;
1111
import datadog.trace.util.Strings;
12-
import java.io.IOException;
1312
import java.nio.ByteBuffer;
1413
import java.security.NoSuchAlgorithmException;
1514
import java.util.Collections;
@@ -200,7 +199,7 @@ private String probeTracesEndpoint(String[] endpoints) {
200199
state = response.header(DATADOG_AGENT_STATE);
201200
return candidate;
202201
}
203-
} catch (IOException e) {
202+
} catch (Throwable e) {
204203
errorQueryingEndpoint(candidate, e);
205204
}
206205
}
@@ -310,7 +309,7 @@ private static void discoverStatsDPort(final Map<String, Object> info) {
310309
}
311310
int statsdPort = ((Number) statsdPortObj).intValue();
312311
DDAgentStatsDClientManager.setDefaultStatsDPort(statsdPort);
313-
} catch (Exception ex) {
312+
} catch (Throwable ex) {
314313
log.debug("statsd_port missing from trace agent /info response", ex);
315314
}
316315
}

communication/src/main/java/datadog/communication/serialization/Codec.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
package datadog.communication.serialization;
22

3+
import datadog.communication.serialization.custom.stacktrace.StackTraceEventFrameWriter;
4+
import datadog.communication.serialization.custom.stacktrace.StackTraceEventWriter;
5+
import datadog.trace.util.stacktrace.StackTraceEvent;
6+
import datadog.trace.util.stacktrace.StackTraceFrame;
37
import java.nio.ByteBuffer;
48
import java.nio.CharBuffer;
59
import java.util.Collection;
610
import java.util.Collections;
711
import java.util.Map;
12+
import java.util.stream.Collectors;
13+
import java.util.stream.Stream;
814

915
public final class Codec extends ClassValue<ValueWriter<?>> {
1016

11-
public static final Codec INSTANCE = new Codec();
17+
private static final Map<Class<?>, ValueWriter<?>> defaultConfig =
18+
Stream.of(
19+
new Object[][] {
20+
{StackTraceEvent.class, new StackTraceEventWriter()},
21+
{StackTraceFrame.class, new StackTraceEventFrameWriter()},
22+
})
23+
.collect(Collectors.toMap(data -> (Class<?>) data[0], data -> (ValueWriter<?>) data[1]));
24+
25+
public static final Codec INSTANCE = new Codec(defaultConfig);
1226

1327
private final Map<Class<?>, ValueWriter<?>> config;
1428

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package datadog.communication.serialization.custom.stacktrace;
2+
3+
import datadog.communication.serialization.EncodingCache;
4+
import datadog.communication.serialization.ValueWriter;
5+
import datadog.communication.serialization.Writable;
6+
import datadog.trace.util.Strings;
7+
import datadog.trace.util.stacktrace.StackTraceFrame;
8+
9+
public class StackTraceEventFrameWriter implements ValueWriter<StackTraceFrame> {
10+
11+
@Override
12+
public void write(StackTraceFrame value, Writable writable, EncodingCache encodingCache) {
13+
int mapSize = 1; // id always present
14+
boolean hasText = Strings.isNotBlank(value.getText());
15+
boolean hasFile = Strings.isNotBlank(value.getFile());
16+
boolean hasLine = value.getLine() != null;
17+
boolean hasClass = Strings.isNotBlank(value.getClass_name());
18+
boolean hasFunction = Strings.isNotBlank(value.getFunction());
19+
if (hasText) {
20+
mapSize++;
21+
}
22+
if (hasFile) {
23+
mapSize++;
24+
}
25+
if (hasLine) {
26+
mapSize++;
27+
}
28+
if (hasClass) {
29+
mapSize++;
30+
}
31+
if (hasFunction) {
32+
mapSize++;
33+
}
34+
writable.startMap(mapSize);
35+
writable.writeString("id", encodingCache);
36+
writable.writeInt(value.getId());
37+
if (hasText) {
38+
writable.writeString("text", encodingCache);
39+
writable.writeString(value.getText(), encodingCache);
40+
}
41+
if (hasFile) {
42+
writable.writeString("file", encodingCache);
43+
writable.writeString(value.getFile(), encodingCache);
44+
}
45+
if (hasLine) {
46+
writable.writeString("line", encodingCache);
47+
writable.writeInt(value.getLine());
48+
}
49+
if (hasClass) {
50+
writable.writeString("class_name", encodingCache);
51+
writable.writeString(value.getClass_name(), encodingCache);
52+
}
53+
if (hasFunction) {
54+
writable.writeString("function", encodingCache);
55+
writable.writeString(value.getFunction(), encodingCache);
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)