Merge pull request #31442 from MichaelRBond/newrelic-lambda

Add type support for NewRelic's AWS Lambda monitoring
This commit is contained in:
Nathan Shively-Sanders
2018-12-18 13:46:54 -08:00
committed by GitHub
2 changed files with 12 additions and 1 deletions
+10 -1
View File
@@ -1,7 +1,8 @@
// Type definitions for newrelic 3.4
// Type definitions for newrelic 4.11
// Project: http://github.com/newrelic/node-newrelic
// Definitions by: Matt R. Wilson <https://github.com/mastermatt>
// Brooks Patton <https://github.com/brookspatton>
// Michael Bond <https://github.com/MichaelRBond>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// https://docs.newrelic.com/docs/agents/nodejs-agent/api-guides/nodejs-agent-api
@@ -321,6 +322,14 @@ export const instrumentMessages: Instrument;
export function shutdown(cb?: (error?: Error) => void): void;
export function shutdown(options?: { collectPendingData?: boolean, timeout?: number }, cb?: (error?: Error) => void): void;
/**
* Wraps an AWS Lambda function with NewRelic instrumentation and returns the value of the handler
*
* @param handler a callback function whose value is returned from setLambdaHandler
* @returns the value returned by handler
*/
export function setLambdaHandler<T>(handler: (...args: any[]) => T): T;
export interface Instrument {
(opts: { moduleName: string, onRequire: () => void, onError?: (err: Error) => void }): void;
(moduleName: string, onRequire: () => void, onError?: (err: Error) => void): void;
+2
View File
@@ -104,3 +104,5 @@ newrelic.shutdown({ collectPendingData: true, timeout: 3000 }, (err) => {
newrelic.shutdown((err) => {
const error: Error | undefined = err;
});
newrelic.setLambdaHandler(() => void 0); // $ExpectType undefined