swarm-otel: delete a sender-set sender and hive from datapoints and log records
This commit is contained in:
parent
ded017953b
commit
90a1e523fb
2 changed files with 75 additions and 18 deletions
|
|
@ -318,6 +318,13 @@ let
|
|||
# without joining them.
|
||||
authPipeline = "authenticated";
|
||||
authReceivers = map (owner: "otlp/${owner}") (lib.attrNames receiverSockets);
|
||||
# `resource/sender` stamps the resource; `attributes/sender` clears the
|
||||
# same two keys from every datapoint and log record, where a sender can set
|
||||
# them too and the stores keep them as labels and fields.
|
||||
senderProcessors = [
|
||||
"resource/sender"
|
||||
"attributes/sender"
|
||||
];
|
||||
|
||||
upstreamOf = sock: "http://unix:${sock}:/";
|
||||
# Set by nginx on every response from a route, whatever its status, so the
|
||||
|
|
@ -1437,7 +1444,7 @@ in
|
|||
service.pipelines = {
|
||||
"metrics/${authPipeline}" = {
|
||||
receivers = authReceivers;
|
||||
processors = [ "resource/sender" ];
|
||||
processors = senderProcessors;
|
||||
exporters = exporterNames;
|
||||
};
|
||||
}
|
||||
|
|
@ -1463,7 +1470,7 @@ in
|
|||
// lib.optionalAttrs collectLogs {
|
||||
"logs/${authPipeline}" = {
|
||||
receivers = authReceivers;
|
||||
processors = [ "resource/sender" ];
|
||||
processors = senderProcessors;
|
||||
exporters = logExporterNames;
|
||||
};
|
||||
}
|
||||
|
|
@ -1657,6 +1664,21 @@ in
|
|||
action = "upsert";
|
||||
}
|
||||
];
|
||||
# The record level of the same boundary. `resource/sender`
|
||||
# only touches resource attributes, so a `sender` or `hive`
|
||||
# set on a datapoint or a log record would reach the store as
|
||||
# a label or field beside the stamped one. Scope attributes
|
||||
# are out of this processor's reach.
|
||||
"attributes/sender".actions = [
|
||||
{
|
||||
key = "sender";
|
||||
action = "delete";
|
||||
}
|
||||
{
|
||||
key = "hive";
|
||||
action = "delete";
|
||||
}
|
||||
];
|
||||
}
|
||||
# The unauthenticated inputs' stamp: `swarm` and no `sender`,
|
||||
# because nothing authenticated them.
|
||||
|
|
|
|||
|
|
@ -751,10 +751,41 @@ let
|
|||
"logs/authenticated"
|
||||
"metrics/authenticated"
|
||||
]
|
||||
&& lib.all (p: p.processors == [ "resource/sender" ]) (lib.attrValues authed)
|
||||
&& lib.all (p: lib.head p.processors == "resource/sender") (lib.attrValues authed)
|
||||
&& !(anyOtlp unauthed)
|
||||
&& unauthed != { };
|
||||
}
|
||||
{
|
||||
# `resource/sender` only rewrites resource attributes. A `sender` or
|
||||
# `hive` a sender sets on a datapoint or a log record reaches the store
|
||||
# as a label beside the stamped one unless `attributes/sender` deletes
|
||||
# it, so each authenticated pipeline must carry it. The unauthenticated
|
||||
# pipelines are the control: they carry neither processor.
|
||||
# 🔬 Invert-proof: drop `attributes/sender` from either pipeline, or
|
||||
# either delete from the processor.
|
||||
name = "every authenticated pipeline deletes a sender-set sender and hive from datapoints and log records";
|
||||
ok =
|
||||
let
|
||||
s = otelSettings otelTwoHives;
|
||||
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;
|
||||
deleted = map (a: a.key) (
|
||||
lib.filter (a: a.action == "delete") s.processors."attributes/sender".actions
|
||||
);
|
||||
in
|
||||
lib.attrNames authed == [
|
||||
"logs/authenticated"
|
||||
"metrics/authenticated"
|
||||
]
|
||||
&& lib.all (p: lib.elem "attributes/sender" p.processors) (lib.attrValues authed)
|
||||
&& !(lib.any (p: lib.elem "attributes/sender" p.processors) (lib.attrValues unauthed))
|
||||
&&
|
||||
lib.sort lib.lessThan deleted == [
|
||||
"hive"
|
||||
"sender"
|
||||
]
|
||||
&& lib.length s.processors."attributes/sender".actions == 2;
|
||||
}
|
||||
{
|
||||
# The same split as the metrics case above — defining an exporter and
|
||||
# naming it are two lists — plus the half one shared list cannot have:
|
||||
|
|
|
|||
Loading…
Reference in a new issue