hanahmily opened a new pull request, #1206:
URL: https://github.com/apache/skywalking-banyandb/pull/1206
## What
Introduce **meter + logging** into native trace-pipeline sampler plugins so
a plugin author can expose internal metrics through BanyanDB's meter system and
emit logs through the standard logging system — while a bounded host-side scope
prevents a plugin from destabilizing the host.
Part of apache/skywalking#13634.
## Design
- **Frozen, SDK-owned façade**
(`sdk.Meter`/`Counter`/`Gauge`/`Histogram`/`Logger`/`Host`/`HostAware`) that
plugins build against. It is stdlib-only and delivered **opt-in** via
`sdk.HostAware.UseHost(host)`; a plugin that doesn't implement `HostAware` gets
no telemetry and pays nothing.
- **Per-group instance for HostAware plugins**: the loader cache is keyed
`(path, symbol, configHash, group)` so each group owns its own instance;
`UseHost` is invoked **once** per instance under the cache lock before
publication (once-only invariant + idempotent reconcile-skip), so there is no
cross-group `Host` clobber and no data race.
- **Host-side bounded adapters** enforce the scope:
- metric names forced under the `banyandb_trace_pipeline_plugin_*` prefix
with `{group, plugin_name}` labels;
- per-plugin **series cap 100**, log **50 lines/s (burst 100)**, **1 KiB**
max message, **16** structured fields, default **INFO** level cap;
- self-observability counters: `plugin_telemetry_series_rejected_total`,
`plugin_log_dropped_total`, `plugin_telemetry_panic_total`;
- never-`Close` (Go plugins can't be unloaded) + `Delete`-based series
reclaim on config change.
- **Zerolog-free SDK**: extracted the byte-sized `ValueType` enum into the
leaf package `pkg/pb/v1/valuetype` and the var-array codec into
`pkg/encoding/vararray`, so the SDK's dependency graph contains **zero**
zerolog/zap/logger/meter (verified by an import-graph test). No ABI bump — the
assertion keys on the method set, not an ABI integer.
## Tests
- Unit + integration tests for the adapters (series cap, log rate/size/field
bounds, level cap, reclaim, once-only `UseHost`, panic isolation).
- **Real `.so` coverage**: a config-parameter plugin (`_telemetrysampler`)
and an adversarial **fault-injection** plugin (`_faultysampler`, exercising
`panicInUseHost` / `floodLogs` / `explodeCardinality`) that assert the host
bounds hold and a misbehaving plugin cannot destabilize the node.
## Verification
- `make lint` clean; `go build ./...` clean; full `banyand/trace/...` suite
green.
- SDK import graph asserted free of zerolog/zap/logger/meter.
Part of apache/skywalking#13634 — this PR does **not** close the issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]