Description
Description
As APM Server receives and processes transactions, it continuously aggregates the transactions it receives, collecting a set of metrics for each transaction based on a defined number of dimensions. The "Aggregator" component will flush the in-memory structures and generate duration histogram metricset documents with the dimensions. These documents power certain parts of the APM UI, like the latency distribution graph.
Currently when more dimensions need to be added to the aggregator and metricset document, it's a manual process and entirely separate from the APM Server model definitions. As our model evolves over time, we also need to keep the transaction metricset dimensions updated so that we can query using the newer dimensions.
apm-server/x-pack/apm-server/aggregation/txmetrics/aggregator.go
Lines 339 to 364 in 875f883
Proposed change
It would be ideal if we could generate the transaction metric dimensions automatically from the defined model and have some validation around it.
We could add struct tags to all the model fields and have a generator that validates that all fields define whether or not they're used a transaction metric dimensions. Additionally, this generator would keep the aggregator keys up to date to ensure that we keep both the model and metric models up to date.
Alternatively, we could maintain two sets of lists (one for dimensions the other one for fields that aren't) and use the same rationale as above.
Related issues
Continuation of #6843