otelgqlgen

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

OpenTelemetry-Go gqlgen Instrumentation

ci Go Report Card codecov Go Reference

It is an OpenTelemetry instrumentation for Golang 99designs/gqlgen, a port from https://github.com/open-telemetry/opentelemetry-go-contrib/pull/761.

It can only instrument traces for the present.

Installation

$ go get github.com/ravilushqa/otelgqlgen

Example

See ./example.

Compatibility

This project is tested on the following systems.

OS Go Version Architecture
Ubuntu 1.17 amd64
Ubuntu 1.16 amd64
Ubuntu 1.17 386
Ubuntu 1.16 386
MacOS 1.17 amd64
MacOS 1.16 amd64
Windows 1.17 amd64
Windows 1.16 amd64
Windows 1.17 386
Windows 1.16 386

While this project should work for other systems, no compatibility guarantees are made for those systems currently.

The project follows the Release Policy to support major Go releases.

References

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOperationName

func GetOperationName(ctx context.Context) string

GetOperationName gets the operation name from the context.

func RequestComplexityLimit

func RequestComplexityLimit(complexityLimit int64) attribute.KeyValue

RequestComplexityLimit sets the complexity limit.

func RequestOperationComplexity

func RequestOperationComplexity(complexityLimit int64) attribute.KeyValue

RequestOperationComplexity sets the operation complexity.

func RequestQuery

func RequestQuery(requestQuery string) attribute.KeyValue

RequestQuery sets the request query.

func RequestVariables

func RequestVariables(requestVariables map[string]interface{}) []attribute.KeyValue

RequestVariables sets request variables.

func ResolverAlias

func ResolverAlias(resolverAlias string) attribute.KeyValue

ResolverAlias sets resolver alias.

func ResolverArgs

func ResolverArgs(argList ast.ArgumentList) []attribute.KeyValue

ResolverArgs sets resolver args.

func ResolverErrors

func ResolverErrors(errorList gqlerror.List) []attribute.KeyValue

ResolverErrors sets errors.

func ResolverField

func ResolverField(resolverField string) attribute.KeyValue

ResolverField sets resolver field.

func ResolverObject

func ResolverObject(resolverObject string) attribute.KeyValue

ResolverObject sets resolver object.

func ResolverPath

func ResolverPath(resolverPath string) attribute.KeyValue

ResolverPath sets resolver path.

func SetOperationName

func SetOperationName(ctx context.Context, name string) context.Context

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 Option

type Option interface {
	// contains filtered or unexported methods
}

Option specifies instrumentation configuration options.

func WithComplexityExtensionName

func WithComplexityExtensionName(complexityExtensionName string) Option

WithComplexityExtensionName specifies complexity extension name

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.

type Tracer

type Tracer struct {
	// contains filtered or unexported fields
}

func Middleware

func Middleware(opts ...Option) Tracer

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

func (a Tracer) ExtensionName() string

func (Tracer) InterceptField

func (a Tracer) InterceptField(ctx context.Context, next graphql.Resolver) (interface{}, error)

func (Tracer) InterceptResponse

func (a Tracer) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response

func (Tracer) Validate

func (a Tracer) Validate(_ graphql.ExecutableSchema) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL