apollo-tracing
Advanced tools
Comparing version 0.0.9 to 0.1.0
@@ -1,2 +0,35 @@ | ||
export { TraceCollector, instrumentSchemaForTracing } from './instrumentation'; | ||
export { formatTraceData } from './tracingFormat'; | ||
import { GraphQLResolveInfo } from "graphql"; | ||
import { GraphQLExtension } from "graphql-extensions"; | ||
export interface TracingFormat { | ||
version: 1; | ||
startTime: string; | ||
endTime: string; | ||
duration: number; | ||
execution: { | ||
resolvers: { | ||
path: (string | number)[]; | ||
parentType: string; | ||
fieldName: string; | ||
returnType: string; | ||
startOffset: number; | ||
duration: number; | ||
}[]; | ||
}; | ||
} | ||
export declare class TracingExtension<TContext = any> implements GraphQLExtension<TContext> { | ||
private startWallTime; | ||
private endWallTime; | ||
private startHrTime; | ||
private duration; | ||
private resolverCalls; | ||
requestDidStart(): void; | ||
executionDidStart(): void; | ||
willResolveField(_source: any, _args: { | ||
[argName: string]: any; | ||
}, _context: TContext, info: GraphQLResolveInfo): () => void; | ||
didResolveField(_source: any, _args: { | ||
[argName: string]: any; | ||
}, _context: TContext, info: GraphQLResolveInfo): void; | ||
requestDidEnd(): void; | ||
format(): [string, TracingFormat]; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var instrumentation_1 = require("./instrumentation"); | ||
exports.TraceCollector = instrumentation_1.TraceCollector; | ||
exports.instrumentSchemaForTracing = instrumentation_1.instrumentSchemaForTracing; | ||
var tracingFormat_1 = require("./tracingFormat"); | ||
exports.formatTraceData = tracingFormat_1.formatTraceData; | ||
const graphql_1 = require("graphql"); | ||
class TracingExtension { | ||
constructor() { | ||
this.resolverCalls = []; | ||
} | ||
requestDidStart() { | ||
this.startWallTime = new Date(); | ||
this.startHrTime = process.hrtime(); | ||
} | ||
executionDidStart() { } | ||
willResolveField(_source, _args, _context, info) { | ||
const resolverCall = { | ||
path: info.path, | ||
fieldName: info.fieldName, | ||
parentType: info.parentType, | ||
returnType: info.returnType, | ||
startOffset: process.hrtime(this.startHrTime) | ||
}; | ||
this.resolverCalls.push(resolverCall); | ||
return () => { | ||
resolverCall.endOffset = process.hrtime(this.startHrTime); | ||
}; | ||
} | ||
didResolveField(_source, _args, _context, info) { } | ||
requestDidEnd() { | ||
this.duration = process.hrtime(this.startHrTime); | ||
this.endWallTime = new Date(); | ||
} | ||
format() { | ||
return [ | ||
"tracing", | ||
{ | ||
version: 1, | ||
startTime: this.startWallTime.toISOString(), | ||
endTime: this.endWallTime.toISOString(), | ||
duration: durationHrTimeToNanos(this.duration), | ||
execution: { | ||
resolvers: this.resolverCalls.map(resolverCall => { | ||
const startOffset = durationHrTimeToNanos(resolverCall.startOffset); | ||
const duration = resolverCall.endOffset | ||
? durationHrTimeToNanos(resolverCall.endOffset) - startOffset | ||
: 0; | ||
return { | ||
path: graphql_1.responsePathAsArray(resolverCall.path), | ||
parentType: resolverCall.parentType.toString(), | ||
fieldName: resolverCall.fieldName, | ||
returnType: resolverCall.returnType.toString(), | ||
startOffset, | ||
duration | ||
}; | ||
}) | ||
} | ||
} | ||
]; | ||
} | ||
} | ||
exports.TracingExtension = TracingExtension; | ||
// Converts an hrtime array (as returned from process.hrtime) to nanoseconds. | ||
// | ||
// ONLY CALL THIS ON VALUES REPRESENTING DELTAS, NOT ON THE RAW RETURN VALUE | ||
// FROM process.hrtime() WITH NO ARGUMENTS. | ||
// | ||
// The entire point of the hrtime data structure is that the JavaScript Number | ||
// type can't represent all int64 values without loss of precision: | ||
// Number.MAX_SAFE_INTEGER nanoseconds is about 104 days. Calling this function | ||
// on a duration that represents a value less than 104 days is fine. Calling | ||
// this function on an absolute time (which is generally roughly time since | ||
// system boot) is not a good idea. | ||
function durationHrTimeToNanos(hrtime) { | ||
return hrtime[0] * 1e9 + hrtime[1]; | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "apollo-tracing", | ||
"version": "0.0.9", | ||
"version": "0.1.0", | ||
"description": "Collect and expose trace data for GraphQL requests", | ||
@@ -29,4 +29,4 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"graphql-tools": "^2.2.0" | ||
"graphql-extensions": "^0.0.4" | ||
} | ||
} |
@@ -10,2 +10,3 @@ { | ||
"lib": ["es2017", "esnext.asynciterable"], | ||
"types": ["jest", "node"], | ||
"strict": true | ||
@@ -12,0 +13,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10044
7
124
1
+ Addedgraphql-extensions@^0.0.4
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedgraphql-extensions@0.0.4(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
- Removedgraphql-tools@^2.2.0
- Removed@wry/equality@0.1.11(transitive)
- Removedapollo-link@1.2.14(transitive)
- Removedapollo-utilities@1.3.4(transitive)
- Removeddeprecated-decorator@0.1.6(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedgraphql-tools@2.24.0(transitive)
- Removedts-invariant@0.4.4(transitive)
- Removedtslib@1.14.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedzen-observable@0.8.15(transitive)
- Removedzen-observable-ts@0.8.21(transitive)