splunkgraphql

package module
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

Splunk instrumentation for github.com/graph-gophers/graphql-go

module github.com/signalfx/splunk-otel-go/instrumentation/github.com/graph-gophers/graphql-go/splunkgraphql

This package provides OpenTelemetry instrumentation for the graphql package.

Getting Started

This package provides an implementation of the graphql.Tracer that can be used to trace graphql operations. See example_test.go for more information.

Documentation

Overview

Package splunkgraphql provides OpenTelemetry instrumentation for the github.com/graph-gophers/graphql-go module.

Example
package main

import (
	"net/http"

	"github.com/graph-gophers/graphql-go"
	"github.com/graph-gophers/graphql-go/relay"

	"github.com/signalfx/splunk-otel-go/instrumentation/github.com/graph-gophers/graphql-go/splunkgraphql"
)

const schema = `
	schema {
		query: Query
	}
	type Query {
		hello: String!
	}
`

type resolver struct{}

func (*resolver) Hello() string { return "Hello, world!" }

func main() {
	tracer := graphql.Tracer(splunkgraphql.NewTracer())
	s := graphql.MustParseSchema(schema, new(resolver), tracer)
	http.Handle("/query", &relay.Handler{Schema: s})

	/*
		if err := http.ListenAndServe(":8080", nil); err != nil {
			panic(err)
		}

		...
	*/
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTracer

func NewTracer(opts ...Option) tracer.Tracer

NewTracer returns a new graphql Tracer backed by OpenTelemetry.

func Version added in v1.6.0

func Version() string

Version returns the version of splunkgraphql.

Types

type Option

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

Option applies options to a configuration.

func WithAttributes

func WithAttributes(attr []attribute.KeyValue) Option

WithAttributes returns an Option that appends attr to the attributes set for every span created.

func WithTracerProvider

func WithTracerProvider(tp trace.TracerProvider) Option

WithTracerProvider returns an Option that sets the TracerProvider used for a configuration.

Directories

Path Synopsis
Package internal provides common non-exported objects to the splunkgraphql and the splunkgraphql/test modules
Package internal provides common non-exported objects to the splunkgraphql and the splunkgraphql/test modules

Jump to

Keyboard shortcuts

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