@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.d.ts
CHANGED
|
@@ -6,15 +6,15 @@ interface GetPluginsOptions {
|
|
|
6
6
|
appKey: string;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
declare const CONFIG_KEY: "telemetry";
|
|
11
|
-
|
|
12
9
|
interface Metric {
|
|
13
10
|
metric: string;
|
|
14
11
|
type: 'count' | 'size' | 'duration';
|
|
15
12
|
value: number;
|
|
16
13
|
tags: string[];
|
|
17
14
|
}
|
|
15
|
+
|
|
16
|
+
declare const CONFIG_KEY: "telemetry";
|
|
17
|
+
|
|
18
18
|
type Filter = (metric: Metric) => Metric | null;
|
|
19
19
|
interface DatadogOptions {
|
|
20
20
|
apiKey?: string;
|
package/dist/src/index.js
CHANGED
|
@@ -3058,6 +3058,48 @@ const getContext = (args) => {
|
|
|
3058
3058
|
value: typeof arg === "string" ? arg : void 0
|
|
3059
3059
|
}));
|
|
3060
3060
|
};
|
|
3061
|
+
const filterTreeMetrics = (metric) => (
|
|
3062
|
+
// Remove tree metrics because way too verbose
|
|
3063
|
+
!/modules\.tree\.(count|size)$/.test(metric.metric) ? metric : null
|
|
3064
|
+
);
|
|
3065
|
+
const filterSourcemapsAndNodeModules = (metric) => metric.tags.some(
|
|
3066
|
+
(tag) => (
|
|
3067
|
+
// Remove sourcemaps.
|
|
3068
|
+
/^assetName:.*\.map$/.test(tag) || // Remove third parties.
|
|
3069
|
+
/^moduleName:\/node_modules/.test(tag)
|
|
3070
|
+
)
|
|
3071
|
+
) ? null : metric;
|
|
3072
|
+
const filterMetricsOnThreshold = (metric) => {
|
|
3073
|
+
const thresholds = {
|
|
3074
|
+
size: 1e5,
|
|
3075
|
+
count: 10,
|
|
3076
|
+
duration: 1e3
|
|
3077
|
+
};
|
|
3078
|
+
if (/(entries|loaders|warnings|errors)\.count$/.test(metric.metric)) {
|
|
3079
|
+
thresholds.count = 0;
|
|
3080
|
+
}
|
|
3081
|
+
if (/(modules\.(dependencies|dependents)$)/.test(metric.metric)) {
|
|
3082
|
+
thresholds.count = 30;
|
|
3083
|
+
}
|
|
3084
|
+
if (/modules\.tree\.count$/.test(metric.metric)) {
|
|
3085
|
+
thresholds.count = 150;
|
|
3086
|
+
}
|
|
3087
|
+
if (/modules\.tree\.size$/.test(metric.metric)) {
|
|
3088
|
+
thresholds.size = 15e5;
|
|
3089
|
+
}
|
|
3090
|
+
if (/entries\.size$/.test(metric.metric)) {
|
|
3091
|
+
thresholds.size = 0;
|
|
3092
|
+
}
|
|
3093
|
+
if (/entries\.modules\.count$/.test(metric.metric)) {
|
|
3094
|
+
thresholds.count = 0;
|
|
3095
|
+
}
|
|
3096
|
+
return metric.value > thresholds[metric.type] ? metric : null;
|
|
3097
|
+
};
|
|
3098
|
+
const defaultTelemetryFilters = [
|
|
3099
|
+
filterTreeMetrics,
|
|
3100
|
+
filterSourcemapsAndNodeModules,
|
|
3101
|
+
filterMetricsOnThreshold
|
|
3102
|
+
];
|
|
3061
3103
|
|
|
3062
3104
|
const outputFiles = async (context, options) => {
|
|
3063
3105
|
const { report, metrics, bundler } = context;
|
|
@@ -5026,48 +5068,6 @@ var templates = (chalk, tmp) => {
|
|
|
5026
5068
|
var chalkExports = chalk$1.exports;
|
|
5027
5069
|
var chalk = /*@__PURE__*/getDefaultExportFromCjs(chalkExports);
|
|
5028
5070
|
|
|
5029
|
-
const filterTreeMetrics = (metric) => (
|
|
5030
|
-
// Remove tree metrics because way too verbose
|
|
5031
|
-
!/modules\.tree\.(count|size)$/.test(metric.metric) ? metric : null
|
|
5032
|
-
);
|
|
5033
|
-
const filterSourcemapsAndNodeModules = (metric) => metric.tags.some(
|
|
5034
|
-
(tag) => (
|
|
5035
|
-
// Remove sourcemaps.
|
|
5036
|
-
/^assetName:.*\.map$/.test(tag) || // Remove third parties.
|
|
5037
|
-
/^moduleName:\/node_modules/.test(tag)
|
|
5038
|
-
)
|
|
5039
|
-
) ? null : metric;
|
|
5040
|
-
const filterMetricsOnThreshold = (metric) => {
|
|
5041
|
-
const thresholds = {
|
|
5042
|
-
size: 1e5,
|
|
5043
|
-
count: 10,
|
|
5044
|
-
duration: 1e3
|
|
5045
|
-
};
|
|
5046
|
-
if (/(entries|loaders|warnings|errors)\.count$/.test(metric.metric)) {
|
|
5047
|
-
thresholds.count = 0;
|
|
5048
|
-
}
|
|
5049
|
-
if (/(modules\.(dependencies|dependents)$)/.test(metric.metric)) {
|
|
5050
|
-
thresholds.count = 30;
|
|
5051
|
-
}
|
|
5052
|
-
if (/modules\.tree\.count$/.test(metric.metric)) {
|
|
5053
|
-
thresholds.count = 150;
|
|
5054
|
-
}
|
|
5055
|
-
if (/modules\.tree\.size$/.test(metric.metric)) {
|
|
5056
|
-
thresholds.size = 15e5;
|
|
5057
|
-
}
|
|
5058
|
-
if (/entries\.size$/.test(metric.metric)) {
|
|
5059
|
-
thresholds.size = 0;
|
|
5060
|
-
}
|
|
5061
|
-
if (/entries\.modules\.count$/.test(metric.metric)) {
|
|
5062
|
-
thresholds.count = 0;
|
|
5063
|
-
}
|
|
5064
|
-
return metric.value > thresholds[metric.type] ? metric : null;
|
|
5065
|
-
};
|
|
5066
|
-
const defaultFilters = [
|
|
5067
|
-
filterTreeMetrics,
|
|
5068
|
-
filterSourcemapsAndNodeModules,
|
|
5069
|
-
filterMetricsOnThreshold
|
|
5070
|
-
];
|
|
5071
5071
|
const getMetric = (metric, opts) => ({
|
|
5072
5072
|
type: "gauge",
|
|
5073
5073
|
tags: [...metric.tags, ...opts.tags],
|
|
@@ -5084,7 +5084,7 @@ const getOptionsDD = (opt) => {
|
|
|
5084
5084
|
tags: options.datadog?.tags || [],
|
|
5085
5085
|
endPoint: options.datadog?.endPoint || "app.datadoghq.com",
|
|
5086
5086
|
prefix: options.datadog?.prefix || "",
|
|
5087
|
-
filters: options.datadog?.filters ||
|
|
5087
|
+
filters: options.datadog?.filters || defaultTelemetryFilters
|
|
5088
5088
|
};
|
|
5089
5089
|
};
|
|
5090
5090
|
|
|
@@ -5623,16 +5623,17 @@ const getMetrics = (opts, report, bundler) => {
|
|
|
5623
5623
|
if (bundler.esbuild) {
|
|
5624
5624
|
metrics.push(...getEsbuildMetrics(bundler.esbuild, opts.cwd));
|
|
5625
5625
|
}
|
|
5626
|
+
const ddOptions = getOptionsDD(opts);
|
|
5626
5627
|
const metricsToSend = metrics.map((m) => {
|
|
5627
5628
|
let metric = m;
|
|
5628
|
-
if (
|
|
5629
|
-
for (const filter of
|
|
5629
|
+
if (ddOptions.filters?.length) {
|
|
5630
|
+
for (const filter of ddOptions.filters) {
|
|
5630
5631
|
if (metric) {
|
|
5631
5632
|
metric = filter(metric);
|
|
5632
5633
|
}
|
|
5633
5634
|
}
|
|
5634
5635
|
}
|
|
5635
|
-
return metric ? getMetric(metric,
|
|
5636
|
+
return metric ? getMetric(metric, ddOptions) : null;
|
|
5636
5637
|
}).filter((m) => m !== null);
|
|
5637
5638
|
return metricsToSend;
|
|
5638
5639
|
};
|
|
@@ -5643,7 +5644,7 @@ const sendMetrics = (metrics, opts) => {
|
|
|
5643
5644
|
}
|
|
5644
5645
|
const metricsNames = [...new Set(metrics.map((m) => m.metric))].sort().map((name) => `${name} - ${metrics.filter((m) => m.metric === name).length}`);
|
|
5645
5646
|
console.log(`
|
|
5646
|
-
|
|
5647
|
+
Sending ${metrics.length} metrics.
|
|
5647
5648
|
Metrics:
|
|
5648
5649
|
- ${metricsNames.join("\n - ")}`);
|
|
5649
5650
|
return new Promise((resolve, reject) => {
|