You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-15Lines changed: 22 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@ _Based on [async-profiler 2.8.3](https://github.com/jvm-profiling-tools/java-pro
3
3
4
4
## Disclaimer
5
5
This is not a fork of [async-profiler](https://github.com/jvm-profiling-tools/async-profiler). This is a work derived from __async-profiler__ but tailored very specifically for Datadog needs.
6
+
See [gritty details](#gritty-details) for more info.
6
7
If you need a full-fledged Java profiler head back to [async-profiler](https://github.com/jvm-profiling-tools/async-profiler)
7
8
8
9
## Build
@@ -35,6 +36,27 @@ cd java-profiler
35
36
36
37
The resulting artifact will be in `ddprof-lib/build/libs/ddprof-<version>.jar`
37
38
39
+
#### Gritty details
40
+
To smoothen the absorption of the upstream changes, we are using parts of the upstream codebase in (mostly) vanilla form.
41
+
42
+
For this, we have four new gradle tasks in [ddprof-lib/build.gradle](ddprof-lib/build.gradle):
43
+
-`cloneAsyncProfiler` - clones the [DataDog/async-profiler](https://github.com/DataDog/async-profiler) repository into `ddprof-lib/build/async-profiler` using the commit lock specified in [gradle/ap-lock.properties](gradle/ap-lock.properties)
44
+
- in that repository, we are maintainin a branch called `dd/master` where we keep the upstream code in sync with the 'safe' changes from the upstream `master` branch
45
+
- cherry-picks into that branch should be rare and only done for critical fixes that are needed in the project
46
+
- otherwise, we should wait for the next upstream release to avoid conflicts
47
+
-`copyUpstreamFiles` - copies the selected upstream source file into the `ddprof-lib/src/main/cpp-external` directory
48
+
-`patchStackFrame` and `patchStackWalker` - patches the upstream files if it is unavoidable to eg. pass the asan checks
49
+
50
+
Since the upstream code might not be 100% compatible with the current version of the project, we need to provide adapters.
51
+
The adapters are sharing the same file name as the upstream files but are suffixed with `_dd` (e.g. `arch_dd.h`).
52
+
53
+
In case we need to adapt a class from the upstream codebase, we put the adapter class into `ddprof` namespace to avoid
54
+
conflicts with the upstream code. This allows us to use the upstream code as-is while still providing the necessary modifications for our use case.
55
+
56
+
See [ddprof-lib/src/main/cpp/stackWalker_dd.h](ddprof-lib/src/main/cpp/stackWalker_dd.h) for an example of how we adapt the upstream code to fit our needs.
57
+
58
+
An example of this is the `ddprof-lib/src/main/cpp-external/stack_frame.cpp` file which is a modified version of the upstream `stack_frame.cpp` file.
For dd-trace-java you just need to set the `ddprof.jar` project property.
163
185
Eg. you can run the gradle build like this - ./gradlew clean -Pddprof.jar=file://<path-to-artifact.jar> :dd-java-agent:shadowJar` - which will result in a custom `dd-java-agent.jar` build containing your test version of Java profiler.
164
-
165
-
## Working with upstream
166
-
167
-
Although this project still shares the git history with the upstream the code structure is different. This makes it dificult to reliably
168
-
cherry-pick the upstream changes. To make this easier we have a script that will prepare the upstream repository
169
-
and add it as 'cherry' remote to this repository.
170
-
This way you can cherry-pick the changes from the upstream repository with (relative) ease.
171
-
172
-
```bash
173
-
./utils/init_cherrypick_repo.sh # you need to run this only once
174
-
175
-
./utils/cherry.sh <commit>
176
-
# ... resolve conflicts, if any
177
-
./utils/cherry.sh --continue # to commit the resolved conflicts
0 commit comments