Skip to content

Commit

Permalink
Add RunningInContainer function to extension
Browse files Browse the repository at this point in the history
This function checks if the agent is running in a container. The Ruby
and the Elixir integrations already use this function in the diagnose
report.

This commit makes the function available to be used in the integration.
  • Loading branch information
luismiramirez committed Dec 27, 2021
1 parent 420541a commit 1f67da7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: "patch"
type: "add"
---

RunningInContainer function is now available from the extension. It checks if the agent is running
in a container.
8 changes: 8 additions & 0 deletions packages/nodejs-ext/ext/appsignal_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Napi::Value DiagnoseRaw(const Napi::CallbackInfo &info) {
return Napi::String::New(env, str.buf, str.len);
}

Napi::Value RunningInContainer(const Napi::CallbackInfo &info) {
bool running_in_container = !!appsignal_running_in_container();

return Napi::Value::From(info.Env(), running_in_container);
}

// Data Array encoding

Napi::Value CreateDataArray(const Napi::CallbackInfo &info) {
Expand Down Expand Up @@ -632,6 +638,8 @@ Napi::Object CreateExtensionObject(Napi::Env env, Napi::Object exports) {
extension.Set(Napi::String::New(env, "stop"), Napi::Function::New(env, Stop));
extension.Set(Napi::String::New(env, "diagnoseRaw"),
Napi::Function::New(env, DiagnoseRaw));
extension.Set(Napi::String::New(env, "runningInContainer"),
Napi::Function::New(env, RunningInContainer));

return extension;
}
Expand Down

0 comments on commit 1f67da7

Please sign in to comment.