hoistgqlgenerrors

package module
v1.1.30 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 9 Imported by: 0

README

status PkgGoDev

hoist-gql-errors

hoist-gql-errors extracts GraphQL errors from the downstream response and record them as OpenTelemetry exception events.

It aims at that Datadog Error Tracking collects errors from OpenTelemetry traces.

Datadog Error Tracking needs error types, error messages, and error stacktraces on service entry spans (top-level spans).

In typical web applications, top-level spans mean spans that started on http.Handler. In addition, otelhttp.Handler will record no exceptions from downstream spans.

These facts mean that Datadog Error Tracking tracks no errors from the spans started by default setup with otelhttp.Handler.

hoist-gql-errors hoists (downstream) GraphQL errors and records them as service entry spans' errors, and then Datadog Error Tracking correctly collects them.

Synopsis

See examples on pkg.go.dev.

import (
  "net/http"

  "github.com/aereal/hoist-gql-errors"
)

func main() {
  var handler http.Handler
  var _ http.Handler = hoistgqlerrors.New()(handler)
}

Installation

go get github.com/aereal/hoist-gql-errors

License

See LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) func(http.Handler) http.Handler

New returns the middleware function that extracts GraphQL errors from downstream http.Handler.

The extracted errors are recorded span's errors.

Types

type EventOptionsBuilderFunc added in v1.1.0

type EventOptionsBuilderFunc func(req *http.Request, statusCode int, responseHeader http.Header) []trace.EventOption

type Option

type Option func(*config)

func WithEventOptions

func WithEventOptions(opts ...trace.EventOption) Option

WithEventOptions returns an Option that passes given trace.EventOption to span.RecordError().

func WithEventOptionsBuilder added in v1.1.0

func WithEventOptionsBuilder(builderFunc EventOptionsBuilderFunc) Option

WithEventOptionsBuilder return an Option that uses the function to build attributes for the error events.

func WithHTTPConventionalAttributes added in v1.1.0

func WithHTTPConventionalAttributes() Option

WithHTTPConventionalAttributes return an Option that adds the attributes conforms to HTTP semantic conventions to the error events.

Jump to

Keyboard shortcuts

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