-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To fit with our naming standards, Agent is now called Extension
- Loading branch information
1 parent
91bd1c3
commit 1db657a
Showing
12 changed files
with
108 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
bump: "patch" | ||
--- | ||
|
||
Rename Agent to Extension | ||
|
||
To fit with our naming standards, Agent class is now Called Extension. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,58 @@ | ||
import { Extension } from "./interfaces/extension" | ||
|
||
let mod: Extension | ||
|
||
try { | ||
mod = require("@appsignal/nodejs-ext") as Extension | ||
} catch (e) { | ||
mod = { | ||
extension: { | ||
start() { | ||
throw new Error("Extension module not loaded") | ||
}, | ||
stop() { | ||
return | ||
import { extension } from "./extension_wrapper" | ||
|
||
/** | ||
* The public interface for the extension. | ||
* | ||
* @class | ||
*/ | ||
export class Extension { | ||
isLoaded = false | ||
|
||
constructor(options?: { active: boolean }) { | ||
if (options?.active) this.start() | ||
} | ||
|
||
/** | ||
* Starts the extension. | ||
*/ | ||
public start(): boolean { | ||
try { | ||
extension.start() | ||
this.isLoaded = true | ||
} catch (e) { | ||
if (e.message === "Extension module not loaded") { | ||
console.warn( | ||
"AppSignal extension not loaded. This could mean that your current environment isn't supported, or that another error has occurred." | ||
) | ||
} else { | ||
console.error( | ||
`Failed to load AppSignal extension with error: ${e.message}. Please email us at [email protected] for support.` | ||
) | ||
} | ||
|
||
this.isLoaded = false | ||
} | ||
} as Extension | ||
} | ||
|
||
export = mod | ||
return this.isLoaded | ||
} | ||
|
||
/** | ||
* Stops the extension. | ||
*/ | ||
public stop(): boolean { | ||
if (this.isLoaded) { | ||
extension.stop() | ||
this.isLoaded = false | ||
} | ||
|
||
return this.isLoaded | ||
} | ||
|
||
public diagnose(): object { | ||
if (this.isLoaded) { | ||
return JSON.parse(extension.diagnoseRaw()) | ||
} else { | ||
return {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ExtensionWrapper } from "./interfaces/extension_wrapper" | ||
|
||
let mod: ExtensionWrapper | ||
|
||
try { | ||
mod = require("@appsignal/nodejs-ext") as ExtensionWrapper | ||
} catch (e) { | ||
mod = { | ||
extension: { | ||
start() { | ||
throw new Error("Extension module not loaded") | ||
}, | ||
stop() { | ||
return | ||
} | ||
} | ||
} as ExtensionWrapper | ||
} | ||
|
||
export = mod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface ExtensionWrapper { | ||
extension: any | ||
span: any | ||
datamap: any | ||
dataarray: any | ||
metrics: any | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters