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 6152862
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/source/api/apollo-server.md
Original file line number Diff line number Diff line change
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.
4 changes: 2 additions & 2 deletions packages/apollo-engine-reporting/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export interface EngineReportingOptions {
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
maskErrorDetails?: 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
Original file line number Diff line number Diff line change
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 6152862

Please sign in to comment.