client

package
v1.8.13 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package client is the HTTP client and types for talking to a Traceway instance.

This package has no dependencies on Cobra, Viper, or any CLI machinery so that a future MCP server can import it directly.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized = errors.New("unauthorized (401)")
	ErrForbidden    = errors.New("forbidden (403)")
	ErrNotFound     = errors.New("not found (404)")
	ErrRateLimited  = errors.New("rate limited (429)")
)

Sentinel errors returned by client methods. Use errors.Is to test.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Body       string
}

APIError is returned for any non-2xx response that isn't covered by a sentinel. Inspect StatusCode and Body for diagnostics.

func (*APIError) Error

func (e *APIError) Error() string

type AiTrace added in v1.8.11

type AiTrace struct {
	Id                 uuid.UUID         `json:"id"`
	ProjectId          uuid.UUID         `json:"projectId"`
	RecordedAt         time.Time         `json:"recordedAt"`
	Duration           time.Duration     `json:"duration"`
	StatusCode         uint8             `json:"statusCode"`
	Model              string            `json:"model"`
	ResponseModel      string            `json:"responseModel"`
	Provider           string            `json:"provider"`
	Operation          string            `json:"operation"`
	InputTokens        int64             `json:"inputTokens"`
	OutputTokens       int64             `json:"outputTokens"`
	TotalTokens        int64             `json:"totalTokens"`
	CachedTokens       int64             `json:"cachedTokens"`
	ReasoningTokens    int64             `json:"reasoningTokens"`
	InputCost          float64           `json:"inputCost"`
	OutputCost         float64           `json:"outputCost"`
	TotalCost          float64           `json:"totalCost"`
	TraceName          string            `json:"traceName"`
	UserId             string            `json:"userId"`
	FinishReason       string            `json:"finishReason"`
	ServerName         string            `json:"serverName"`
	AppVersion         string            `json:"appVersion"`
	StorageKey         string            `json:"storageKey"`
	Attributes         map[string]string `json:"attributes"`
	DistributedTraceId *uuid.UUID        `json:"distributedTraceId,omitempty"`
	IsRoot             bool              `json:"isRoot"`
}

AiTrace mirrors models.AiTrace — one LLM call/operation.

type AiTraceDetailResponse added in v1.8.11

type AiTraceDetailResponse struct {
	AiTrace      *AiTrace        `json:"aiTrace"`
	Conversation json.RawMessage `json:"conversation,omitempty"`
}

AiTraceDetailResponse is the body of POST /api/ai-traces/:traceId. The conversation blob is passed through verbatim (server stores it opaquely).

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	JWT        string
	UserAgent  string
}

Client talks to a Traceway HTTP API.

func New

func New(baseURL string, opts ...Option) *Client

New returns a Client with sane defaults. The baseURL is normalized by stripping trailing slashes; do() prepends "/api/..." paths.

func (*Client) ArchiveExceptions

func (c *Client) ArchiveExceptions(ctx context.Context, projectID string, hashes []string) error

ArchiveExceptions marks the given exception hashes as archived for the project. The upstream response is just {"success": true}; on success this returns nil and the caller can report the count back to the user.

func (*Client) GetAiTrace added in v1.8.11

func (c *Client) GetAiTrace(ctx context.Context, projectID, id string, recordedAt time.Time) (*AiTraceDetailResponse, error)

GetAiTrace returns one AI trace plus its stored conversation. recordedAt is the trace's recordedAt and is required for a fast (partition-pruned) lookup.

func (*Client) GetDistributedTrace added in v1.8.11

func (c *Client) GetDistributedTrace(ctx context.Context, id string, recordedAt time.Time) (*DistributedTraceResponse, error)

GetDistributedTrace returns every node sharing a distributed trace id across all projects the user can see. The route resolves projects from the JWT, so no projectId query param is sent. recordedAt bounds the lookup to ±48h.

func (*Client) GetEndpoint added in v1.8.11

func (c *Client) GetEndpoint(ctx context.Context, projectID, id string, recordedAt time.Time) (*EndpointDetailResponse, error)

GetEndpoint returns one request (transaction) by id plus its spans and any linked exception/messages. recordedAt is the transaction's recordedAt and is required for a partition-pruned lookup; without it the server scans every daily partition of the endpoints table.

func (*Client) GetEndpointChart added in v1.8.12

func (c *Client) GetEndpointChart(ctx context.Context, projectID string, req EndpointChartRequest) (*EndpointChartResponse, error)

GetEndpointChart returns endpoint latency bucketed over time for the top endpoints, which is the curve used to pinpoint when latency changed.

func (*Client) GetException

func (c *Client) GetException(ctx context.Context, projectID, hash string, page PaginationParams) (*GetExceptionResponse, error)

GetException returns the group + paginated occurrences for the given hash.

func (*Client) GetExceptionById added in v1.8.11

func (c *Client) GetExceptionById(ctx context.Context, projectID, id string, recordedAt time.Time) (*ExceptionByIdResponse, error)

GetExceptionById returns a single exception occurrence by its id. recordedAt is the occurrence's recordedAt (from the URL's t= param, a notification's "Occurred at", or an `exceptions show` occurrence) and is required for a partition-pruned lookup.

func (*Client) GetSession added in v1.8.11

func (c *Client) GetSession(ctx context.Context, projectID, id string, startedAt time.Time) (*SessionDetailResponse, error)

GetSession returns one session plus the exceptions that fired during it. startedAt (not recordedAt) bounds the lookup — the sessions table is partitioned on started_at. Use the session's startedAt, or the recordedAt of a linked exception occurrence, which falls inside the ±24h window.

func (*Client) GetSlowEndpoint added in v1.8.12

func (c *Client) GetSlowEndpoint(ctx context.Context, projectID, endpoint string) (*SlowEndpointResponse, error)

GetSlowEndpoint returns the user-configured slow allowance for one endpoint. The offset shifts the server-side apdex/impact thresholds only; the raw p50/p95/p99 from endpoints list/chart are not adjusted by it.

func (*Client) GetTask added in v1.8.11

func (c *Client) GetTask(ctx context.Context, projectID, id string, recordedAt time.Time) (*TaskDetailResponse, error)

GetTask returns one task run plus its spans and linked exceptions/messages. recordedAt should be the task's recordedAt (from a notification, the URL's t= param, or a distributed-trace node) so the lookup prunes partitions.

func (*Client) ListEndpoints

func (c *Client) ListEndpoints(ctx context.Context, projectID string, req ListEndpointsRequest) (*ListEndpointsResponse, error)

ListEndpoints returns p50/p95/p99 stats grouped by endpoint route. We use the /grouped variant rather than the bare /endpoints (which returns one row per request).

func (*Client) ListExceptions

func (c *Client) ListExceptions(ctx context.Context, projectID string, req ListExceptionsRequest) (*ListExceptionsResponse, error)

ListExceptions returns one page of grouped exceptions for the given project.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context) ([]Project, error)

ListProjects returns all projects visible to the authenticated user. Upstream: GET /api/projects → []Project (direct array, no pagination wrapper).

func (*Client) Login

func (c *Client) Login(ctx context.Context, email, password string) (string, error)

Login exchanges an email + password for a JWT. The returned token should be stored by the caller and passed to subsequent Client constructions via WithJWT.

func (*Client) QueryLogs

func (c *Client) QueryLogs(ctx context.Context, projectID string, req QueryLogsRequest) (*QueryLogsResponse, error)

QueryLogs returns one page of log records for the given project and filters.

func (*Client) QueryMetrics

func (c *Client) QueryMetrics(ctx context.Context, projectID string, req QueryMetricsRequest) (*QueryMetricsResponse, error)

QueryMetrics runs one or more metric queries against the project.

func (*Client) UnarchiveExceptions

func (c *Client) UnarchiveExceptions(ctx context.Context, projectID string, hashes []string) error

UnarchiveExceptions reverses ArchiveExceptions for the given hashes.

type DistributedTraceNode added in v1.8.11

type DistributedTraceNode struct {
	ProjectId   uuid.UUID        `json:"projectId"`
	ProjectName string           `json:"projectName"`
	TraceType   string           `json:"traceType"`
	Endpoint    *Endpoint        `json:"endpoint,omitempty"`
	Task        *Task            `json:"task,omitempty"`
	AiTrace     *AiTrace         `json:"aiTrace,omitempty"`
	Spans       []Span           `json:"spans"`
	Exception   *LinkedException `json:"exception,omitempty"`
}

DistributedTraceNode is one resource (endpoint/task/ai-trace/exception) that participated in a distributed trace, scoped to its originating project.

type DistributedTraceResponse added in v1.8.11

type DistributedTraceResponse struct {
	DistributedTraceId string                 `json:"distributedTraceId"`
	Nodes              []DistributedTraceNode `json:"nodes"`
}

DistributedTraceResponse is the body of POST /api/distributed-traces/:id — the full cross-service request timeline, the highest-value RCA view.

type Endpoint added in v1.8.11

type Endpoint struct {
	Id                 uuid.UUID         `json:"id"`
	ProjectId          uuid.UUID         `json:"projectId"`
	Endpoint           string            `json:"endpoint"`
	Duration           time.Duration     `json:"duration"`
	RecordedAt         time.Time         `json:"recordedAt"`
	StatusCode         int16             `json:"statusCode"`
	BodySize           int32             `json:"bodySize"`
	ClientIP           string            `json:"clientIP"`
	Attributes         map[string]string `json:"attributes"`
	AppVersion         string            `json:"appVersion"`
	ServerName         string            `json:"serverName"`
	DistributedTraceId *uuid.UUID        `json:"distributedTraceId,omitempty"`
	SpanId             *uuid.UUID        `json:"spanId,omitempty"`
	IsStream           bool              `json:"isStream"`
	IsRoot             bool              `json:"isRoot"`
}

Endpoint mirrors models.Endpoint — one request (transaction), as returned by the by-id detail endpoint. EndpointStats (above) is the grouped/list shape; this is the single-row shape keyed by the transaction's id.

type EndpointChartPoint added in v1.8.12

type EndpointChartPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Endpoint  string    `json:"endpoint"`
	Value     float64   `json:"value"`
}

EndpointChartPoint is one bucket of one endpoint's series. Value is in milliseconds: total request time for total_time, the quantile for p50/p95/p99.

type EndpointChartRequest added in v1.8.12

type EndpointChartRequest struct {
	TimeRange       TimeRange `json:"-"`
	MetricType      string    `json:"metricType,omitempty"`
	IntervalMinutes int       `json:"intervalMinutes,omitempty"`
}

EndpointChartRequest is the body for POST /api/endpoints/chart. The server returns the top 5 endpoints ranked by MetricType (plus an "Other" bucket), each as a time series bucketed by IntervalMinutes, which is endpoint latency over time in a single call.

func (EndpointChartRequest) MarshalJSON added in v1.8.12

func (r EndpointChartRequest) MarshalJSON() ([]byte, error)

MarshalJSON expands TimeRange into top-level fromDate/toDate (the endpoints routes use fromDate/toDate, unlike metrics which uses from/to).

type EndpointChartResponse added in v1.8.12

type EndpointChartResponse struct {
	Endpoints []string             `json:"endpoints"` // top 5 ranked by the metric, plus "Other"
	Series    []EndpointChartPoint `json:"series"`
}

EndpointChartResponse mirrors models.EndpointStackedChartResponse.

type EndpointDetailResponse added in v1.8.11

type EndpointDetailResponse struct {
	Endpoint  *Endpoint        `json:"endpoint"`
	Spans     []Span           `json:"spans"`
	HasSpans  bool             `json:"hasSpans"`
	Exception *LinkedException `json:"exception,omitempty"`
	Messages  []LinkedMessage  `json:"messages"`
}

EndpointDetailResponse is the body of POST /api/endpoints/:endpointId.

type EndpointStats

type EndpointStats struct {
	Endpoint     string        `json:"endpoint"`
	Count        uint64        `json:"count"`
	P50Duration  time.Duration `json:"p50Duration"`
	P95Duration  time.Duration `json:"p95Duration"`
	P99Duration  time.Duration `json:"p99Duration"`
	AvgDuration  time.Duration `json:"avgDuration"`
	LastSeen     time.Time     `json:"lastSeen"`
	Impact       float64       `json:"impact"`
	ImpactReason string        `json:"impactReason"`
}

EndpointStats matches the upstream models.EndpointStats. Durations are time.Duration values which Go marshals/unmarshals as nanoseconds.

type ExceptionByIdResponse added in v1.8.11

type ExceptionByIdResponse struct {
	Exception        *ExceptionStackTrace `json:"exception"`
	SessionId        *uuid.UUID           `json:"sessionId,omitempty"`
	SessionRecording json.RawMessage      `json:"sessionRecording,omitempty"`
}

ExceptionByIdResponse is the body of POST /api/exception-stack-traces/by-id/:exceptionId. Over a paginated `exceptions show <hash>` occurrence it adds the linked sessionId and an inline sessionRecording blob (passed through verbatim), and resolves directly without walking pages.

type ExceptionGroup

type ExceptionGroup struct {
	ExceptionHash string                `json:"exceptionHash"`
	StackTrace    string                `json:"stackTrace"`
	FirstSeen     time.Time             `json:"firstSeen"`
	LastSeen      time.Time             `json:"lastSeen"`
	Count         uint64                `json:"count"`
	HourlyTrend   []ExceptionTrendPoint `json:"hourlyTrend,omitempty"`
}

ExceptionGroup matches Traceway's models.ExceptionGroup. Hourly trends are only present on list responses; on the detail endpoint they're absent.

type ExceptionStackTrace

type ExceptionStackTrace struct {
	Id                 uuid.UUID         `json:"id"`
	ExceptionHash      string            `json:"exceptionHash"`
	StackTrace         string            `json:"stackTrace"`
	RecordedAt         time.Time         `json:"recordedAt"`
	TraceId            *uuid.UUID        `json:"traceId,omitempty"`
	TraceType          string            `json:"traceType,omitempty"`
	ServerName         string            `json:"serverName,omitempty"`
	AppVersion         string            `json:"appVersion,omitempty"`
	IsMessage          bool              `json:"isMessage,omitempty"`
	Attributes         map[string]string `json:"attributes,omitempty"`
	DistributedTraceId *uuid.UUID        `json:"distributedTraceId,omitempty"`
	SessionId          *uuid.UUID        `json:"sessionId,omitempty"`
}

ExceptionStackTrace is one occurrence of a grouped exception.

type ExceptionTrendPoint

type ExceptionTrendPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Count     uint64    `json:"count"`
}

ExceptionTrendPoint is one entry in an exception's hourly trend.

type GetExceptionResponse

type GetExceptionResponse struct {
	Group       *ExceptionGroup       `json:"group"`
	Occurrences []ExceptionStackTrace `json:"occurrences"`
	Pagination  Pagination            `json:"pagination"`
}

GetExceptionResponse is the upstream ExceptionDetailResponse minus the session-recording blob (we don't expose recordings in v1).

type LinkedException added in v1.8.11

type LinkedException struct {
	ExceptionHash string `json:"exceptionHash"`
	StackTrace    string `json:"stackTrace"`
	RecordedAt    string `json:"recordedAt"`
}

LinkedException is the exception/message summary attached to endpoint, task, and distributed-trace detail responses (backend EndpointExceptionInfo). RecordedAt is a preformatted RFC3339 string, matching the server.

type LinkedMessage added in v1.8.11

type LinkedMessage struct {
	Id            uuid.UUID         `json:"id"`
	ExceptionHash string            `json:"exceptionHash"`
	StackTrace    string            `json:"stackTrace"`
	RecordedAt    string            `json:"recordedAt"`
	Attributes    map[string]string `json:"attributes,omitempty"`
}

LinkedMessage is a captured message (non-error exception) linked to an endpoint or task (backend EndpointMessageInfo).

type ListEndpointsRequest

type ListEndpointsRequest struct {
	TimeRange     TimeRange        `json:"-"`
	Pagination    PaginationParams `json:"pagination"`
	OrderBy       string           `json:"orderBy,omitempty"`
	SortDirection string           `json:"sortDirection,omitempty"`
	Search        string           `json:"search,omitempty"`
}

ListEndpointsRequest is the body for POST /api/endpoints/grouped.

func (ListEndpointsRequest) MarshalJSON

func (r ListEndpointsRequest) MarshalJSON() ([]byte, error)

MarshalJSON expands TimeRange into top-level fromDate/toDate.

type ListEndpointsResponse

type ListEndpointsResponse struct {
	Data       []EndpointStats `json:"data"`
	Pagination Pagination      `json:"pagination"`
}

ListEndpointsResponse mirrors PaginatedResponse[EndpointStats].

type ListExceptionsRequest

type ListExceptionsRequest struct {
	TimeRange       TimeRange        `json:"-"` // serialized as fromDate/toDate via MarshalJSON
	Pagination      PaginationParams `json:"pagination"`
	OrderBy         string           `json:"orderBy,omitempty"`
	Search          string           `json:"search,omitempty"`
	SearchType      string           `json:"searchType,omitempty"`
	IncludeArchived bool             `json:"includeArchived,omitempty"`
}

ListExceptionsRequest is the body for POST /api/exception-stack-traces. projectId travels as a URL query param (handled by ListExceptions), not in the body — the upstream RequireProjectAccess middleware reads it via c.Query("projectId").

func (ListExceptionsRequest) MarshalJSON

func (r ListExceptionsRequest) MarshalJSON() ([]byte, error)

MarshalJSON expands TimeRange.From / TimeRange.To into top-level fromDate / toDate so the wire shape matches Traceway's ExceptionSearchRequest.

type ListExceptionsResponse

type ListExceptionsResponse struct {
	Data       []ExceptionGroup `json:"data"`
	Pagination Pagination       `json:"pagination"`
}

ListExceptionsResponse mirrors the upstream PaginatedResponse[ExceptionGroup].

type LogRecord

type LogRecord struct {
	Id                 uuid.UUID         `json:"id"`
	Timestamp          time.Time         `json:"timestamp"`
	SeverityText       string            `json:"severityText"`
	SeverityNumber     uint8             `json:"severityNumber"`
	ServiceName        string            `json:"serviceName"`
	Body               string            `json:"body"`
	TraceId            string            `json:"traceId,omitempty"`
	SpanId             string            `json:"spanId,omitempty"`
	ResourceAttributes map[string]string `json:"resourceAttributes,omitempty"`
	ScopeName          string            `json:"scopeName,omitempty"`
	LogAttributes      map[string]string `json:"logAttributes,omitempty"`
}

LogRecord matches the upstream models.LogRecord (subset — we drop fields we don't surface in v1, like resource/scope schema URLs).

type MetricQueryItem

type MetricQueryItem struct {
	Name        string            `json:"name"`
	Aggregation string            `json:"aggregation,omitempty"`
	TagFilters  map[string]string `json:"tagFilters,omitempty"`
	GroupBy     string            `json:"groupBy,omitempty"`
}

MetricQueryItem is one query within a QueryMetricsRequest.

type MetricQueryResult

type MetricQueryResult struct {
	Name   string                       `json:"name"`
	Unit   string                       `json:"unit"`
	Series map[string][]TimeSeriesPoint `json:"series"`
}

MetricQueryResult is one query's results, optionally grouped by tag. The map key is the group label ("all" if no GroupBy was specified).

type Option

type Option func(*Client)

Option mutates a Client during construction.

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient injects a custom *http.Client (useful for tests).

func WithJWT

func WithJWT(jwt string) Option

WithJWT sets the bearer token to send on every request.

type Pagination

type Pagination struct {
	Page       int   `json:"page"`
	PageSize   int   `json:"pageSize"`
	Total      int64 `json:"total"`
	TotalPages int64 `json:"totalPages"`
}

Pagination is the response-side pagination block. Traceway returns this on every paginated list endpoint.

type PaginationParams

type PaginationParams struct {
	Page     int `json:"page"`
	PageSize int `json:"pageSize"`
}

PaginationParams is the request-side pagination control.

type Project

type Project struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Project is the minimal project shape we need today. Add fields as commands require them; do not pre-emptively mirror the entire upstream model.

type QueryLogsRequest

type QueryLogsRequest struct {
	TimeRange     TimeRange        `json:"-"`
	Pagination    PaginationParams `json:"pagination"`
	OrderBy       string           `json:"orderBy,omitempty"`
	SortDirection string           `json:"sortDirection,omitempty"`
	Search        string           `json:"search,omitempty"`
	SearchType    string           `json:"searchType,omitempty"`
	MinSeverity   uint8            `json:"minSeverity,omitempty"`
	ServiceName   string           `json:"serviceName,omitempty"`
	TraceId       string           `json:"traceId,omitempty"`
}

QueryLogsRequest is the body for POST /api/logs.

func (QueryLogsRequest) MarshalJSON

func (r QueryLogsRequest) MarshalJSON() ([]byte, error)

MarshalJSON expands TimeRange into top-level fromDate/toDate.

type QueryLogsResponse

type QueryLogsResponse struct {
	Data       []LogRecord `json:"data"`
	Pagination Pagination  `json:"pagination"`
}

QueryLogsResponse mirrors the upstream PaginatedResponse[LogRecord].

type QueryMetricsRequest

type QueryMetricsRequest struct {
	TimeRange       TimeRange         `json:"-"`
	IntervalMinutes int               `json:"intervalMinutes,omitempty"`
	Queries         []MetricQueryItem `json:"queries"`
}

QueryMetricsRequest is the body for POST /api/metrics/query.

Note: metrics uses `from`/`to` (NOT fromDate/toDate like the other endpoints) and has no pagination — results are time-bucketed via IntervalMinutes.

func (QueryMetricsRequest) MarshalJSON

func (r QueryMetricsRequest) MarshalJSON() ([]byte, error)

MarshalJSON expands TimeRange into top-level from/to (NOT fromDate/toDate).

type QueryMetricsResponse

type QueryMetricsResponse struct {
	Results []MetricQueryResult `json:"results"`
}

QueryMetricsResponse is the upstream MetricQueryResponse.

type Session added in v1.8.11

type Session struct {
	Id                 uuid.UUID         `json:"id"`
	ProjectId          uuid.UUID         `json:"projectId"`
	StartedAt          time.Time         `json:"startedAt"`
	EndedAt            *time.Time        `json:"endedAt,omitempty"`
	Duration           int64             `json:"duration"`
	ClientIP           string            `json:"clientIP"`
	Attributes         map[string]string `json:"attributes"`
	AppVersion         string            `json:"appVersion"`
	ServerName         string            `json:"serverName"`
	DistributedTraceId *uuid.UUID        `json:"distributedTraceId,omitempty"`
}

Session mirrors models.Session — one user session that can be replayed.

type SessionDetailResponse added in v1.8.11

type SessionDetailResponse struct {
	Session    *Session                 `json:"session"`
	Exceptions []SessionLinkedException `json:"exceptions"`
}

SessionDetailResponse is the body of POST /api/sessions/:sessionId.

type SessionLinkedException added in v1.8.11

type SessionLinkedException struct {
	Id            uuid.UUID `json:"id"`
	ExceptionHash string    `json:"exceptionHash"`
	StackTrace    string    `json:"stackTrace"`
	RecordedAt    string    `json:"recordedAt"`
	IsMessage     bool      `json:"isMessage"`
}

SessionLinkedException is one exception/message that fired during a session (backend SessionExceptionInfo). Unlike LinkedException it carries isMessage.

type SlowEndpointResponse added in v1.8.12

type SlowEndpointResponse struct {
	OffsetMs uint32 `json:"offsetMs"`
	Reason   string `json:"reason"`
}

SlowEndpointResponse is the body of GET /api/endpoints/slow. OffsetMs is the user-set allowance (in ms) added to the apdex and impact thresholds for this endpoint; Reason is the operator's note. An endpoint that was never marked slow returns {offsetMs:0, reason:""}, not an error.

type Span added in v1.8.11

type Span struct {
	Id           uuid.UUID         `json:"id"`
	TraceId      uuid.UUID         `json:"traceId"`
	ProjectId    uuid.UUID         `json:"projectId"`
	Name         string            `json:"name"`
	StartTime    time.Time         `json:"startTime"`
	Duration     time.Duration     `json:"duration"`
	RecordedAt   time.Time         `json:"recordedAt"`
	ParentSpanId *uuid.UUID        `json:"parentSpanId,omitempty"`
	Attributes   map[string]string `json:"attributes,omitempty"`
}

Span mirrors models.Span. Returned inside endpoint, task, and distributed trace detail responses.

type Task added in v1.8.11

type Task struct {
	Id                 uuid.UUID         `json:"id"`
	ProjectId          uuid.UUID         `json:"projectId"`
	TaskName           string            `json:"taskName"`
	Duration           time.Duration     `json:"duration"`
	RecordedAt         time.Time         `json:"recordedAt"`
	ClientIP           string            `json:"clientIP"`
	Attributes         map[string]string `json:"attributes"`
	AppVersion         string            `json:"appVersion"`
	ServerName         string            `json:"serverName"`
	DistributedTraceId *uuid.UUID        `json:"distributedTraceId,omitempty"`
	SpanId             *uuid.UUID        `json:"spanId,omitempty"`
	IsRoot             bool              `json:"isRoot"`
}

Task mirrors models.Task — one run of a background task.

type TaskDetailResponse added in v1.8.11

type TaskDetailResponse struct {
	Task      *Task            `json:"task"`
	Spans     []Span           `json:"spans"`
	HasSpans  bool             `json:"hasSpans"`
	Exception *LinkedException `json:"exception,omitempty"`
	Messages  []LinkedMessage  `json:"messages"`
}

TaskDetailResponse is the body of POST /api/tasks/:taskId.

type TimeRange

type TimeRange struct {
	From time.Time
	To   time.Time
}

TimeRange is an inclusive [From, To] interval used in resource queries. It marshals to RFC3339 strings via the request structs that embed it.

func TimeRangeFromExplicit

func TimeRangeFromExplicit(from, to time.Time) TimeRange

TimeRangeFromExplicit constructs a TimeRange from two explicit instants. Caller is responsible for ensuring From <= To.

func TimeRangeFromSince

func TimeRangeFromSince(d time.Duration) TimeRange

TimeRangeFromSince returns a TimeRange ending now and starting `d` ago. Equivalent to TimeRangeFromSinceAt(d, time.Now()).

func TimeRangeFromSinceAt

func TimeRangeFromSinceAt(d time.Duration, now time.Time) TimeRange

TimeRangeFromSinceAt is the testable form: caller supplies "now".

type TimeSeriesPoint

type TimeSeriesPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
}

TimeSeriesPoint is one data point in a metric query result.

Jump to

Keyboard shortcuts

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