swarm-otel: stamp sender from the authenticated client id, not a hive
This commit is contained in:
parent
ab329e5793
commit
22c4d16a20
1 changed files with 243 additions and 233 deletions
|
|
@ -698,14 +698,54 @@ let
|
|||
# config however the mapping is written. The length clause is what
|
||||
# makes the `all` mean anything — over an empty roster it holds
|
||||
# vacuously.
|
||||
name = "the swarm collector routes every hive's logs, not just one";
|
||||
name = "every authenticated receiver, each hive's included, feeds the sender-stamping logs and metrics pipelines";
|
||||
ok =
|
||||
let
|
||||
p = (otelSettings otelTwoHives).service.pipelines;
|
||||
hives = lib.attrNames otelTwoHives.services.hyperhive.swarm.hives;
|
||||
in
|
||||
lib.length hives == 2
|
||||
&& lib.all (h: (p ? "logs/${h}") && p."logs/${h}".receivers == [ "otlp/${h}" ]) hives;
|
||||
&& lib.all (
|
||||
h:
|
||||
lib.elem "otlp/${h}" p."logs/authenticated".receivers
|
||||
&& lib.elem "otlp/${h}" p."metrics/authenticated".receivers
|
||||
) hives
|
||||
&& !(lib.any (h: (p ? "logs/${h}") || (p ? "metrics/${h}")) hives);
|
||||
}
|
||||
{
|
||||
# 🕳️ The stamp is the attribution boundary, so each half is pinned: the
|
||||
# claim it reads, the order that makes a missing claim leave NO sender
|
||||
# (`insert` skips an existing key), and that no `hive` is stamped. The
|
||||
# unauthenticated pipelines are the control — they carry the swarm
|
||||
# stamp and must not carry `sender`, since nothing authenticated them.
|
||||
name = "the sender stamp reads the token's client id, deletes any sender-set value first, and stamps no hive";
|
||||
ok =
|
||||
let
|
||||
s = otelSettings otelTwoHives;
|
||||
attrs = s.processors."resource/sender".attributes;
|
||||
actions = map (a: "${a.action} ${a.key}") attrs;
|
||||
idx = x: lib.lists.findFirstIndex (a: a == x) null actions;
|
||||
insert = lib.findFirst (a: a.action == "insert" && a.key == "sender") null attrs;
|
||||
authed = lib.filterAttrs (_: p: lib.elem "resource/sender" p.processors) s.service.pipelines;
|
||||
unauthed = lib.filterAttrs (_: p: !(lib.elem "resource/sender" p.processors)) s.service.pipelines;
|
||||
anyOtlp = ps: lib.any (p: lib.any (r: lib.hasPrefix "otlp/" r) p.receivers) (lib.attrValues ps);
|
||||
in
|
||||
insert != null
|
||||
&& insert.from_context == "auth.claims.client_id"
|
||||
&& idx "delete sender" != null
|
||||
&& idx "delete sender" < idx "insert sender"
|
||||
&& idx "delete hive" != null
|
||||
&& lib.all (
|
||||
n: !(lib.any (a: a.key == "hive" && a.action != "delete") (s.processors.${n}.attributes or [ ]))
|
||||
) (lib.attrNames s.processors)
|
||||
&&
|
||||
lib.attrNames authed == [
|
||||
"logs/authenticated"
|
||||
"metrics/authenticated"
|
||||
]
|
||||
&& lib.all (p: p.processors == [ "resource/sender" ]) (lib.attrValues authed)
|
||||
&& !(anyOtlp unauthed)
|
||||
&& unauthed != { };
|
||||
}
|
||||
{
|
||||
# The same split as the metrics case above — defining an exporter and
|
||||
|
|
|
|||
Loading…
Reference in a new issue