elastic / elastic/apm-server

model: Anotate models to define transaction metric dimensions

Open
#7,047 0 comments 0 reactions 0 assignees View on GitHub
enhancement technical debt
Dominant language
Go
Stars
1.3k
Forks
543
Avg merge
1d 18h
Merged PRs (30d)
109

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.

https://github.com/elastic/apm-server/blob/875f8831c6c8908f7ca9a165ee240f6835582111/x-pack/apm-server/aggregation/txmetrics/aggregator.go#L339-L364

## 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.