Commit 9c3437a
committed
Add OTEL Java extension demo
**What does this PR do?**
This PR adds a PoC for how process context publishing can be integrated
into an application using the OTEL Java SDK by using the OTEL extension
mechanism.
With the extension built, adding the OTEL process context to an
application can be as simple as:
```
$ java -Dotel.javaagent.extensions=opentelemetry-java-instrumentation-extension-demo-1.0.jar -jar build/libs/dice-application.jar
...
Published OTEL_CTX
2025-10-28T16:17:41.322Z INFO 'Starting DiceApplication using Java 23.0.1 with PID 398219 (dice-application.jar started by ivo.anjo)' : 00000000000000000000000000000000 0000000000000000 [scopeInfo: otel.DiceApplication:] {}
```
and we can look at it as usual:
```
$ sudo ./otel_process_ctx_dump.sh 398219
Found OTEL context for PID 398219
Start address: 75e620025000
00000000 4f 54 45 4c 5f 43 54 58 02 00 00 00 07 f2 73 e5 |OTEL_CTX......s.|
00000010 86 b5 72 18 59 00 00 00 b0 40 73 1c e6 75 00 00 |..r.Y....@s..u..|
00000020
Parsed struct:
otel_process_ctx_signature : "OTEL_CTX"
otel_process_ctx_version : 2
otel_process_ctx_published_at_ns : 1761669995235111431 (2025-10-28 16:46:35 GMT)
otel_process_payload_size : 89
otel_process_payload : 0x000075e61c7340b0
Payload dump (89 bytes):
00000000 12 00 1a 24 39 66 66 33 63 62 31 64 2d 39 62 33 |...$9ff3cb1d-9b3|
00000010 65 2d 34 31 33 33 2d 62 38 34 32 2d 66 39 61 37 |e-4133-b842-f9a7|
00000020 31 62 37 32 61 39 61 63 22 10 64 69 63 65 2d 61 |1b72a9ac".dice-a|
00000030 70 70 6c 69 63 61 74 69 6f 6e 2a 00 32 04 6a 61 |pplication*.2.ja|
00000040 76 61 3a 06 31 2e 35 35 2e 30 42 0d 6f 70 65 6e |va:.1.55.0B.open|
00000050 74 65 6c 65 6d 65 74 72 79 |telemetry|
00000059
Protobuf decode:
service_instance_id: "9ff3cb1d-9b3e-4133-b842-f9a71b72a9ac"
service_name: "dice-application"
telemetry_sdk_language: "java"
telemetry_sdk_version: "1.55.0"
telemetry_sdk_name: "opentelemetry"
```
**Motivation:**
Trying this out was a nice suggestion we got from the OTEL Java SDK SIG
as a way of showing off how this could fit in an OTEL app.
**Additional Notes:**
N/A
**How to test the change?**
The `README.md` includes instructions on how to build and run the
example.1 parent c73a814 commit 9c3437a
File tree
19 files changed
+1246
-0
lines changed- otel-java-extension-demo
- dice-application
- build/libs
- gradle/wrapper
- otel-process-ctx-extension
- .vscode
- build/libs
- gradle/wrapper
- src/main/java/com/example/javaagent
19 files changed
+1246
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Binary file not shown.
Binary file not shown.
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments