stats

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 15 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

Index

Constants

This section is empty.

Variables

View Source
var ErrAgentNotFound = errors.New("agent not found")
View Source
var LatencyBucketsMs = []int{5, 10, 25, 50, 100, 250, 500, 1000}

LatencyBucketsMs are the upper bounds of the response-time histogram; a final bucket holds the rest.

Functions

This section is empty.

Types

type APIKeyCreator added in v0.15.0

type APIKeyCreator struct {
	Subject         string `json:"subject"`
	Name            string `json:"name"`
	Email           string `json:"email"`
	CreatedAt       string `json:"created_at"`
	ProjectID       string `json:"project_id"`
	ProjectName     string `json:"project_name"`
	AgentID         string `json:"agent_id"`
	AgentName       string `json:"agent_name"`
	EnvironmentID   string `json:"environment_id,omitempty"`
	EnvironmentName string `json:"environment_name,omitempty"`
}

type AgentMetrics added in v0.16.1

type AgentMetrics struct {
	Days         []string             `json:"days"`
	Environments []EnvironmentMetrics `json:"environments"`
	Flags        []FlagMetrics        `json:"flags"`
}

type AgentStat

type AgentStat struct {
	ID           string        `json:"id"`
	Name         string        `json:"name"`
	Stats        []Stat        `json:"stats"`
	Environments []Environment `json:"environments"`
}

type AgentsStats

type AgentsStats struct {
	Agents []AgentStat `json:"agents"`
}

type CompanyOverview added in v0.15.0

type CompanyOverview struct {
	RequestTotals       RequestTotals               `json:"request_totals"`
	EnvironmentRequests []EnvironmentRequestSummary `json:"environment_requests"`
	LatestAPIKeyCreator *APIKeyCreator              `json:"latest_api_key_creator,omitempty"`
}

type Environment

type Environment struct {
	Id   string `json:"id"`
	Name string `json:"name"`

	Stats []Stat `json:"stats"`
}

type EnvironmentMetrics added in v0.16.1

type EnvironmentMetrics struct {
	EnvironmentId string `json:"environment_id"`
	Name          string `json:"name"`
	Level         int    `json:"level"`
	Users         []int  `json:"users"`    // distinct targeting keys per day
	Requests      []int  `json:"requests"` // SDK/OFREP flag requests per day
	// response time of the flags endpoint over the whole range; the bucket's upper bound, 1001 means >1s
	P50Ms int `json:"p50_ms"`
	P95Ms int `json:"p95_ms"`
}

type EnvironmentRequestSummary added in v0.15.0

type EnvironmentRequestSummary struct {
	EnvironmentID      string `json:"environment_id"`
	EnvironmentName    string `json:"environment_name"`
	AgentID            string `json:"agent_id"`
	AgentName          string `json:"agent_name"`
	ProjectID          string `json:"project_id"`
	ProjectName        string `json:"project_name"`
	SingleFlagRequests int    `json:"single_flag_requests"`
	AllFlagsRequests   int    `json:"all_flags_requests"`
	TotalRequests      int    `json:"total_requests"`
}

type Exposure added in v0.16.1

type Exposure struct {
	Flag    string
	On      bool
	RuleHit bool
}

Exposure is what one flag was served to one user: the server's own decision.

type FlagMetrics added in v0.16.1

type FlagMetrics struct {
	Name          string `json:"name"`
	EnvironmentId string `json:"environment_id"`
	ServedOn      []int  `json:"served_on"`
	ServedOff     []int  `json:"served_off"`
	RuleHits      []int  `json:"rule_hits"`
}

type RequestKind added in v0.15.0

type RequestKind string
const (
	RequestKindSingleFlag RequestKind = "single_flag"
	RequestKindAllFlags   RequestKind = "all_flags"
)

type RequestSource added in v0.15.0

type RequestSource string
const (
	RequestSourceOFREPSingle RequestSource = "ofrep_single"
	RequestSourceOFREPBulk   RequestSource = "ofrep_bulk"
	RequestSourceSDKAll      RequestSource = "sdk_all"
)

type RequestTotals added in v0.15.0

type RequestTotals struct {
	SingleFlagRequests int `json:"single_flag_requests"`
	AllFlagsRequests   int `json:"all_flags_requests"`
	TotalRequests      int `json:"total_requests"`
}

type Stat

type Stat struct {
	Requests  int64  `json:"request"`
	Errors    int64  `json:"error"`
	Successes int64  `json:"success"`
	Label     string `json:"label"`
}

type System

type System struct {
	Config *ConfigBuilder.Config
}

func NewSystem

func NewSystem(cfg *ConfigBuilder.Config) *System

func (*System) AddAgentError

func (s *System) AddAgentError(companyId, agentId, environmentId string)

func (*System) AddAgentSuccess

func (s *System) AddAgentSuccess(companyId, agentId, environmentId string)

func (*System) GetAgentEnvironmentStats

func (s *System) GetAgentEnvironmentStats(ctx context.Context, agentId string, timePeriod int) (*AgentStat, error)

func (*System) GetAgentMetrics added in v0.16.1

func (s *System) GetAgentMetrics(ctx context.Context, companyId, agentId string, days int) (*AgentMetrics, error)

GetAgentMetrics returns daily usage for the agent's environments and flags over the last `days` days.

func (*System) GetAgentMetricsHandler added in v0.16.1

func (s *System) GetAgentMetricsHandler(w http.ResponseWriter, r *http.Request)

GetAgentMetricsHandler: GET /agent/{agentId}/metrics?days=14 (1-90)

func (*System) GetAgentName

func (s *System) GetAgentName(ctx context.Context, agentId string) (string, error)

func (*System) GetAgentStats

func (s *System) GetAgentStats(w http.ResponseWriter, r *http.Request)

func (*System) GetAgentsStats

func (s *System) GetAgentsStats(w http.ResponseWriter, r *http.Request)

func (*System) GetAgentsStatsFromInflux

func (s *System) GetAgentsStatsFromInflux(ctx context.Context, companyId string) (*AgentsStats, error)

func (*System) GetCompanyOverview added in v0.15.0

func (s *System) GetCompanyOverview(ctx context.Context, companyId string) (*CompanyOverview, error)

func (*System) GetCompanyStats

func (s *System) GetCompanyStats(w http.ResponseWriter, r *http.Request)

func (*System) GetEnvironmentName

func (s *System) GetEnvironmentName(ctx context.Context, environmentId string) (string, error)

func (*System) GetEnvironmentStats

func (s *System) GetEnvironmentStats(w http.ResponseWriter, r *http.Request)

func (*System) GetNamesForData

func (s *System) GetNamesForData(ctx context.Context, data *AgentStat) (*AgentStat, error)

func (*System) GetProjectStats

func (s *System) GetProjectStats(w http.ResponseWriter, r *http.Request)

func (*System) RecordAPIKeyCreation added in v0.15.0

func (s *System) RecordAPIKeyCreation(ctx context.Context, userSubject, projectId, agentId, environmentId string) error

func (*System) RecordEnvironmentRequest added in v0.15.0

func (s *System) RecordEnvironmentRequest(ctx context.Context, projectId, agentId, environmentId string, requestKind RequestKind, requestSource RequestSource) error

func (*System) RecordFlagsRequest added in v0.16.1

func (s *System) RecordFlagsRequest(ctx context.Context, environmentId, targetingKey string, took time.Duration, exposures []Exposure) error

RecordFlagsRequest stores the endpoint's response time and, the first time a targeting key is seen in the environment today, counts that user and what every flag was served to them. Later polls that day cost one insert.

Jump to

Keyboard shortcuts

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