Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export function scoutMiddleware(opts?: ExpressMiddlewareOptions): ExpressMiddlew
.then(scout => req.app.scout = scout)
// Set up the scout instance (if necessary)
.then(scout => scout.setup())
// Start perofrming midleware duties
// Start performing middleware duties
.then(scout => {
// If we get here but have no route path,
// (meaning we couldn't figure it out from a matched middleware or full route listing)
Expand Down
2 changes: 1 addition & 1 deletion lib/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function setGlobalLastUsedConfiguration(config: Partial<ScoutConfiguratio
/**
* Set the last used scout options, to support flexibility in setup from middleware or scout.install()
*
* @param {Partial<ScoutOptsuration>} opts
* @param {Partial<ScoutOptions>} opts
*/
export function setGlobalLastUsedOptions(opts: ScoutOptions): void {
LAST_USED_OPTS = opts;
Expand Down
2 changes: 1 addition & 1 deletion lib/integrations/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class ExpressIntegration extends RequireIntegration {
// Get the current request if available
const currentRequest = integration.scout.getCurrentRequest();
if (currentRequest) {
// Mark the curernt request as errored
// Mark the current request as errored
currentRequest.addContextSync(ScoutContextName.Error, "true");
}

Expand Down
46 changes: 14 additions & 32 deletions lib/scout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,12 @@ export class Scout extends EventEmitter {
Constants.CORE_AGENT_BIN_FILE_NAME,
);

// If the passed-in logging function (saved @ logFn) has a 'logger' property which has a correposnding level
// attempt to set the log level to the passed in logger's level
// If the passed-in logging function has a 'logger' property with a corresponding level,
// attempt to set the log level to match
if (this.logFn && this.logFn.logger && this.logFn.logger.level && isLogLevel(this.logFn.logger.level)) {
this.config.logLevel = parseLogLevel(this.logFn.logger.level);
}

// Create async namespace if it does not exist
this.createAsyncNamespace();
}

Expand Down Expand Up @@ -208,7 +207,7 @@ export class Scout extends EventEmitter {

this.statsSendingInterval = setInterval(() => {
if (!this.agent) {
// A shutdown likey occurred
// A shutdown likely occurred
this.log("[scout] Disabling stats sending interval since agent is missing...", LogLevel.Debug);
if (this.statsSendingInterval) { clearInterval(this.statsSendingInterval); }
return;
Expand Down Expand Up @@ -242,7 +241,7 @@ export class Scout extends EventEmitter {
/**
* Stop sending statistics for the node process
*
* @return {Promise<void>} A promise that resolves when the statistics sending has stoped
* @return {Promise<void>} A promise that resolves when the statistics sending has stopped
*/
protected stopSendingStatistics(): void {
if (!this.statsSendingInterval) { return; }
Expand Down Expand Up @@ -309,7 +308,6 @@ export class Scout extends EventEmitter {

const doLaunch = shouldLaunch ? this.downloadAndLaunchAgent() : this.createAgentForExistingSocket();

// If the socket path exists then we may be able to skip downloading and launching
this.settingUp = doLaunch
.then(() => {
if (!this.agent) { throw new Errors.NoAgentPresent(); }
Expand Down Expand Up @@ -361,7 +359,7 @@ export class Scout extends EventEmitter {
this.stopSendingStatistics();
}

// Ensure an agent is present bfore we attempt to shut it down
// Ensure an agent is present before we attempt to shut it down
if (!this.agent) {
this.log("[scout] shutdown called but no agent to shutdown is present", LogLevel.Error);
return Promise.reject(new Errors.NoAgentPresent());
Expand Down Expand Up @@ -447,7 +445,7 @@ export class Scout extends EventEmitter {

let ranContext = false;

// Setup if necessary then then perform the async request context
// Setup if necessary, then perform the async request context
return this.setup()
.then(() => {
ranContext = true;
Expand Down Expand Up @@ -688,7 +686,7 @@ export class Scout extends EventEmitter {
}

/**
* Retrieve the current request using the async hook/continuation local storage machinery
* Retrieve the current request from the active async context
*
* @returns {ScoutRequest} the current active request
*/
Expand All @@ -701,7 +699,7 @@ export class Scout extends EventEmitter {
}

/**
* Retrieve the current span using the async hook/continuation local storage machinery
* Retrieve the current span from the active async context
*
* @returns {ScoutSpan} the current active span
*/
Expand Down Expand Up @@ -741,22 +739,6 @@ export class Scout extends EventEmitter {
return Promise.reject(new Errors.UnknownSocketType());
}

/**
* Attempt to clear an async name space entry
*
* this.asyncNamespace.set can fail if the async context ID is already gone
* before someone tries to clear it. This can happen if some caller moves calls to
* another async context or if it's cleaned up suddenly
*/
private clearAsyncNamespaceEntry(key: keyof ScoutAsyncStore) {
try {
const store = this.asyncStorage.getStore();
if (store) { store[key] = undefined; }
} catch {
this.logFn("failed to clear async namespace", LogLevel.Debug);
}
}

// Helper for creating an ExternalProcessAgent for an existing, listening agent
private createAgentForExistingSocket(socketPath?: string): Promise<ExternalProcessAgent> {
this.log(`[scout] detected existing socket @ [${this.socketPath}], skipping agent launch`, LogLevel.Debug);
Expand Down Expand Up @@ -886,7 +868,7 @@ export class Scout extends EventEmitter {

};

this.log(`[scout] Starting request in async namespace...`, LogLevel.Debug);
this.log(`[scout] Starting request in async context...`, LogLevel.Debug);

// Start the request
this.startRequest()
Expand Down Expand Up @@ -996,7 +978,7 @@ export class Scout extends EventEmitter {
const currentRequest = this.getCurrentRequest();
if (!currentRequest) { return; }

// Mark the curernt request as errored
// Mark the current request as errored
currentRequest.addContext(ScoutContextName.Error, "true");
}

Expand Down Expand Up @@ -1067,7 +1049,7 @@ export function sendStopRequest(scout: Scout, req: ScoutRequest): Promise<ScoutR
* @param {ScoutRequest} req - The original request
* @param {String} name - The tag name
* @param {String} value - The tag value
* @returns {Promise<void>} A promise which resolves when the message has been sent
* @returns {Promise<void>} A promise which resolves when the message has been sent sent
*/
export function sendTagRequest(
scout: Scout,
Expand Down Expand Up @@ -1128,13 +1110,13 @@ export function sendStartSpan(scout: Scout, span: ScoutSpan): Promise<ScoutSpan>
}

/**
* Send the TagSpan message to the agent message to the agent
* Send the TagSpan message to the agent
*
* @param {Scout} scout - A scout instance
* @param {ScoutSpan} span - The original span
* @param {String} name - The tag name
* @param {String} value - The tag value
* @returns {Promise<void>} A promise which resolves when the message has been
* @returns {Promise<void>} A promise which resolves when the message has been sent
*/
export function sendTagSpan(
scout: Scout,
Expand Down Expand Up @@ -1220,7 +1202,7 @@ export function sendThroughAgent<T extends BaseAgentRequest, R extends BaseAgent
}

if (!config.monitor) {
scout.log("[scout] monitoring disabled, not sending tag request", LogLevel.Warn);
scout.log("[scout] monitoring disabled, not sending request", LogLevel.Warn);
return Promise.reject(new Errors.MonitoringDisabled());
}

Expand Down
Loading