Skip to content

Commit

Permalink
Correctly use Map primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannmoinet committed Sep 13, 2023
1 parent 01b8c07 commit baea19a
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/hooks/datadog/metrics/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const getPlugins = (plugins: TimingsMap): Metric[] => {
metrics.push({
metric: 'plugins.count',
type: 'count',
value: Object.keys(plugins).length,
value: plugins.size,
tags: [],
});

Expand Down Expand Up @@ -149,27 +149,26 @@ export const getLoaders = (loaders: TimingsMap): Metric[] => {
metrics.push({
metric: 'loaders.count',
type: 'count',
value: Object.keys(loaders).length,
value: loaders.size,
tags: [],
});

metrics.push(
...flattened(
Object.values(loaders).map((loader) => [
{
metric: 'loaders.duration',
type: 'duration',
value: loader.duration,
tags: [`loaderName:${loader.name}`],
},
{
metric: 'loaders.increment',
type: 'count',
value: loader.increment,
tags: [`loaderName:${loader.name}`],
},
])
)
);
for (const loader of loaders.values()) {
metrics.push(
{
metric: 'loaders.duration',
type: 'duration',
value: loader.duration,
tags: [`loaderName:${loader.name}`],
},
{
metric: 'loaders.increment',
type: 'count',
value: loader.increment,
tags: [`loaderName:${loader.name}`],
}
);
}

return metrics;
};

0 comments on commit baea19a

Please sign in to comment.