otelhttpserver

package
v0.0.0-...-8c16a7d Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAttrsFromReq

func ExtractAttrsFromReq(r *http.Request) []attribute.KeyValue

ExtractAttrsFromReq extracts OTEL attributes from the request. NOTE: In order to simplify the impl, we are assuming that the request is non-nil and always used with go-chi.

func SpanPostProcessing

func SpanPostProcessing(ctx context.Context, rww *ResponseWriterWrapper, rbw *RequestBodyWrapper)

SpanPostProcessing adds post-processing attributes to the span

func StartSpan

func StartSpan(r *http.Request, attrs []attribute.KeyValue) (ctx context.Context, end func(error))

StartSpan starts the http server request processing span. NOTE: For simplicity, we are assuming that the request will always be used with go-chi.

Types

type Measure

type Measure struct {
	// contains filtered or unexported fields
}

Measure measures server's inbound HTTP call performance

func NewMeasure

func NewMeasure() (*Measure, error)

NewMeasure returns a new instance of Measure

func (*Measure) MeasurePostProcessing

func (m *Measure) MeasurePostProcessing(
	ctx context.Context,
	rww *ResponseWriterWrapper,
	rbw *RequestBodyWrapper,
	elapsedTime time.Duration,
	attrs []attribute.KeyValue,
)

MeasurePostProcessing records post processing metrics TODO: Why does this have to be a pointer?

func (*Measure) MeasurePreProcessing

func (m *Measure) MeasurePreProcessing(ctx context.Context, attrs []attribute.KeyValue)

MeasurePreProcessing records pre processing metrics TODO: Why does this have to be a pointer?

type RequestBodyWrapper

type RequestBodyWrapper struct {
	io.ReadCloser

	Ctx context.Context
	// contains filtered or unexported fields
}

func (*RequestBodyWrapper) Read

func (w *RequestBodyWrapper) Read(b []byte) (int, error)

type ResponseWriterWrapper

type ResponseWriterWrapper struct {
	http.ResponseWriter

	Ctx context.Context
	// contains filtered or unexported fields
}

ResponseWriterWrapper is a wrapper around http.ResponseWriter to help with OTEL instrumentation

func (*ResponseWriterWrapper) Write

func (w *ResponseWriterWrapper) Write(p []byte) (int, error)

Write satisfies the interface and records the status code

func (*ResponseWriterWrapper) WriteHeader

func (w *ResponseWriterWrapper) WriteHeader(statusCode int)

WriteHeader satisfies the interface and records the status code

Jump to

Keyboard shortcuts

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