From 85e29d5a71d70e39306c6b39b35cf5ff8fbaa791 Mon Sep 17 00:00:00 2001 From: Kenneth Aasan Date: Fri, 22 Nov 2019 16:41:35 +0100 Subject: [PATCH] newrelic distributed tracing Transaction handle methods (#40550) * Adds newrelic distributed tracing Transaction handle methods * Adds newrelic distributed tracing Transaction handle methods --- types/newrelic/index.d.ts | 23 +++++++++++++++++++++++ types/newrelic/newrelic-tests.ts | 2 ++ 2 files changed, 25 insertions(+) diff --git a/types/newrelic/index.d.ts b/types/newrelic/index.d.ts index 911f7e7a2e..c010db1f5e 100644 --- a/types/newrelic/index.d.ts +++ b/types/newrelic/index.d.ts @@ -4,6 +4,7 @@ // Brooks Patton // Michael Bond // Kyle Scully +// Kenneth Aasan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // https://docs.newrelic.com/docs/agents/nodejs-agent/api-guides/nodejs-agent-api @@ -354,6 +355,18 @@ export interface Metric { sumOfSquares: number; } +export interface DistributedTracePayload { + /** + * The base64 encoded JSON representation of the distributed trace payload. + */ + text(): string; + + /** + * The base64 encoded JSON representation of the distributed trace payload. + */ + httpSafe(): string; +} + export interface TransactionHandle { /** * End the transaction. @@ -364,4 +377,14 @@ export interface TransactionHandle { * Mark the transaction to be ignored. */ ignore(): void; + + /** + * Creates a distributed trace payload. + */ + createDistributedTracePayload(): DistributedTracePayload; + + /** + * Parses incoming distributed trace header payload. + */ + acceptDistributedTracePayload(payload: DistributedTracePayload): void; } diff --git a/types/newrelic/newrelic-tests.ts b/types/newrelic/newrelic-tests.ts index a98a38a22d..b2c7069ba8 100644 --- a/types/newrelic/newrelic-tests.ts +++ b/types/newrelic/newrelic-tests.ts @@ -7,6 +7,8 @@ const trans = newrelic.getTransaction(); trans.ignore(); // $ExpectType void trans.end(); // $ExpectType void trans.end(() => {}); // $ExpectType void +const payload = trans.createDistributedTracePayload(); // $ExpectType DistributedTracePayload +trans.acceptDistributedTracePayload(payload); // $ExpectType void newrelic.setDispatcher('foo'); // $ExpectType void newrelic.setDispatcher('foo', '42'); // $ExpectType void