Skip to content

Commit

Permalink
refactor(preload): init map in constructor instead of lazy init
Browse files Browse the repository at this point in the history
  • Loading branch information
basti1302 committed Jun 22, 2024
1 parent 78a0425 commit b149f47
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions images/dash0-instrumentation/preload/src/libdash0envhook.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,17 @@ secure_getenv_fun_ptr original_secure_getenv;

int num_map_entries = 1;
Entry map[1];
bool init = false;

char* default_node_options_value = "--require /opt/dash0/instrumentation/node.js/node_modules/@dash0/opentelemetry/src/index.js";

void init_map() {
if (init) {
return;
}

__attribute__((constructor)) static void setup(void) {
Entry node_options_entry = { .key = "NODE_OPTIONS", .value = NULL };
map[0] = node_options_entry;
init = true;
}

char* _getenv(char* (*original_function)(const char* name), const char* name)
{
init_map();

if (strcmp(name, "NODE_OPTIONS") != 0) {
return original_function(name);
}
Expand Down

0 comments on commit b149f47

Please sign in to comment.