Skip to content

Commit ec19ab7

Browse files
authored
Merge pull request #7 from tinythings/isbm-sharedlib
Add logjet export as a sharedlib
2 parents b3d1098 + d4e5543 commit ec19ab7

16 files changed

Lines changed: 795 additions & 197 deletions

Cargo.lock

Lines changed: 50 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ edition = "2024"
55
license = "Apache-2.0"
66

77
[workspace]
8-
members = [".", "logjetd", "demo", "ljx"]
9-
default-members = [".", "logjetd", "demo", "ljx"]
8+
members = [".", "logjetd", "demo", "ljx", "liblogjet"]
9+
default-members = [".", "logjetd", "demo", "ljx", "liblogjet"]
1010

1111
[profile.release]
1212
lto = true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ fn replay_batches() -> Result<(), Box<dyn std::error::Error>> {
154154
## Notes
155155

156156
- Examples for standalone usage live in [examples](./examples).
157+
- C and C++ shared-library usage lives in [doc/c-cpp-integration.md](./doc/c-cpp-integration.md).
157158
- The reader is sequential by design.
158159
- Compression is per block, not per file.
159160
- The payload bytes are opaque to `logjet`.

demo/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ It also contains scenario demos under subdirectories:
3535
- one replay client stalls while another keeps flowing
3636
- [`replay-handoff`](./replay-handoff)
3737
- a late replay client drains retained backlog and then continues live on the same connection
38+
- [`cpp-shared-lib`](./cpp-shared-lib)
39+
- a C++ process loads `liblogjet.so`, sends OTLP logs into `ljd`, and opens the result in `ljx view`
3840
- [`file-replay`](./file-replay)
3941
- replay stored `.logjet` files into a collector
4042
- [`file-tooling`](./file-tooling)

demo/cpp-shared-lib/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# C++ Shared Library Demo
2+
3+
This demo shows one C++ process loading a Rust shared library and sending OTLP
4+
logs into `ljd` over gRPC.
5+
6+
The path is:
7+
8+
`C++ appliance -> liblogjet.so -> OTLP/gRPC -> ljd -> .logjet file -> ljx view`
9+
10+
## Build First
11+
12+
From the project root:
13+
14+
```bash
15+
cargo build -p ljd -p ljx -p liblogjet
16+
```
17+
18+
You also need `g++` available locally because the demo compiles the C++
19+
example on demand.
20+
21+
## Run
22+
23+
From this directory:
24+
25+
```bash
26+
./run-demo.sh
27+
```
28+
29+
## What It Does
30+
31+
The script:
32+
33+
1. builds the example C++ logger
34+
2. starts file-backed `ljd` on `127.0.0.1:4317`
35+
3. loads `liblogjet.so` through `dlopen`
36+
4. sends 25 OTLP log records from C++ by default
37+
5. opens `ljx view` on the resulting `./logs/cpp-demo.logjet`
38+
39+
## Notes
40+
41+
- the library now supports both OTLP/HTTP and OTLP/gRPC constructors
42+
- this demo specifically uses OTLP/gRPC
43+
- the FFI API is intentionally small: endpoint, service name, timestamp, severity, message body, and string attributes
44+
- those key/value pairs become OTLP `LogRecord.attributes`, which is the standard OTel metadata field for log records
45+
- if the appliance already has JSON metadata, the better long-term shape is to flatten that JSON into separate attributes where possible; a raw JSON blob can still be sent as one string attribute when needed
46+
- the demo uses a local symlink named `liblogjet.so` that points at Cargo's built shared object

demo/cpp-shared-lib/cpp-logger

35 KB
Binary file not shown.

0 commit comments

Comments
 (0)