@datadog/webpack-plugin 0.0.12-dev → 0.0.13-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +48 -47
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +48 -47
- package/dist/src/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/src/index.mjs
CHANGED
|
@@ -3034,6 +3034,48 @@ const getContext = (args) => {
|
|
|
3034
3034
|
value: typeof arg === "string" ? arg : void 0
|
|
3035
3035
|
}));
|
|
3036
3036
|
};
|
|
3037
|
+
const filterTreeMetrics = (metric) => (
|
|
3038
|
+
// Remove tree metrics because way too verbose
|
|
3039
|
+
!/modules\.tree\.(count|size)$/.test(metric.metric) ? metric : null
|
|
3040
|
+
);
|
|
3041
|
+
const filterSourcemapsAndNodeModules = (metric) => metric.tags.some(
|
|
3042
|
+
(tag) => (
|
|
3043
|
+
// Remove sourcemaps.
|
|
3044
|
+
/^assetName:.*\.map$/.test(tag) || // Remove third parties.
|
|
3045
|
+
/^moduleName:\/node_modules/.test(tag)
|
|
3046
|
+
)
|
|
3047
|
+
) ? null : metric;
|
|
3048
|
+
const filterMetricsOnThreshold = (metric) => {
|
|
3049
|
+
const thresholds = {
|
|
3050
|
+
size: 1e5,
|
|
3051
|
+
count: 10,
|
|
3052
|
+
duration: 1e3
|
|
3053
|
+
};
|
|
3054
|
+
if (/(entries|loaders|warnings|errors)\.count$/.test(metric.metric)) {
|
|
3055
|
+
thresholds.count = 0;
|
|
3056
|
+
}
|
|
3057
|
+
if (/(modules\.(dependencies|dependents)$)/.test(metric.metric)) {
|
|
3058
|
+
thresholds.count = 30;
|
|
3059
|
+
}
|
|
3060
|
+
if (/modules\.tree\.count$/.test(metric.metric)) {
|
|
3061
|
+
thresholds.count = 150;
|
|
3062
|
+
}
|
|
3063
|
+
if (/modules\.tree\.size$/.test(metric.metric)) {
|
|
3064
|
+
thresholds.size = 15e5;
|
|
3065
|
+
}
|
|
3066
|
+
if (/entries\.size$/.test(metric.metric)) {
|
|
3067
|
+
thresholds.size = 0;
|
|
3068
|
+
}
|
|
3069
|
+
if (/entries\.modules\.count$/.test(metric.metric)) {
|
|
3070
|
+
thresholds.count = 0;
|
|
3071
|
+
}
|
|
3072
|
+
return metric.value > thresholds[metric.type] ? metric : null;
|
|
3073
|
+
};
|
|
3074
|
+
const defaultTelemetryFilters = [
|
|
3075
|
+
filterTreeMetrics,
|
|
3076
|
+
filterSourcemapsAndNodeModules,
|
|
3077
|
+
filterMetricsOnThreshold
|
|
3078
|
+
];
|
|
3037
3079
|
|
|
3038
3080
|
const outputFiles = async (context, options) => {
|
|
3039
3081
|
const { report, metrics, bundler } = context;
|
|
@@ -5002,48 +5044,6 @@ var templates = (chalk, tmp) => {
|
|
|
5002
5044
|
var chalkExports = chalk$1.exports;
|
|
5003
5045
|
var chalk = /*@__PURE__*/getDefaultExportFromCjs(chalkExports);
|
|
5004
5046
|
|
|
5005
|
-
const filterTreeMetrics = (metric) => (
|
|
5006
|
-
// Remove tree metrics because way too verbose
|
|
5007
|
-
!/modules\.tree\.(count|size)$/.test(metric.metric) ? metric : null
|
|
5008
|
-
);
|
|
5009
|
-
const filterSourcemapsAndNodeModules = (metric) => metric.tags.some(
|
|
5010
|
-
(tag) => (
|
|
5011
|
-
// Remove sourcemaps.
|
|
5012
|
-
/^assetName:.*\.map$/.test(tag) || // Remove third parties.
|
|
5013
|
-
/^moduleName:\/node_modules/.test(tag)
|
|
5014
|
-
)
|
|
5015
|
-
) ? null : metric;
|
|
5016
|
-
const filterMetricsOnThreshold = (metric) => {
|
|
5017
|
-
const thresholds = {
|
|
5018
|
-
size: 1e5,
|
|
5019
|
-
count: 10,
|
|
5020
|
-
duration: 1e3
|
|
5021
|
-
};
|
|
5022
|
-
if (/(entries|loaders|warnings|errors)\.count$/.test(metric.metric)) {
|
|
5023
|
-
thresholds.count = 0;
|
|
5024
|
-
}
|
|
5025
|
-
if (/(modules\.(dependencies|dependents)$)/.test(metric.metric)) {
|
|
5026
|
-
thresholds.count = 30;
|
|
5027
|
-
}
|
|
5028
|
-
if (/modules\.tree\.count$/.test(metric.metric)) {
|
|
5029
|
-
thresholds.count = 150;
|
|
5030
|
-
}
|
|
5031
|
-
if (/modules\.tree\.size$/.test(metric.metric)) {
|
|
5032
|
-
thresholds.size = 15e5;
|
|
5033
|
-
}
|
|
5034
|
-
if (/entries\.size$/.test(metric.metric)) {
|
|
5035
|
-
thresholds.size = 0;
|
|
5036
|
-
}
|
|
5037
|
-
if (/entries\.modules\.count$/.test(metric.metric)) {
|
|
5038
|
-
thresholds.count = 0;
|
|
5039
|
-
}
|
|
5040
|
-
return metric.value > thresholds[metric.type] ? metric : null;
|
|
5041
|
-
};
|
|
5042
|
-
const defaultFilters = [
|
|
5043
|
-
filterTreeMetrics,
|
|
5044
|
-
filterSourcemapsAndNodeModules,
|
|
5045
|
-
filterMetricsOnThreshold
|
|
5046
|
-
];
|
|
5047
5047
|
const getMetric = (metric, opts) => ({
|
|
5048
5048
|
type: "gauge",
|
|
5049
5049
|
tags: [...metric.tags, ...opts.tags],
|
|
@@ -5060,7 +5060,7 @@ const getOptionsDD = (opt) => {
|
|
|
5060
5060
|
tags: options.datadog?.tags || [],
|
|
5061
5061
|
endPoint: options.datadog?.endPoint || "app.datadoghq.com",
|
|
5062
5062
|
prefix: options.datadog?.prefix || "",
|
|
5063
|
-
filters: options.datadog?.filters ||
|
|
5063
|
+
filters: options.datadog?.filters || defaultTelemetryFilters
|
|
5064
5064
|
};
|
|
5065
5065
|
};
|
|
5066
5066
|
|
|
@@ -5599,16 +5599,17 @@ const getMetrics = (opts, report, bundler) => {
|
|
|
5599
5599
|
if (bundler.esbuild) {
|
|
5600
5600
|
metrics.push(...getEsbuildMetrics(bundler.esbuild, opts.cwd));
|
|
5601
5601
|
}
|
|
5602
|
+
const ddOptions = getOptionsDD(opts);
|
|
5602
5603
|
const metricsToSend = metrics.map((m) => {
|
|
5603
5604
|
let metric = m;
|
|
5604
|
-
if (
|
|
5605
|
-
for (const filter of
|
|
5605
|
+
if (ddOptions.filters?.length) {
|
|
5606
|
+
for (const filter of ddOptions.filters) {
|
|
5606
5607
|
if (metric) {
|
|
5607
5608
|
metric = filter(metric);
|
|
5608
5609
|
}
|
|
5609
5610
|
}
|
|
5610
5611
|
}
|
|
5611
|
-
return metric ? getMetric(metric,
|
|
5612
|
+
return metric ? getMetric(metric, ddOptions) : null;
|
|
5612
5613
|
}).filter((m) => m !== null);
|
|
5613
5614
|
return metricsToSend;
|
|
5614
5615
|
};
|
|
@@ -5619,7 +5620,7 @@ const sendMetrics = (metrics, opts) => {
|
|
|
5619
5620
|
}
|
|
5620
5621
|
const metricsNames = [...new Set(metrics.map((m) => m.metric))].sort().map((name) => `${name} - ${metrics.filter((m) => m.metric === name).length}`);
|
|
5621
5622
|
console.log(`
|
|
5622
|
-
|
|
5623
|
+
Sending ${metrics.length} metrics.
|
|
5623
5624
|
Metrics:
|
|
5624
5625
|
- ${metricsNames.join("\n - ")}`);
|
|
5625
5626
|
return new Promise((resolve, reject) => {
|