Sending all transactions without filtering and aggregation would create an heavy load on the service. We must carefully balance data completeness with efficient storage and processing to ensure optimal performance monitoring.
Sending every transaction without filtering creates several critical issues:
- Significantly increased server load, particularly during high traffic periods
- Large amounts of redundant data that provide minimal analytical value
- "Infinite loops" in client code may generate endless transactions.
Instead of collecting every transaction, we focus on gathering a representative sample that provides meaningful insights while minimizing data volume.
To ensure we capture important but infrequent transactions:
– Slow transactions are always sent. Transaction is considered slow if its duration is greater than criticalDurationThresholdMs parameter.
- Errors (
status== 'failure') are always sent.
See Sampling for details.
Throttling + transaction batches → instead of 1000 separate messages, send 1 AggregatedTransaction.
Instead of 1000 transactions, send one with count = 1000 and average metrics.
- Store P50, P95, P100 (percentiles).
- Save min(startTime) and max(endTime) to see the interval boundaries and calculate Transactions Per Minute.
What do we lose ?
- The detail of each specific transaction.
- Exact startTime and endTime for each transaction.
What do we gain?
- A sharp reduction in load on the Collector and DB (10-100 times fewer records).
- All necessary metrics (P50, P95, P100, avg) remain.
- You can continue to build graphs and calculate metrics, but with less load.
See Transaction Aggregation for details on how transactions are aggregated.
Transactions with duration < thresholdMs will not be sent, as they are not critical.
| Field | Type | Description |
|---|---|---|
| id | string | Unique identifier of the transaction |
| severity | string | Type of transaction sampling ('default' or 'critical'). See Sampling for details |
| name | string | Name of the transaction |
| startTime | number | Timestamp when transaction started |
| endTime | number | Timestamp when transaction ended |
| duration | number | Total duration of transaction in milliseconds |
| status | string | Status when transaction finished. 'success' (default) or 'failure'. See Transaction Completion |
| spans | Span[] | Array of spans associated with this transaction |
| Field | Type | Description |
|---|---|---|
| aggregationId | string | Identifier of the aggregation |
| name | string | Name of the transaction |
| avgStartTime | number | Average timestamp when transaction started |
| minStartTime | number | Minimum timestamp when transaction started |
| maxEndTime | number | Maximum timestamp when transaction ended |
| p50duration | number | 50th percentile (median) duration of transaction in milliseconds |
| p95duration | number | 95th percentile duration of transaction in milliseconds |
| maxDuration | number | Maximum duration of transaction in milliseconds |
| count | number | how many transactions aggregated |
| failureRate | number | percentage of transactions with status 'failure' |
| aggregatedSpans | AggregatedSpan[] | List of spans in transactions |
| Field | Type | Description |
|---|---|---|
| id | string | Unique identifier of the span |
| name | string | Name of the span |
| startTime | number | Timestamp when span started |
| endTime | number | Timestamp when span ended |
| duration | number | Total duration of span in milliseconds |
| status | string | Status when span finished. 'success' (default) or 'failure' |
See Transaction Aggregation for details on how spans are aggregated.
| Field | Type | Description |
|---|---|---|
| aggregationId | string | Unique identifier of the span aggregation |
| name | string | Name of the span |
| minStartTime | number | Minimum timestamp when span started |
| maxEndTime | number | Maximum timestamp when span ended |
| p50duration | number | 50th percentile (median) duration of span in milliseconds |
| p95duration | number | 95th percentile duration of span in milliseconds |
| maxDuration | number | Maximum duration of span in milliseconds |
| failureRate | number | percentage of spans with status 'failure' |
When creating a transaction, you can specify its type:
- 'critical' - important transactions that are always sent to the server
- 'default' - regular transactions that go through the sampling process
When completing a transaction:
-
A finish status is specified (
status):- 'success' (default) - successful completion
- 'failure' - completion with error (such transactions are always sent to the server)
-
The transaction duration is checked:
- If
thresholdMsparameter is specified and the transaction duration is less than this value, the transaction is discarded - Default
thresholdMsis 20ms status"failure" has a priority overthresholdMs- Otherwise, the transaction goes through the sampling process
- If
-
After successful sampling, the transaction is added to the list for sending
- When the first transaction is added to the list, a timer starts
- When the timer expires:
- All collected transactions are aggregated
- Aggregated data is sent to the server
- The transaction list is cleared
- The probability of sending transactions is configured through the
performance.sampleRateparameter (value from 0 to 1) - Only transactions of type 'default' with finish status 'success' are subject to sampling
- Sampling process:
- A random number between 0 and 1 is generated for each transaction
- If the number is less than or equal to sampleRate, the transaction is sent
-
Transactions are grouped by name (name field)
-
For each group, statistical indicators are calculated:
- minStartTime - earliest start time
- maxEndTime - latest end time
- p50duration - median duration (50th percentile)
- p95duration - 95th percentile duration
- maxDuration - maximum duration
-
Based on this data, AggregatedTransaction objects are created
-
For each aggregated transaction:
- Spans are grouped by name
- Their own statistical indicators (see AggregatedSpan) are calculated for each span group
- AggregatedSpan objects are created