Documentation
¶
Overview ¶
Package otelgqlgen instruments the github.com/99designs/gqlgen package.
Currently only the routing of a received message can be instrumented. To do it, use the Middleware function.
Index ¶
- func GetOperationName(ctx context.Context) string
- func RequestComplexityLimit(complexityLimit int64) attribute.KeyValue
- func RequestOperationComplexity(complexityLimit int64) attribute.KeyValue
- func RequestQuery(requestQuery string) attribute.KeyValue
- func RequestVariables(requestVariables map[string]interface{}) []attribute.KeyValue
- func ResolverAlias(resolverAlias string) attribute.KeyValue
- func ResolverArgs(argList ast.ArgumentList) []attribute.KeyValue
- func ResolverErrors(errorList gqlerror.List) []attribute.KeyValue
- func ResolverField(resolverField string) attribute.KeyValue
- func ResolverObject(resolverObject string) attribute.KeyValue
- func ResolverPath(resolverPath string) attribute.KeyValue
- func SetOperationName(ctx context.Context, name string) context.Context
- type FieldsPredicateFunc
- type InterceptFieldsResultHandlerFunc
- type InterceptResponseResultHandlerFunc
- type Option
- func WithComplexityExtensionName(complexityExtensionName string) Option
- func WithCreateSpanFromFields(predicate FieldsPredicateFunc) Option
- func WithInterceptFieldsResultHandlerFunc(handler InterceptFieldsResultHandlerFunc) Option
- func WithInterceptResponseResultHandlerFunc(handler InterceptResponseResultHandlerFunc) Option
- func WithRequestVariablesAttributesBuilder(builder RequestVariablesBuilderFunc) Option
- func WithSpanKindSelector(spanKindSelector SpanKindSelectorFunc) Option
- func WithTracerProvider(provider trace.TracerProvider) Option
- func WithoutVariables() Option
- type RequestVariablesBuilderFunc
- type SpanKindSelectorFunc
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOperationName ¶ added in v0.4.1
GetOperationName gets the operation name from the context.
func RequestComplexityLimit ¶
RequestComplexityLimit sets the complexity limit.
func RequestOperationComplexity ¶
RequestOperationComplexity sets the operation complexity.
func RequestQuery ¶
RequestQuery sets the request query.
func RequestVariables ¶
RequestVariables sets request variables.
func ResolverAlias ¶
ResolverAlias sets resolver alias.
func ResolverArgs ¶
func ResolverArgs(argList ast.ArgumentList) []attribute.KeyValue
ResolverArgs sets resolver args.
func ResolverErrors ¶
ResolverErrors sets errors.
func ResolverField ¶
ResolverField sets resolver field.
func ResolverObject ¶
ResolverObject sets resolver object.
func ResolverPath ¶
ResolverPath sets resolver path.
func SetOperationName ¶ added in v0.4.1
SetOperationName adds the operation name to the context so that the interceptors can use it. It will replace the operation name if it already exists in the context. example:
ctx = otelgqlgen.SetOperationName(r.Context(), "my-operation") r = r.WithContext(ctx)
Types ¶
type FieldsPredicateFunc ¶ added in v0.11.0
type FieldsPredicateFunc func(ctx *graphql.FieldContext) bool
type InterceptFieldsResultHandlerFunc ¶ added in v0.19.0
type InterceptFieldsResultHandlerFunc func(resp interface{}, respErr error, fieldErrList gqlerror.List, span trace.Span) (interface{}, error)
InterceptFieldsResultHandlerFunc is the signature of the function used to intercept and handle GraphQL field-level results and errors during execution.
type InterceptResponseResultHandlerFunc ¶ added in v0.19.0
type InterceptResponseResultHandlerFunc func(resp *graphql.Response, span trace.Span) *graphql.Response
InterceptResponseResultHandlerFunc is the signature of the function used to intercept and handle GraphQL response results before they are returned.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option specifies instrumentation configuration options.
func WithComplexityExtensionName ¶
WithComplexityExtensionName specifies complexity extension name.
func WithCreateSpanFromFields ¶ added in v0.11.0
func WithCreateSpanFromFields(predicate FieldsPredicateFunc) Option
WithCreateSpanFromFields allows specifying a custom function to handle the creation or not of spans regarding the GraphQL context fields.
func WithInterceptFieldsResultHandlerFunc ¶ added in v0.19.0
func WithInterceptFieldsResultHandlerFunc(handler InterceptFieldsResultHandlerFunc) Option
WithInterceptFieldsResultHandlerFunc allows specifying a custom function to intercept and handle GraphQL field-level results and errors during execution.
func WithInterceptResponseResultHandlerFunc ¶ added in v0.19.0
func WithInterceptResponseResultHandlerFunc(handler InterceptResponseResultHandlerFunc) Option
WithInterceptResponseResultHandlerFunc allows specifying a custom function to intercept and handle GraphQL response results before they are returned.
func WithRequestVariablesAttributesBuilder ¶ added in v0.8.0
func WithRequestVariablesAttributesBuilder(builder RequestVariablesBuilderFunc) Option
WithRequestVariablesAttributesBuilder allows specifying a custom function to handle the building of the attributes for the variables.
func WithSpanKindSelector ¶ added in v0.17.0
func WithSpanKindSelector(spanKindSelector SpanKindSelectorFunc) Option
WithSpanKindSelector allows specifying a custom function that defines the SpanKind based on the name of the operation.
func WithTracerProvider ¶
func WithTracerProvider(provider trace.TracerProvider) Option
WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.
func WithoutVariables ¶ added in v0.8.0
func WithoutVariables() Option
WithoutVariables allows disabling the variables attributes.
type RequestVariablesBuilderFunc ¶ added in v0.8.0
RequestVariablesBuilderFunc is the signature of the function used to build the request variables attributes.
type SpanKindSelectorFunc ¶ added in v0.17.0
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer is a GraphQL extension that traces GraphQL requests.
func Middleware ¶
Middleware sets up a handler to start tracing the incoming requests. The service parameter should describe the name of the (virtual) server handling the request. extension parameter may be empty string.
func (Tracer) ExtensionName ¶
ExtensionName returns the extension name.
func (Tracer) InterceptField ¶
InterceptField intercepts the incoming request.