How to use the apollo-engine-reporting-protobuf.Trace.HTTP 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 / extension.ts View on Github external
requestContext: WithRequired<
      GraphQLRequestContext,
      'metrics' | 'queryHash'
    >;
  }): EndHandler {
    this.treeBuilder.startTiming();
    o.requestContext.metrics.startHrTime = this.treeBuilder.startHrTime;

    // Generally, we'll get queryString here and not parsedQuery; we only get
    // parsedQuery if you're using an OperationStore. In normal cases we'll get
    // our documentAST in the execution callback after it is parsed.
    const queryHash = o.requestContext.queryHash;
    this.queryString = o.queryString;
    this.documentAST = o.parsedQuery;

    this.treeBuilder.trace.http = new Trace.HTTP({
      method:
        Trace.HTTP.Method[o.request.method as keyof typeof Trace.HTTP.Method] ||
        Trace.HTTP.Method.UNKNOWN,
      // Host and path are not used anywhere on the backend, so let's not bother
      // trying to parse request.url to get them, which is a potential
      // source of bugs because integrations have different behavior here.
      // On Node's HTTP module, request.url only includes the path
      // (see https://nodejs.org/api/http.html#http_message_url)
      // The same is true on Lambda (where we pass event.path)
      // But on environments like Cloudflare we do get a complete URL.
      host: null,
      path: null,
    });

    if (this.options.sendHeaders) {
      makeHTTPRequestHeaders(