import { GraphQLError } from 'graphql';
import { Plugin, YogaInitialContext } from 'graphql-yoga';
import { google, Trace } from '@apollo/usage-reporting-protobuf';
export interface ApolloInlineRequestTraceContext {
    startHrTime: [number, number];
    traceStartTimestamp: google.protobuf.Timestamp;
    traces: Map<YogaInitialContext, ApolloInlineGraphqlTraceContext>;
    /**
     * graphql-js can continue to execute more fields indefinitely after
     * `execute()` resolves. That's because parallelism on a selection set
     * is implemented using `Promise.all`, and as soon as one field
     * throws an error, the combined Promise resolves, but there's no
     * "cancellation" of the rest of Promises/fields in `Promise.all`.
     */
    stopped: boolean;
}
export interface ApolloInlineGraphqlTraceContext {
    rootNode: Trace.Node;
    trace: Trace;
    nodes: Map<string, Trace.Node>;
}
export interface ApolloInlineTracePluginOptions {
    /**
     * Format errors before being sent for tracing. Beware that only the error
     * `message` and `extensions` can be changed.
     *
     * Return `null` to skip reporting error.
     */
    rewriteError?: (err: GraphQLError) => GraphQLError | null;
    /**
     * Allows to entirely disable tracing based on the HTTP request
     * @param request HTTP request from the execution context
     * @returns If true is returned (either as is or wrapped in Promise), traces for this request will
     *          not be generated.
     */
    ignoreRequest?: (request: Request) => Promise<boolean> | boolean;
}
/**
 * Produces Apollo's base64 trace protocol containing timing, resolution and
 * errors information.
 *
 * The output is placed in `extensions.ftv1` of the GraphQL result.
 *
 * The Apollo Gateway utilizes this data to construct the full trace and submit
 * it to Apollo's usage reporting ingress.
 */
export declare function useApolloInlineTrace(options?: ApolloInlineTracePluginOptions): Plugin<YogaInitialContext>;
/**
 * Instrument GraphQL request processing pipeline and creates Apollo compatible tracing data.
 *
 * This is meant as a helper, do not use it directly. Use `useApolloInlineTrace` or `useApolloUsageReport` instead.
 * @param options
 * @returns A tuple with the instrumentation plugin and a WeakMap containing the tracing data
 */
export declare function useApolloInstrumentation(options: ApolloInlineTracePluginOptions): readonly [Plugin, WeakMap<Request, ApolloInlineRequestTraceContext>];
