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 ¶
- Variables
- type APIError
- type AiTrace
- type AiTraceDetailResponse
- type Client
- func (c *Client) ArchiveExceptions(ctx context.Context, projectID string, hashes []string) error
- func (c *Client) DeviceAuthorize(ctx context.Context, clientID string) (*DeviceAuth, error)
- func (c *Client) GetAiTrace(ctx context.Context, projectID, id string, recordedAt time.Time) (*AiTraceDetailResponse, error)
- func (c *Client) GetDistributedTrace(ctx context.Context, id string, recordedAt time.Time) (*DistributedTraceResponse, error)
- func (c *Client) GetEndpoint(ctx context.Context, projectID, id string, recordedAt time.Time) (*EndpointDetailResponse, error)
- func (c *Client) GetEndpointChart(ctx context.Context, projectID string, req EndpointChartRequest) (*EndpointChartResponse, error)
- func (c *Client) GetException(ctx context.Context, projectID, hash string, page PaginationParams) (*GetExceptionResponse, error)
- func (c *Client) GetExceptionById(ctx context.Context, projectID, id string, recordedAt time.Time) (*ExceptionByIdResponse, error)
- func (c *Client) GetSession(ctx context.Context, projectID, id string, startedAt time.Time) (*SessionDetailResponse, error)
- func (c *Client) GetSlowEndpoint(ctx context.Context, projectID, endpoint string) (*SlowEndpointResponse, error)
- func (c *Client) GetTask(ctx context.Context, projectID, id string, recordedAt time.Time) (*TaskDetailResponse, error)
- func (c *Client) ListEndpoints(ctx context.Context, projectID string, req ListEndpointsRequest) (*ListEndpointsResponse, error)
- func (c *Client) ListExceptions(ctx context.Context, projectID string, req ListExceptionsRequest) (*ListExceptionsResponse, error)
- func (c *Client) ListProjects(ctx context.Context) ([]Project, error)
- func (c *Client) Login(ctx context.Context, email, password string) (string, error)
- func (c *Client) Logout(ctx context.Context, refreshToken string) error
- func (c *Client) PollDeviceToken(ctx context.Context, deviceCode string) (*TokenSet, error)
- func (c *Client) QueryLogs(ctx context.Context, projectID string, req QueryLogsRequest) (*QueryLogsResponse, error)
- func (c *Client) QueryMetrics(ctx context.Context, projectID string, req QueryMetricsRequest) (*QueryMetricsResponse, error)
- func (c *Client) Refresh(ctx context.Context, refreshToken string) (*TokenSet, error)
- func (c *Client) UnarchiveExceptions(ctx context.Context, projectID string, hashes []string) error
- func (c *Client) WithBearer(token string) *Client
- type DeviceAuth
- type DistributedTraceNode
- type DistributedTraceResponse
- type Endpoint
- type EndpointChartPoint
- type EndpointChartRequest
- type EndpointChartResponse
- type EndpointDetailResponse
- type EndpointStats
- type ExceptionByIdResponse
- type ExceptionGroup
- type ExceptionStackTrace
- type ExceptionTrendPoint
- type GetExceptionResponse
- type LinkedException
- type LinkedMessage
- type ListEndpointsRequest
- type ListEndpointsResponse
- type ListExceptionsRequest
- type ListExceptionsResponse
- type LogRecord
- type MetricQueryItem
- type MetricQueryResult
- type Option
- type Pagination
- type PaginationParams
- type Project
- type QueryLogsRequest
- type QueryLogsResponse
- type QueryMetricsRequest
- type QueryMetricsResponse
- type Refresher
- type Session
- type SessionDetailResponse
- type SessionLinkedException
- type SlowEndpointResponse
- type Span
- type Task
- type TaskDetailResponse
- type TimeRange
- type TimeSeriesPoint
- type TokenSet
Constants ¶
This section is empty.
Variables ¶
var ( ExceptionsOrderByValues = []string{"lastSeen", "firstSeen", "count"} ExceptionsSearchTypes = []string{"text", "regex"} LogsSearchTypes = []string{"body", "attribute"} SortDirections = []string{"asc", "desc"} EndpointsOrderByValues = []string{"impact", "count", "p95", "lastSeen"} EndpointChartMetricTypes = []string{"total_time", "p50", "p95", "p99"} // MetricAggregations are the values the server accepts on metrics/query. // The server has no quantile aggregation for metric points: p50/p95/p99 // are silently computed as avg. The CLI accepts them for parity with the // dashboard; the MCP server rejects them (see MetricAggregationsExact). MetricAggregations = []string{"avg", "sum", "count", "min", "max", "p50", "p95", "p99"} // MetricAggregationsExact are the aggregations the server actually // computes as named. Latency percentiles come from the endpoints // endpoints, never from metrics/query. MetricAggregationsExact = []string{"avg", "sum", "count", "min", "max"} )
Enum values accepted by the list/query endpoints. These mirror the backend contract and are shared by the CLI flag validation and the MCP server's input validation, so the two surfaces cannot drift.
var ( ErrForbidden = errors.New("forbidden (403)") ErrNotFound = errors.New("not found (404)") ErrRateLimited = errors.New("rate limited (429)") ErrAuthorizationPending = errors.New("authorization_pending") ErrSlowDown = errors.New("slow_down") ErrAccessDenied = errors.New("access_denied") ErrExpiredToken = errors.New("expired_token") ErrInvalidGrant = errors.New("invalid_grant") )
Sentinel errors returned by client methods. Use errors.Is to test.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is returned for any non-2xx response that isn't covered by a sentinel. Inspect StatusCode and Body for diagnostics.
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
// contains filtered or unexported fields
}
Client talks to a Traceway HTTP API. It is safe for concurrent use: JWT reads and the refresh path are serialized internally (long-lived consumers like the MCP server dispatch requests in parallel). Do not mutate JWT directly after construction; it is owned by the refresh path.
func New ¶
New returns a Client with sane defaults. The baseURL is normalized by stripping trailing slashes; do() prepends "/api/..." paths.
func (*Client) ArchiveExceptions ¶
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) DeviceAuthorize ¶ added in v1.8.14
DeviceAuthorize starts the device authorization flow and returns the user code, verification URL, and polling parameters.
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 ¶
ListProjects returns all projects visible to the authenticated user. Upstream: GET /api/projects → []Project (direct array, no pagination wrapper).
func (*Client) Login ¶
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) Logout ¶ added in v1.8.14
Logout revokes the refresh token's family server-side so the session cannot be refreshed after the local credentials are removed. It is idempotent; the caller should treat any error as non-fatal (local logout must still succeed).
func (*Client) PollDeviceToken ¶ added in v1.8.14
PollDeviceToken polls the token endpoint once. It returns ErrAuthorizationPending, ErrSlowDown, ErrAccessDenied, or ErrExpiredToken to drive the polling loop.
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) Refresh ¶ added in v1.8.14
Refresh exchanges a refresh token for a new token set (with a rotated refresh token). It returns ErrInvalidGrant when the refresh token is expired, revoked, or reused.
func (*Client) UnarchiveExceptions ¶
UnarchiveExceptions reverses ArchiveExceptions for the given hashes.
func (*Client) WithBearer ¶ added in v1.8.15
type DeviceAuth ¶ added in v1.8.14
type DeviceAuth struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
VerificationURIComplete string `json:"verification_uri_complete"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
DeviceAuth is the response from starting the device authorization flow.
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 ¶
WithHTTPClient injects a custom *http.Client (useful for tests).
func WithRefresher ¶ added in v1.8.14
WithRefresher enables transparent access-token refresh: on a 401, do() calls the refresher for a new token and retries the request once.
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 ¶
PaginationParams is the request-side pagination control.
type Project ¶
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 Refresher ¶ added in v1.8.14
Refresher returns a fresh access token (JWT) when the current one is rejected. do() invokes it at most once per request, on a 401, then retries. Invocations are serialized by the Client, so a Refresher never runs concurrently with itself on the same Client.
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 ¶
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 ¶
TimeRangeFromExplicit constructs a TimeRange from two explicit instants. Caller is responsible for ensuring From <= To.
func TimeRangeFromSince ¶
TimeRangeFromSince returns a TimeRange ending now and starting `d` ago. Equivalent to TimeRangeFromSinceAt(d, time.Now()).
type TimeSeriesPoint ¶
TimeSeriesPoint is one data point in a metric query result.
type TokenSet ¶ added in v1.8.14
type TokenSet struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
Email string `json:"email"`
}
TokenSet is the access + refresh token pair issued by the device-code and refresh grants.