Skip to content

Commit

Permalink
[Squash] Address feedback
Browse files Browse the repository at this point in the history
Note that the Engine proxy strips all error information from the traces
with noErrorTraces set. To get errors to show up in the ui, the proxy
sends error counts inside of the aggregated stats reports. To get
similar behavior inside of the apollo server metrics reporting, we
always send a trace and mask out the PII.
  • Loading branch information
Evans Hauser committed Sep 4, 2018
1 parent 8e30c45 commit 4f45d9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/source/api/apollo-server.md
Expand Up @@ -345,6 +345,6 @@ addMockFunctionsToSchema({
'sendReport()' on other signals if you'd like. Note that 'sendReport()'
does not run synchronously so it cannot work usefully in an 'exit' handler.

* `sendErrorTraces`: boolean
* `maskErrorDetails`: boolean

To remove errors from traces, set this to false. Defaults to true
Set to true to remove error details from the traces sent to Apollo's servers. Defaults to false.
6 changes: 3 additions & 3 deletions packages/apollo-engine-reporting/src/agent.ts
Expand Up @@ -75,14 +75,14 @@ export interface EngineReportingOptions {
privateHeaders?: Array<String> | boolean;
// By default, EngineReportingAgent listens for the 'SIGINT' and 'SIGTERM'
// signals, stops, sends a final report, and re-sends the signal to
// itself. Set this to false to disable. You can manually invoke 'stop()' and
// itself. Set tnis to false to disable. You can manually invoke 'stop()' and
// 'sendReport()' on other signals if you'd like. Note that 'sendReport()'
// does not run synchronously so it cannot work usefully in an 'exit' handler.
handleSignals?: boolean;
// Sends the trace report immediately. This options is useful for stateless environments
sendReportsImmediately?: boolean;
// To remove errors from traces, set this to false. Defaults to true
sendErrorTraces?: boolean;
// To remove the error message from traces, set this to true. Defaults to false
maskeErrorDetails?: boolean;

// XXX Provide a way to set client_name, client_version, client_address,
// service, and service_version fields. They are currently not revealed in the
Expand Down
15 changes: 6 additions & 9 deletions packages/apollo-engine-reporting/src/extension.ts
Expand Up @@ -44,7 +44,7 @@ export class EngineReportingExtension<TContext = any>
addTrace: (signature: string, operationName: string, trace: Trace) => void,
) {
this.options = {
sendErrorTraces: true,
maskErrorDetails: false,
...options,
};
this.addTrace = addTrace;
Expand Down Expand Up @@ -229,19 +229,16 @@ export class EngineReportingExtension<TContext = any>
}
}

// With noErrorTraces, the Engine proxy strips all error information
// from the traces and sends error counts inside of the aggregated stats
// reports. To get similar behavior inside of the apollo server metrics
// reporting, we always send a trace and mask out the PII
const errorInfo = this.options.sendErrorTraces
? {
// Always send the trace errors, so that the UI acknowledges that there is an error.
const errorInfo = this.options.maskErrorDetails
? { message: '<masked>' }
: {
message: error.message,
location: (error.locations || []).map(
({ line, column }) => new Trace.Location({ line, column }),
),
json: JSON.stringify(error),
}
: { message: 'Masked by Apollo Engine Reporting' };
};

node!.error!.push(new Trace.Error(errorInfo));
});
Expand Down

0 comments on commit 4f45d9f

Please sign in to comment.