traces

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClickHouseConn

func NewClickHouseConn(cfg *ClickHouseConfig) (driver.Conn, error)

NewClickHouseConn creates a new ClickHouse connection using HTTP protocol

Types

type ClickHouseConfig

type ClickHouseConfig struct {
	Host     string
	Port     int
	Database string
	Username string
	Password string
	UseTLS   bool
}

ClickHouseConfig holds ClickHouse connection configuration

type EndpointStats

type EndpointStats struct {
	ServiceName string  `json:"service_name"`
	SpanName    string  `json:"span_name"`
	CallCount   uint64  `json:"call_count"`
	ErrorCount  uint64  `json:"error_count"`
	ErrorRate   float64 `json:"error_rate"`
	AvgDuration float64 `json:"avg_duration_ms"`
	P50Duration float64 `json:"p50_duration_ms"`
	P95Duration float64 `json:"p95_duration_ms"`
	P99Duration float64 `json:"p99_duration_ms"`
}

EndpointStats represents aggregated statistics for an endpoint

type ServiceStats

type ServiceStats struct {
	ServiceName string  `json:"service_name"`
	SpanCount   uint64  `json:"span_count"`
	ErrorCount  uint64  `json:"error_count"`
	ErrorRate   float64 `json:"error_rate"`
	AvgDuration float64 `json:"avg_duration_ms"`
	MaxDuration float64 `json:"max_duration_ms"`
	MinDuration float64 `json:"min_duration_ms"`
	P50Duration float64 `json:"p50_duration_ms"`
	P95Duration float64 `json:"p95_duration_ms"`
	P99Duration float64 `json:"p99_duration_ms"`
}

ServiceStats represents aggregated statistics for a service

type Span

type Span struct {
	TraceID            string            `json:"trace_id"`
	SpanID             string            `json:"span_id"`
	ParentSpanID       string            `json:"parent_span_id,omitempty"`
	Name               string            `json:"name"`
	Kind               string            `json:"kind"`
	ServiceName        string            `json:"service_name"`
	Duration           float64           `json:"duration_ms"`
	StartTime          time.Time         `json:"start_time"`
	EndTime            time.Time         `json:"end_time"`
	StatusCode         string            `json:"status_code"`
	StatusMessage      string            `json:"status_message,omitempty"`
	Attributes         map[string]string `json:"attributes,omitempty"`
	ResourceAttributes map[string]string `json:"resource_attributes,omitempty"`
	Events             []SpanEvent       `json:"events,omitempty"`
	Children           []Span            `json:"children,omitempty"`
}

Span represents a single span within a trace

type SpanEvent

type SpanEvent struct {
	Timestamp  time.Time         `json:"timestamp"`
	Name       string            `json:"name"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

SpanEvent represents an event within a span

type Trace

type Trace struct {
	TraceID    string    `json:"trace_id"`
	RootSpan   *Span     `json:"root_span,omitempty"`
	Spans      []Span    `json:"spans"`
	SpanCount  int       `json:"span_count"`
	Duration   float64   `json:"duration_ms"`
	StartTime  time.Time `json:"start_time"`
	EndTime    time.Time `json:"end_time"`
	Services   []string  `json:"services"`
	HasErrors  bool      `json:"has_errors"`
	ErrorCount int       `json:"error_count"`
}

Trace represents a complete trace with all its spans

type TraceListItem

type TraceListItem struct {
	TraceID      string    `json:"trace_id"`
	RootSpanName string    `json:"root_span_name"`
	ServiceName  string    `json:"service_name"`
	Duration     float64   `json:"duration_ms"`
	SpanCount    uint64    `json:"span_count"`
	StartTime    time.Time `json:"start_time"`
	HasErrors    bool      `json:"has_errors"`
	ErrorCount   uint64    `json:"error_count"`
}

TraceListItem is a summary view of a trace for listing

type TraceQueryParams

type TraceQueryParams struct {
	ServiceName string    `json:"service_name,omitempty"`
	SpanName    string    `json:"span_name,omitempty"`
	TraceID     string    `json:"trace_id,omitempty"`
	MinDuration *float64  `json:"min_duration_ms,omitempty"`
	MaxDuration *float64  `json:"max_duration_ms,omitempty"`
	HasErrors   *bool     `json:"has_errors,omitempty"`
	StartTime   time.Time `json:"start_time"`
	EndTime     time.Time `json:"end_time"`
	Limit       int       `json:"limit"`
	Offset      int       `json:"offset"`
}

TraceQueryParams holds query parameters for trace search

type TracesService

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

TracesService provides methods to query trace data from ClickHouse

func NewTracesService

func NewTracesService(conn driver.Conn) *TracesService

NewTracesService creates a new TracesService

func (*TracesService) GetEndpointStats

func (s *TracesService) GetEndpointStats(ctx context.Context, serviceName string, startTime, endTime time.Time) ([]EndpointStats, error)

GetEndpointStats returns aggregated statistics for endpoints

func (*TracesService) GetServiceStats

func (s *TracesService) GetServiceStats(ctx context.Context, startTime, endTime time.Time) ([]ServiceStats, error)

GetServiceStats returns aggregated statistics for services

func (*TracesService) GetServices

func (s *TracesService) GetServices(ctx context.Context) ([]string, error)

GetServices returns a list of unique service names

func (*TracesService) GetTrace

func (s *TracesService) GetTrace(ctx context.Context, traceID string) (*Trace, error)

GetTrace returns a complete trace with all spans organized hierarchically

func (*TracesService) ListTraces

func (s *TracesService) ListTraces(ctx context.Context, params *TraceQueryParams) ([]TraceListItem, int64, error)

ListTraces returns a paginated list of traces

Jump to

Keyboard shortcuts

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