How to use the apollo-engine-reporting-protobuf.ReportHeader function in apollo-engine-reporting-protobuf

To help you get started, we’ve selected a few apollo-engine-reporting-protobuf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apollographql / apollo-server / packages / apollo-engine-reporting / src / agent.ts View on Github external
public async addTrace({
    trace,
    queryHash,
    documentAST,
    operationName,
    queryString,
    schemaHash,
  }: AddTraceArgs): Promise {
    // Ignore traces that come in after stop().
    if (this.stopped) {
      return;
    }

    if (!(schemaHash in this.reports)) {
      this.reportHeaders[schemaHash] = new ReportHeader({
        ...serviceHeaderDefaults,
        schemaHash,
        schemaTag:
          this.options.schemaTag || process.env.ENGINE_SCHEMA_TAG || '',
      });
      // initializes this.reports[reportHash]
      this.resetReport(schemaHash);
    }
    const report = this.reports[schemaHash];

    const protobufError = Trace.verify(trace);
    if (protobufError) {
      throw new Error(`Error encoding trace: ${protobufError}`);
    }
    const encodedTrace = Trace.encode(trace).finish();