Skip to content

model: Anotate models to define transaction metric dimensions #7047

Open
@marclop

Description

@marclop

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.

func (a *Aggregator) makeTransactionAggregationKey(event model.APMEvent, interval time.Duration) transactionAggregationKey {
return transactionAggregationKey{
// Group metrics by time interval.
timestamp: event.Timestamp.Truncate(interval),
traceRoot: event.Parent.ID == "",
transactionName: event.Transaction.Name,
transactionResult: event.Transaction.Result,
transactionType: event.Transaction.Type,
eventOutcome: event.Event.Outcome,
agentName: event.Agent.Name,
serviceEnvironment: event.Service.Environment,
serviceName: event.Service.Name,
serviceVersion: event.Service.Version,
serviceNodeName: event.Service.Node.Name,
hostname: event.Host.Hostname,
containerID: event.Container.ID,
kubernetesPodName: event.Kubernetes.PodName,
cloudProvider: event.Cloud.Provider,
cloudRegion: event.Cloud.Region,
cloudAvailabilityZone: event.Cloud.AvailabilityZone,
}
}

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions