otelgqlgen

package module
v0.0.0-...-1e8fc56 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 9 Imported by: 0

README

OpenTelemetry gqlgen godoc

A gqlgen plugin for instrumenting operations with OpenTelemetry.

Usage

Use this package as a gqlg plugin, preferably the very first one so all the underlying ones are counted towards time spent as well.

import (
	"github.com/dmathieu/otelgqlgen"
	"github.com/99designs/gqlgen/graphql/handler"
)

handler := handler.NewDefaultServer(...)
handler.Use(otelgqlgen.New())

Documentation

Overview

Example
package main

import (
	"log"
	"net/http"

	"github.com/99designs/gqlgen/graphql"
	"github.com/99designs/gqlgen/graphql/handler"
	"github.com/dmathieu/otelgqlgen"
)

var es graphql.ExecutableSchema

func main() {
	srv := handler.NewDefaultServer(es)
	srv.Use(otelgqlgen.New())

	http.Handle("/query", srv)

	if err := http.ListenAndServe(":8080", nil); err != nil {
		log.Fatal(err)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func SemVersion

func SemVersion() string

SemVersion is the semantic version to be supplied to tracer/meter creation.

func Version

func Version() string

Version is the current release version of the gqlgen instrumentation.

Types

type Handler

Handler is the interface for our middleware

func New

func New(opts ...Option) Handler

New builds a new handler

type Option

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

Option interface used for setting optional config properties.

func WithComplexityExtensionName

func WithComplexityExtensionName(name string) Option

WithComplexityExtensionName allows passing a custom complexity extension name If none is specified, `ComplexityLimit` will be used.

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.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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