Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(publish-metrics): route debug correctly for publish metrics reporters #2514

Conversation

InesNi
Copy link
Contributor

@InesNi InesNi commented Feb 20, 2024

Description

When DEBUG is set to a vendor-specific reporter (from publish-metrics) if that reporter is using OTel in the background we want to log OTel reporters debug logs as well.

e.g. When user uses the Datadog reporter for tracing and sets DEBUG=plugin:publish-metrics:datadog, we want to log debug logs from OTel reporter as well as OTel is the one running the tracing.

Implementation

  • OpenTelemetry's internal diagnostic handler will run if DEBUG is set to any reporter, not just open-telemetry
  • Artillery's debug will be dynamically set for metrics and traces, using the type property from config set to the reporters name.

In config translator functions type is set on both traces and metrics part of config so that classes responsible for metrics and traces can set the debug accordingly.

Testing

Tested manually, running multiple reporters and types of errors to trigger all debug logs and make sure the output is correct.

Pre-merge checklist

  • Does this require an update to the docs?
  • Does this require a changelog entry?

@@ -64,11 +64,14 @@ const vendorTranslators = {
return otelTemplate(config, dynatraceTraceSettings);
},
'open-telemetry': (config) => {
let tracesConfig = config;
let newConfig = config;
Copy link
Contributor Author

@InesNi InesNi Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the type to metrics block here to make the reporter name available for the metric pipeline.

Note: Changing name to newConfig as makes more sense, especially now when adding the metrics check as well.

@@ -24,7 +23,7 @@ context.setGlobalContextManager(contextManager);
// DEBUGGING SETUP - setting the OpenTelemetry's internal diagnostic handler here to run when debug is enabled
if (
process.env.DEBUG &&
process.env.DEBUG === 'plugin:publish-metrics:open-telemetry'
process.env.DEBUG.includes('plugin:publish-metrics:')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting OTels internal logger to run when DEBUG is set for any reporter, not just open-telemetry

}
}

class OTelTraceBase {
constructor(config, script) {
this.config = config;
this.script = script;
this.debug = require('debug')(`plugin:publish-metrics:${this.config.type}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting this.debug here with reporter type will make it available to both HTTP and Playwright trace reporters.

@@ -45,6 +44,7 @@ class OTelMetricsReporter {
}

configure(config) {
this.debug = require('debug')(`plugin:publish-metrics:${this.config.type}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently OTel reporter metrics doesn't support any vendor-specific reporters, but for future proofing we require dynamically.

@InesNi InesNi marked this pull request as ready for review February 20, 2024 16:06
@InesNi InesNi merged commit 6e56af4 into main Feb 21, 2024
18 checks passed
@InesNi InesNi deleted the ifazlic-art-1655-route-debug-correctly-for-publish-metrics-reporters branch February 21, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants