otelgqlgen

package module
v0.0.0-...-4539625 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 8 Imported by: 0

README

otelgqlgen

OpenTelemetry instrumentation library for gqlgen

go get -u github.com/rot1024/otelgqlgen
package example

import (
  "net/http"

	"github.com/99designs/gqlgen/graphql/handler"
  "github.com/example/example/examplegql"
  "github.com/rot1024/otelgqlgen"
)

func GqlHandler() http.Handler {
	schema := examplegql.NewExecutableSchema(examplegql.New())

  srv := handler.NewDefaultServer(schema)
  srv.Use(otelgqlgen.NewTracer()) // Add

  return srv
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Tracer trace.Tracer
}

Config is used to configure the extension.

type Option

type Option func(Config) Config

Option specifies instrumentation configuration options.

func WithTracer

func WithTracer(tracer trace.Tracer) Option

WithTracer specifies a tracer to use for creating spans. If none is specified, a tracer named "github.com/rot1024/otelgqlgen" from the global provider is used.

type Tracer

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

Tracer is an extension for gqlgen to trace GrapGQL operations

func NewTracer

func NewTracer(options ...Option) Tracer

NewTracer returns a new Tracer

func (Tracer) ExtensionName

func (a Tracer) ExtensionName() string

ExtensionName implements graphql.HandlerExtension

func (Tracer) InterceptField

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

InterceptField implements graphql.FieldInterceptor

func (Tracer) InterceptResponse

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

InterceptResponse implements graphql.ResponseInterceptor

func (Tracer) Validate

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

Validate implements graphql.HandlerExtension

Jump to

Keyboard shortcuts

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