observe

package
v0.0.0-...-210767f Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package observe provides metric and tracing support for Go servers. It uses OpenTelemetry and the golang.org/x/exp/events package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Observer

type Observer struct {

	// LogHandlerFunc is invoked in [Observer.Observe] to obtain an
	// [event.Handler] for logging to be added to the [event.Exporter] in
	// addition to the tracing and metrics handlers.
	LogHandlerFunc func(*http.Request) event.Handler
	// contains filtered or unexported fields
}

An Observer handles tracing and metrics exporting.

func NewObserver

func NewObserver(ctx context.Context, projectID, serverName string) (_ *Observer, err error)

NewObserver creates an Observer. The context is used to flush traces in AfterRequest, so it should be longer-lived than any request context. (We don't want to use the request context because we still want traces even if it is canceled or times out.)

func (*Observer) Observe

func (o *Observer) Observe(h http.Handler) http.Handler

Observe adds metrics and tracing to an http.Handler.

Jump to

Keyboard shortcuts

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