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 5, 2024
1 parent a8b9fbf commit 1f5eb4d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ 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 =
kAppmapRecorderProcessAlwaysEnvar in process.env &&
isTruthy(process.env[kAppmapRecorderProcessAlwaysEnvar]!);

function isTruthy(value: string): boolean {
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 1f5eb4d

Please sign in to comment.