Skip to content

Commit

Permalink
fix: Check APPMAP_RECORDER_PROCESS_ALWAYS truthy value
Browse files Browse the repository at this point in the history
This commit updates the interpretation of the APPMAP_RECORDER_PROCESS_ALWAYS
environment variable so that process recording remains active only if the
variable is set to a truthy value (one of ‘true’, ‘1’, ‘on’, ‘yes’).

Previously, the existence of the APPMAP_RECORDER_PROCESS_ALWAYS environment
variable, regardless of its value, was interpreted as true.
  • Loading branch information
zermelo-wisen committed Aug 8, 2024
1 parent a8b9fbf commit e640100
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ import { FunctionInfo } from "./registry";
import commonPathPrefix from "./util/commonPathPrefix";
import { getTime } from "./util/getTime";

const processRecordingShouldAlwaysBeActive = "APPMAP_RECORDER_PROCESS_ALWAYS" in process.env;
const kAppmapRecorderProcessAlwaysEnvar = "APPMAP_RECORDER_PROCESS_ALWAYS";
const processRecordingShouldAlwaysBeActive = isTruthy(
process.env[kAppmapRecorderProcessAlwaysEnvar],
);

function isTruthy(value?: string): boolean {
if (value == undefined) return false;
const truthyValues = ["true", "1", "on", "yes"];
return truthyValues.includes(value.toLowerCase().trim());
}

// If APPMAP_RECORDER_PROCESS_ALWAYS is set we can have
// two recordings active simultaneously. Always active
Expand Down

0 comments on commit e640100

Please sign in to comment.