internal

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package internal provides shared middleware functionality for OpenTelemetry tracers.

Package internal provides shared utilities for OpenTelemetry middleware tracers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(getMiddlewareTracer TracerRouter, log logger.Logger) func(*http.Request, NextMiddleware) (*http.Response, error)

Middleware creates a shared OpenTelemetry middleware that uses the provided router to determine which tracer to use for each endpoint. An optional logger can be provided for debug and error logging. If nil, logging is disabled.

func SetJSONAttr

func SetJSONAttr(span trace.Span, key string, value any) error

SetJSONAttr is a helper function to set JSON attributes on spans

func ToInt64

func ToInt64(v any) (bool, int64)

ToInt64 converts various numeric types to int64

Types

type BufferedReader

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

BufferedReader saves data read from the readCloser and triggers an action when fully read or closed.

func NewBufferedReader

func NewBufferedReader(src io.ReadCloser, onDone func(io.Reader)) *BufferedReader

NewBufferedReader creates a new buffered reader that calls onDone when fully read or closed.

func (*BufferedReader) Close

func (r *BufferedReader) Close() error

Close closes the underlying reader and triggers the onDone callback.

func (*BufferedReader) Read

func (r *BufferedReader) Read(p []byte) (int, error)

type MiddlewareTracer

type MiddlewareTracer interface {
	StartSpan(ctx context.Context, start time.Time, request io.Reader) (context.Context, trace.Span, error)
	TagSpan(span trace.Span, response io.Reader) error
}

MiddlewareTracer adds tracing to API requests by parsing bodies of the request and response.

type NextMiddleware

type NextMiddleware = func(req *http.Request) (*http.Response, error)

NextMiddleware represents the next middleware to run in the client middleware chain.

type TracerRouter

type TracerRouter func(path string) MiddlewareTracer

TracerRouter maps URL paths to specific tracers for different endpoints.

Jump to

Keyboard shortcuts

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