nrgraphgophers

package module
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

v3/integrations/nrgraphgophers GoDoc

Package nrgraphgophers instruments https://github.com/graph-gophers/graphql-go applications.

import "github.com/newrelic/go-agent/v3/integrations/nrgraphgophers"

For more information, see godocs.

Documentation

Overview

Package nrgraphgophers instruments https://github.com/graph-gophers/graphql-go applications.

This package creates a graphql-go Tracer that adds adds segment instrumentation to your graphql request transactions.

Example
package main

import (
	"log"
	"net/http"
	"os"

	graphql "github.com/graph-gophers/graphql-go"
	"github.com/graph-gophers/graphql-go/relay"
	"github.com/newrelic/go-agent/v3/integrations/nrgraphgophers"
	"github.com/newrelic/go-agent/v3/newrelic"
)

type query struct{}

func (*query) Hello() string { return "hello world" }

func main() {
	// First create your New Relic Application:
	app, err := newrelic.NewApplication(
		newrelic.ConfigAppName("GraphQL App"),
		newrelic.ConfigLicense(os.Getenv("NEW_RELIC_LICENSE_KEY")),
		newrelic.ConfigDebugLogger(os.Stdout),
	)
	if nil != err {
		panic(err)
	}

	querySchema := `type Query { hello: String! }`

	// Then add a graphql.Tracer(nrgraphgophers.NewTracer()) option to your
	// schema parsing to get field and query segment instrumentation:
	opt := graphql.Tracer(nrgraphgophers.NewTracer())
	schema := graphql.MustParseSchema(querySchema, &query{}, opt)

	// Finally, instrument your request handler using newrelic.WrapHandle
	// to create transactions for requests:
	http.Handle(newrelic.WrapHandle(app, "/", &relay.Handler{Schema: schema}))
	log.Fatal(http.ListenAndServe(":8000", nil))
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTracer

func NewTracer() trace.Tracer

NewTracer creates a new trace.Tracer that adds segment instrumentation to the transaction.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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