diff --git a/packages/artillery-plugin-publish-metrics/lib/dynatrace/index.js b/packages/artillery-plugin-publish-metrics/lib/dynatrace/index.js index c0fde5f8ba..ffe1444c01 100644 --- a/packages/artillery-plugin-publish-metrics/lib/dynatrace/index.js +++ b/packages/artillery-plugin-publish-metrics/lib/dynatrace/index.js @@ -1,10 +1,11 @@ 'use strict'; -const got = require('got'); const debug = require('debug')('plugin:publish-metrics:dynatrace'); const path = require('path'); const { sleep } = require('../util'); +let got = null; + class DynatraceReporter { constructor(config, events, script) { if ( @@ -266,6 +267,10 @@ class DynatraceReporter { } async sendRequest(url, options, type = 'metrics') { + if (!got) { + got = (await import('got')).default; + } + this.pendingRequests += 1; debug(`Sending ${type} to Dynatrace`); diff --git a/packages/artillery-plugin-publish-metrics/lib/newrelic/index.js b/packages/artillery-plugin-publish-metrics/lib/newrelic/index.js index f9d482c54b..f7c66844b6 100644 --- a/packages/artillery-plugin-publish-metrics/lib/newrelic/index.js +++ b/packages/artillery-plugin-publish-metrics/lib/newrelic/index.js @@ -1,7 +1,8 @@ -const got = require('got'); const { sleep } = require('../util'); const debug = require('debug')('plugin:publish-metrics:newrelic'); +let got = null; + class NewRelicReporter { constructor(config, events, script) { if (!config.licenseKey) { @@ -192,6 +193,10 @@ class NewRelicReporter { } async sendStats(url, licenseKey, body) { + if (!got) { + got = (await import('got')).default; + } + this.pendingRequests += 1; const headers = { 'Content-Type': 'application/json; charset=UTF-8', @@ -236,6 +241,10 @@ class NewRelicReporter { } async sendEvent(url, licenseKey, eventOptions) { + if (!got) { + got = (await import('got')).default; + } + this.pendingRequests += 1; const headers = { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/packages/artillery-plugin-publish-metrics/lib/splunk/index.js b/packages/artillery-plugin-publish-metrics/lib/splunk/index.js index 2be99ecbf1..aae872fc90 100644 --- a/packages/artillery-plugin-publish-metrics/lib/splunk/index.js +++ b/packages/artillery-plugin-publish-metrics/lib/splunk/index.js @@ -1,7 +1,6 @@ -const got = require('got'); const { sleep } = require('../util'); const debug = require('debug')('plugin:publish-metrics:splunk'); - +let got = null; class SplunkReporter { constructor(config, events, script) { if (!config.accessToken) { @@ -178,6 +177,10 @@ class SplunkReporter { } async sendRequest(url, payload, type) { + if (!got) { + got = (await import('got')).default; + } + this.pendingRequests += 1; const options = this.formRequest(payload);