observability

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package observability provides integration helpers for using observops with multi-agent systems and general Go applications.

This package provides utilities for:

  • HTTP client middleware for distributed tracing
  • HTTP server middleware for request instrumentation
  • Agent task instrumentation for multi-agent workflows
  • Context helpers for trace propagation

HTTP Client Middleware

Wrap your HTTP client to automatically trace outgoing requests:

client := observability.WrapHTTPClient(http.DefaultClient, provider)
resp, err := client.Get("https://api.example.com/data")

HTTP Server Middleware

Use the handler middleware for automatic request tracing:

handler := observability.HTTPMiddleware(provider)(yourHandler)
http.ListenAndServe(":8080", handler)

Agent Task Instrumentation

Instrument agent tasks for multi-agent workflows:

err := observability.ObserveTask(ctx, provider, "ProcessData",
	observability.WithAgentID("agent-1"),
	observability.WithTaskType("synthesis"),
	func(ctx context.Context) error {
		// Your task logic here
		return nil
	},
)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPMiddleware

func HTTPMiddleware(provider observops.Provider) func(http.Handler) http.Handler

HTTPMiddleware returns a middleware that instruments HTTP handlers with tracing.

func IncrementAgentCounter

func IncrementAgentCounter(ctx context.Context, provider observops.Provider, name string, agentID string, additionalAttrs ...observops.KeyValue) error

IncrementAgentCounter increments a counter with agent context.

func ObserveTask

func ObserveTask(ctx context.Context, provider observops.Provider, name string, opts []TaskOption, fn func(context.Context) error) error

ObserveTask instruments a task with tracing and metrics. It automatically creates a span for the task, records duration, and logs errors if the task fails.

func RecordAgentMetric

func RecordAgentMetric(ctx context.Context, provider observops.Provider, name string, value float64, agentID string, additionalAttrs ...observops.KeyValue) error

RecordAgentMetric records a metric with agent context.

func StartAgentSpan

func StartAgentSpan(ctx context.Context, provider observops.Provider, name string, agentID string, opts ...observops.SpanOption) (context.Context, observops.Span)

StartAgentSpan creates a new span for an agent operation. This is useful for instrumenting agent workflows without using ObserveTask.

func WrapHTTPClient

func WrapHTTPClient(client *http.Client, provider observops.Provider) *http.Client

WrapHTTPClient returns a new HTTP client that instruments outgoing requests.

Types

type TaskOption

type TaskOption func(*taskConfig)

TaskOption configures task observation.

func WithAgentID

func WithAgentID(id string) TaskOption

WithAgentID sets the agent ID for the task.

func WithTaskAttributes

func WithTaskAttributes(attrs ...observops.KeyValue) TaskOption

WithTaskAttributes sets additional span attributes.

func WithTaskMetadata

func WithTaskMetadata(metadata map[string]string) TaskOption

WithTaskMetadata sets task metadata.

func WithTaskType

func WithTaskType(taskType string) TaskOption

WithTaskType sets the task type.

Jump to

Keyboard shortcuts

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