Skip to content

Commit

Permalink
Use APPSIGNAL_ACTIVE environment value
Browse files Browse the repository at this point in the history
Before this change, the value of the `APPSIGNAL_ACTIVE` environment
variable would never be read, as the `active` config option was
read directly from the `BaseClient` constructor. After this change,
the option is read from the `Config` object, after it has been
initialised in the constructor.

Fixes #546.
  • Loading branch information
unflxw committed Jan 17, 2022
1 parent c77ff63 commit bb62525
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "fix"
---

Use the APPSIGNAL_ACTIVE environment variable to determine whether AppSignal is active.
1 change: 1 addition & 0 deletions packages/nodejs/src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("Configuration", () => {
let initialEnv: { [key: string]: any }

const expectedDefaultConfig = {
active: false,
caFilePath: path.join(__dirname, "../../cert/cacert.pem"),
debug: false,
dnsServers: [],
Expand Down
8 changes: 4 additions & 4 deletions packages/nodejs/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export class BaseClient implements Client {
* Creates a new instance of the `Appsignal` object
*/
constructor(options: Partial<AppsignalOptions> = {}) {
const {
active = false, // Agent is not started by default
ignoreInstrumentation
} = options
const { ignoreInstrumentation } = options

this.config = new Configuration(options)

const active = this.config.data.active!

this.extension = new Extension({ active })

this.storeInGlobal()
Expand Down
1 change: 1 addition & 0 deletions packages/nodejs/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export class Configuration {
*/
private _defaultValues(): { [key: string]: any } {
return {
active: false,
caFilePath: path.join(__dirname, "../cert/cacert.pem"),
debug: false,
dnsServers: [],
Expand Down

0 comments on commit bb62525

Please sign in to comment.