From 68c82e63c687b39f8811bf0a911da5d5743b5399 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Thu, 27 Sep 2018 16:35:00 +0300 Subject: [PATCH] Revert "Provide ability to specify client info in traces (#1631)" This reverts commit 96af44e41a9816b52ca7777f80c218f0f5470ba3. --- CHANGELOG.md | 1 + docs/source/api/apollo-server.md | 10 -------- packages/apollo-engine-reporting/src/agent.ts | 13 ---------- .../apollo-engine-reporting/src/extension.ts | 25 +------------------ .../apollo-server-core/src/runHttpQuery.ts | 1 - packages/apollo-server-core/src/runQuery.ts | 2 -- packages/graphql-extensions/src/index.ts | 1 - 7 files changed, 2 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48255a24ca5..794870a2f89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### vNEXT +- FIXME(@abernix): client info in traces. - Allow an optional function to resolve the `rootValue`, passing the `DocumentNode` AST to determine the value. [PR #1555](https://github.com/apollographql/apollo-server/pull/1555) - Follow-up on the work in [PR #1516](https://github.com/apollographql/apollo-server/pull/1516) to also fix missing insertion cursor/caret when a custom GraphQL configuration is specified which doesn't specify its own `cursorShape` property. [PR #1607](https://github.com/apollographql/apollo-server/pull/1607) diff --git a/docs/source/api/apollo-server.md b/docs/source/api/apollo-server.md index 90bbea8d71f..3b39fc456f6 100644 --- a/docs/source/api/apollo-server.md +++ b/docs/source/api/apollo-server.md @@ -365,13 +365,3 @@ addMockFunctionsToSchema({ * `maskErrorDetails`: boolean Set to true to remove error details from the traces sent to Apollo's servers. Defaults to false. - -* generateClientInfo?: (o: { context: any, extensions?: Record}) => ClientInfo; - - Creates the client information that is attached to the traces sent to the - Apollo backend. The context field is the execution context passed to the - resolvers and the extensions field corresponds to the same value in the POST - body or GET parameters. `ClientInfo` contains fields for `clientName` and - `clientVersion`, which are both optional. The default generation copies the - respective fields from `extensions.clientInfo`. If `clientName` or - `clientVersion` is not present, the values are set to the empty string. diff --git a/packages/apollo-engine-reporting/src/agent.ts b/packages/apollo-engine-reporting/src/agent.ts index 6169d5115ce..c9378925f24 100644 --- a/packages/apollo-engine-reporting/src/agent.ts +++ b/packages/apollo-engine-reporting/src/agent.ts @@ -34,11 +34,6 @@ Traces.encode = function(message, originalWriter) { return writer; }; -export interface ClientInfo { - clientName?: string; - clientVersion?: string; -} - export interface EngineReportingOptions { // API key for the service. Get this from // [Engine](https://engine.apollographql.com) by logging in and creating @@ -88,14 +83,6 @@ export interface EngineReportingOptions { sendReportsImmediately?: boolean; // To remove the error message from traces, set this to true. Defaults to false maskErrorDetails?: boolean; - // Creates the client information attached to the traces sent to the Apollo - // backend - generateClientInfo?: ( - o: { - context: any; - extensions?: Record; - }, - ) => ClientInfo; // XXX Provide a way to set client_name, client_version, client_address, // service, and service_version fields. They are currently not revealed in the diff --git a/packages/apollo-engine-reporting/src/extension.ts b/packages/apollo-engine-reporting/src/extension.ts index 7f870ad1a6d..2387b3d2553 100644 --- a/packages/apollo-engine-reporting/src/extension.ts +++ b/packages/apollo-engine-reporting/src/extension.ts @@ -15,7 +15,7 @@ import { } from 'graphql-extensions'; import { Trace, google } from 'apollo-engine-reporting-protobuf'; -import { EngineReportingOptions, ClientInfo } from './agent'; +import { EngineReportingOptions } from './agent'; import { defaultSignature } from './signature'; // EngineReportingExtension is the per-request GraphQLExtension which creates a @@ -38,12 +38,6 @@ export class EngineReportingExtension operationName: string, trace: Trace, ) => void; - private generateClientInfo: ( - o: { - context: any; - extensions?: Record; - }, - ) => ClientInfo; public constructor( options: EngineReportingOptions, @@ -57,11 +51,6 @@ export class EngineReportingExtension const root = new Trace.Node(); this.trace.root = root; this.nodes.set(responsePathAsString(undefined), root); - this.generateClientInfo = - options.generateClientInfo || - // Default to using the clientInfo field of the request's extensions, when - // the ClientInfo fields are undefined, we send the empty string - (({ extensions }) => (extensions && extensions.clientInfo) || {}); } public requestDidStart(o: { @@ -71,8 +60,6 @@ export class EngineReportingExtension variables?: Record; persistedQueryHit?: boolean; persistedQueryRegister?: boolean; - context: any; - extensions?: Record; }): EndHandler { this.trace.startTime = dateToTimestamp(new Date()); this.startHrTime = process.hrtime(); @@ -167,16 +154,6 @@ export class EngineReportingExtension }); } - // While clientAddress could be a part of the protobuf, we'll ignore it for - // now, since the backend does not group by it and Engine frontend will not - // support it in the short term - const { clientName, clientVersion } = this.generateClientInfo({ - context: o.context, - extensions: o.extensions, - }); - this.trace.clientName = clientName || ''; - this.trace.clientVersion = clientVersion || ''; - return () => { this.trace.durationNs = durationHrTimeToNanos( process.hrtime(this.startHrTime), diff --git a/packages/apollo-server-core/src/runHttpQuery.ts b/packages/apollo-server-core/src/runHttpQuery.ts index e49d1a7b7ad..08964abd6aa 100644 --- a/packages/apollo-server-core/src/runHttpQuery.ts +++ b/packages/apollo-server-core/src/runHttpQuery.ts @@ -402,7 +402,6 @@ export async function runHttpQuery( : false, request: request.request, extensions: optionsObject.extensions, - queryExtensions: extensions, persistedQueryHit, persistedQueryRegister, }; diff --git a/packages/apollo-server-core/src/runQuery.ts b/packages/apollo-server-core/src/runQuery.ts index 12920ab6d61..0b33e730c4f 100644 --- a/packages/apollo-server-core/src/runQuery.ts +++ b/packages/apollo-server-core/src/runQuery.ts @@ -66,7 +66,6 @@ export interface QueryOptions { cacheControl?: boolean | CacheControlExtensionOptions; request: Pick; extensions?: Array<() => GraphQLExtension>; - queryExtensions?: Record; persistedQueryHit?: boolean; persistedQueryRegister?: boolean; } @@ -137,7 +136,6 @@ function doRunQuery(options: QueryOptions): Promise { persistedQueryHit: options.persistedQueryHit, persistedQueryRegister: options.persistedQueryRegister, context, - extensions: options.queryExtensions, }); return Promise.resolve() .then( diff --git a/packages/graphql-extensions/src/index.ts b/packages/graphql-extensions/src/index.ts index b4455109da6..b7f358f6da8 100644 --- a/packages/graphql-extensions/src/index.ts +++ b/packages/graphql-extensions/src/index.ts @@ -81,7 +81,6 @@ export class GraphQLExtensionStack { persistedQueryHit?: boolean; persistedQueryRegister?: boolean; context: TContext; - extensions?: Record; }): EndHandler { return this.handleDidStart( ext => ext.requestDidStart && ext.requestDidStart(o),