Skip to content

Conversation

@MSpryszynski
Copy link
Collaborator

Added metrics and logs support for OpenTelemetry and created monitoring local setup

handler.js Outdated

// time interval (ms) at which to probe and log metrics
const probeInterval = process.env.HF_VAR_PROBE_INTERVAL || 2000;
const probeInterval = process.env.HF_VAR_PROBE_INTERVAL || 1;
Copy link
Member

Choose a reason for hiding this comment

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

This is 1ms! Is this necessary? It might have negative impact on performance.

handler.js Outdated
let ioInfo = procfs.processIo(pid);
ioInfo.pid = pid;
ioInfo.name = jm["name"];
if (process.env.HF_VAR_ENABLE_TRACING === "1") {
Copy link
Member

Choose a reason for hiding this comment

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

If (otelLogger) { ... } should be sufficient. That way we avoid too many places where env is tested. The same occurs in other places where otelLogger is used.

handler.js Outdated
const tracer = process.env.HF_VAR_ENABLE_TRACING === "1" ? require("./tracing.js")("hyperflow-job-executor"): undefined;
const { spawn } = require('child_process');
const tracer = process.env.HF_VAR_ENABLE_TRACING === "1" ? require("./tracing.js")("hyperflow-job-executor") : undefined;
const otelLogger = process.env.HF_VAR_ENABLE_TRACING === "1" ? require("./logs.js")("hyperflow-job-executor") : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Here test a different env, e.g. "HF_VAR_ENABLE_OTEL". TRACING should be enabled separately because it requires proper context propagation.

handler.js Outdated
// elapsed: 6650000, // ms since the start of the process
// timestamp: 864000000 // ms since epoch
// }
if (process.env.HF_VAR_ENABLE_TRACING === "1") {
Copy link
Member

Choose a reason for hiding this comment

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

Here (for sending metrics) let's use another guard, e.g. "If (otelEnabled)". Evaluate it at the beginning using the HF_VAR_ENABLE_OTEL env. (That way we evaluate all envs only at the beginning)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants