Skip to content

Commit

Permalink
[APM] Use total duration for calculating impact
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Feb 2, 2021
1 parent 97acbf5 commit 506ed30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,26 @@ export async function getServiceDependencies({
});

const latencySums = metricsByResolvedAddress
.map((metrics) => metrics.latency.value)
.map(
(metric) => (metric.latency.value ?? 0) * (metric.throughput.value ?? 0)
)
.filter(isFiniteNumber);

const minLatencySum = Math.min(...latencySums);
const maxLatencySum = Math.max(...latencySums);

return metricsByResolvedAddress.map((metric) => ({
...metric,
impact:
metric.latency.value === null
? 0
: ((metric.latency.value - minLatencySum) /
return metricsByResolvedAddress.map((metric) => {
const impact =
isFiniteNumber(metric.latency.value) &&
isFiniteNumber(metric.throughput.value)
? ((metric.latency.value * metric.throughput.value - minLatencySum) /
(maxLatencySum - minLatencySum)) *
100,
}));
100
: 0;

return {
...metric,
impact,
};
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
"errorRate": Object {
"value": 0,
},
"impact": 0,
"impact": 1.97910470896139,
"latency": Object {
"value": 1043.99015586546,
},
Expand Down Expand Up @@ -444,13 +444,13 @@ export default function ApiTest({ getService }: FtrProviderContext) {
expectSnapshot(impactValues).toMatchInline(`
Array [
Object {
"impact": 5.4753760019723,
"impact": 1.36961744704522,
"latency": 2568.40816326531,
"name": "elasticsearch",
"throughput": 13.0666666666667,
},
Object {
"impact": 88.1778158446408,
"impact": 0,
"latency": 25593.875,
"name": "opbeans-java",
"throughput": 0.533333333333333,
Expand All @@ -462,7 +462,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
"throughput": 50.8,
},
Object {
"impact": 0,
"impact": 1.97910470896139,
"latency": 1043.99015586546,
"name": "redis",
"throughput": 40.6333333333333,
Expand Down

0 comments on commit 506ed30

Please sign in to comment.