dd-trace
    Preparing search index...

    Interface graphql

    This plugin automatically instruments the graphql module.

    It also instruments mercurius (the Fastify GraphQL adapter): every request through app.graphql / reply.graphql opens a top-level graphql.request span that parents the graphql.parse/graphql.validate/graphql.execute spans and carries the request text. This span is produced even when mercurius serves the query from its JIT-compiled path, where graphql.execute does not run.

    The graphql integration uses the operation name as the span resource name. If no operation name is set, the resource name will always be just query, mutation or subscription.

    For example:

    # good, the resource name will be `query HelloWorld`
    query HelloWorld {
      hello
      world
    }
    
    # bad, the resource name will be `query`
    {
      hello
      world
    }
    
    interface graphql {
        collapse?: boolean;
        depth?: number;
        enabled?: boolean;
        errorExtensions?: string[];
        hooks?: {
            execute?: (span?: Span, args?: ExecutionArgs, res?: any) => void;
            parse?: (span?: Span, source?: any, document?: any) => void;
            resolve?: (span?: Span, field?: FieldContext) => void;
            validate?: (span?: Span, document?: any, errors?: any) => void;
        };
        measured?: boolean
        | { [key: string]: boolean };
        service?: any;
        signature?: boolean;
        source?: boolean;
        variables?:
            | string[]
            | ((variables: { [key: string]: any }) => { [key: string]: any });
    }
    Index

    Properties

    collapse?: boolean

    Whether to collapse list items into a single element. (i.e. single users.*.name span instead of users.0.name, users.1.name, etc)

    true
    

    DD_TRACE_GRAPHQL_COLLAPSE

    depth?: number

    The maximum depth of fields/resolvers to instrument. Set to 0 to only instrument the operation or to -1 to instrument all fields/resolvers. Counts selection-set nesting (named fields) only; list indices do not count toward the limit, regardless of collapse.

    -1
    

    DD_TRACE_GRAPHQL_DEPTH

    enabled?: boolean

    Whether to enable the plugin.

    true
    
    errorExtensions?: string[]

    An array of error extensions keys to attach to the span error event for each GraphQL error.

    DD_TRACE_GRAPHQL_ERROR_EXTENSIONS

    hooks?: {
        execute?: (span?: Span, args?: ExecutionArgs, res?: any) => void;
        parse?: (span?: Span, source?: any, document?: any) => void;
        resolve?: (span?: Span, field?: FieldContext) => void;
        validate?: (span?: Span, document?: any, errors?: any) => void;
    }

    An object of optional callbacks to be executed during the respective phase of a GraphQL operation. Undefined callbacks default to a noop function.

    {}
    
    measured?: boolean | { [key: string]: boolean }

    Whether to measure the span. Can also be set to a key-value pair with span names as keys and booleans as values for more granular control.

    service?: any

    The service name to be used for this plugin.

    signature?: boolean

    Whether to enable signature calculation for the resource name. This can be disabled if your GraphQL operations always have a name. Note that when disabled all queries will need to be named for this to work properly.

    true
    
    source?: boolean

    Whether to include the source of the operation within the query as a tag on every span. This may contain sensitive information and should only be enabled if sensitive data is always sent as variables and not in the query text.

    false
    
    variables?:
        | string[]
        | ((variables: { [key: string]: any }) => { [key: string]: any })

    An array of variable names to record. Can also be a callback that returns the key/value pairs to record. For example, using variables => variables would record all variables. The environment variable only accepts the array form (comma-separated variable names).

    DD_TRACE_GRAPHQL_VARIABLES