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: Check APPMAP_RECORDER_PROCESS_ALWAYS truthy value #168

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

zermelo-wisen
Copy link
Contributor

@zermelo-wisen zermelo-wisen commented Aug 5, 2024

This PR 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.


Behavior regarding this environment variable is as follows:

Default Behavior (When APPMAP_RECORDER_PROCESS_ALWAYS is not set to a truthy value)

When the APPMAP_RECORDER_PROCESS_ALWAYS environment variable is not set to one of the truthy values (true, 1, on, yes), appmap-node behaves as follows:

appmap-node initially creates a process recording AppMap for the entire process. If appmap-node detects a request, a test or a remote recording, it abandons the process recording. Instead, for example, if requests are detected, it creates individual request recordings for each detected request. In this case, you end up with multiple request recordings (one per request) and no process recording. Otherwise there will be just one process recording AppMap.

Behavior with APPMAP_RECORDER_PROCESS_ALWAYS set to a truthy Value

When APPMAP_RECORDER_PROCESS_ALWAYS is set to one of the truthy values (true, 1, on, yes):

appmap-node continues to record the entire process even when a request, a test or a remote recording is detected. As a result, for example, if requests are detected, you get one process recording AppMap that covers the entire process and multiple request recording AppMaps, with one AppMap for each request.

@zermelo-wisen zermelo-wisen force-pushed the fix/process-always-envar-truthy-value branch 2 times, most recently from 1f5eb4d to 02d7bc6 Compare August 5, 2024 21:17
@petecheslock
Copy link

Hi @zermelo-wisen - I did a quick test of this branch to see if it was working based on my expectations, but I still seem to get a process recording no matter what the value being set as. Testing with the mern-ecommerce application.

Basically no matter the value of that environment variable i still seem to have process recordings getting created. But perhaps i'm not fully understanding the scope of this change.

Here is a loom where i explain more and show what i'm seeing. https://www.loom.com/share/237004ab6afd4988b21fd134823b0c0f?sid=36c49bdd-ff56-4f22-814a-143f0cd774ac

src/message.ts Outdated
return chalk.magentaBright`(Λ) ` + (typeof message === "string" ? message : inspect(message));
return (
"pid:" +
process.pid +
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like leftover debugging? It's not very user-friendly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this with a temporary commit for @petecheslock to check to be sure. I'll remove it now.

src/recorder.ts Outdated
const processRecordingShouldAlwaysBeActive = "APPMAP_RECORDER_PROCESS_ALWAYS" in process.env;
const kAppmapRecorderProcessAlwaysEnvar = "APPMAP_RECORDER_PROCESS_ALWAYS";
const processRecordingShouldAlwaysBeActive =
kAppmapRecorderProcessAlwaysEnvar in process.env &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you need this check, isTruthy() is going to correctly return false on undefined.

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.
@zermelo-wisen zermelo-wisen force-pushed the fix/process-always-envar-truthy-value branch from daddc77 to e640100 Compare August 8, 2024 12:29
@dustinbyrne dustinbyrne self-requested a review August 12, 2024 13:12
@dustinbyrne dustinbyrne merged commit 761b69a into main Aug 13, 2024
6 checks passed
@dustinbyrne dustinbyrne deleted the fix/process-always-envar-truthy-value branch August 13, 2024 21:10
@appland-release
Copy link

🎉 This PR is included in version 2.24.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants