-
Notifications
You must be signed in to change notification settings - Fork 416
/
resolve.go
28 lines (23 loc) · 1.07 KB
/
resolve.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016 Datadog, Inc.
package graphqlsec
import (
"context"
"github.com/DataDog/dd-trace-go/v2/internal/appsec/dyngo"
"github.com/DataDog/dd-trace-go/v2/internal/appsec/emitter/graphqlsec/types"
"github.com/DataDog/dd-trace-go/v2/internal/appsec/trace"
)
// StartResolveOperation starts a new GraphQL Resolve operation, along with the given arguments, and
// emits a start event up in the operation stack. The operation is tracked on the returned context,
// and can be extracted later on using FromContext.
func StartResolveOperation(ctx context.Context, parent *types.ExecutionOperation, span trace.TagSetter, args types.ResolveOperationArgs) (context.Context, *types.ResolveOperation) {
op := &types.ResolveOperation{
Operation: dyngo.NewOperation(parent),
TagSetter: span,
}
newCtx := contextWithValue(ctx, op)
dyngo.StartOperation(op, args)
return newCtx, op
}