feat: cmk Linux agent data emitted from metrics-cache - #32
Conversation
| pub metrics: MetricTables, | ||
| pub indexes: Indexes, | ||
| pub self_health: SelfHealth, | ||
| pub system_agent_snapshot: HashMap<String, Bytes>, |
There was a problem hiding this comment.
I'd store the actual arced MetricsFetcherIngestion here, for a few reasons:
- The main reason for
MetricsFetcherIngestionas an abstraction at all is so we can store some metadata (namely the ingestion timestamp) alongside it and ideally eventually emit that in the self-health sections in the future. But if we only store the Bytes we lose that. - We arc the
MetricsFetcherIngestionso we can easily clone it as a whole, so we might as well use that. Yesaxum::body::Bytesis reference counted and can be cloned cheaply too, but it doesn't really buy us anything and see (1) 😅
| }) | ||
| } | ||
|
|
||
| pub fn from_raw(piggyback_hostname: String, raw: Bytes) -> Self { |
There was a problem hiding this comment.
I'd match of() here e.g. take &str in the first arg and probably rename to just raw().
| @@ -1,3 +1,4 @@ | |||
| use axum::body::Bytes; | |||
There was a problem hiding this comment.
I think it's fine to use Bytes here, but let's use bytes::Bytes directly instead of Axum's re-export of it. (We can add the direct dependency on bytes if it's not there yet).
There was a problem hiding this comment.
The String::from_utf8_lossy() on 22 is incompatible with the Bytes we store now (we could potentially change the agent output there by altering non-utf8-compliant bytes which would be non-ideal).
I'd probably change the handler to return Bytes instead of String and change the last line to Ok(out.into()).
(A test here would be nice but is probably a bit difficult to set up, so you can ignore it for now)
CMK-36614