services

package
v0.0.0-...-ff88eae Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RingBuffer configuration
	ConfigRingBufferSize     = "size"     // number of points per metric
	ConfigRingBufferDuration = "duration" // time window to retain

	// Database configuration
	ConfigDBConnection = "connection" // connection string
	ConfigDBRetention  = "retention"  // data retention period
	ConfigDBBatchSize  = "batch_size" // write batch size
)

Common configuration keys

View Source
const APP_ID = "sdl"

Variables

View Source
var ErrNoSuchEntity = errors.New("entity not found")

Functions

func CaptureConsoleLog

func CaptureConsoleLog(t *testing.T, level runtime.LogLevel) (*bytes.Buffer, func())

CaptureConsoleLog captures console log output during test execution

func Debug

func Debug(format string, args ...any)

Debug logs a debug message

func Error

func Error(format string, args ...any)

Error logs an error message

func Event

func Event(emoji, format string, args ...any)

Event logs an event with optional emoji

func Failure

func Failure(format string, args ...any)

Failure logs a failure message

func Info

func Info(format string, args ...any)

Info logs an info message

func QuietTest

func QuietTest(t *testing.T) func()

QuietTest disables console logging for the duration of a test

func SetLogLevel

func SetLogLevel(level runtime.LogLevel)

SetLogLevel sets the console log level

func SetUseEmojis

func SetUseEmojis(use bool)

SetUseEmojis enables or disables emoji output

func Start

func Start(format string, args ...any)

Start logs a start event

func Stop

func Stop(format string, args ...any)

Stop logs a stop event

func Success

func Success(format string, args ...any)

Success logs a success message

func ToProtoDiagramEdge

func ToProtoDiagramEdge(e DiagramEdge) *protos.DiagramEdge

func ToProtoDiagramNode

func ToProtoDiagramNode(n DiagramNode) *protos.DiagramNode

func ToProtoSystemDiagram

func ToProtoSystemDiagram(d *SystemDiagram) *protos.SystemDiagram

func Warn

func Warn(format string, args ...any)

Warn logs a warning message

Types

type AggregateFunc

type AggregateFunc string

AggregateFunc represents an aggregation function

const (
	AggCount  AggregateFunc = "count"
	AggSum    AggregateFunc = "sum"
	AggAvg    AggregateFunc = "avg"
	AggMin    AggregateFunc = "min"
	AggMax    AggregateFunc = "max"
	AggP50    AggregateFunc = "p50"
	AggP90    AggregateFunc = "p90"
	AggP95    AggregateFunc = "p95"
	AggP99    AggregateFunc = "p99"
	AggRate   AggregateFunc = "rate"   // points per second
	AggStdDev AggregateFunc = "stddev" // standard deviation
)

type AggregateOptions

type AggregateOptions struct {
	// Time range
	StartTime time.Time
	EndTime   time.Time

	// Aggregation window (e.g., 1s, 5s, 1m)
	Window time.Duration

	// Additional tag filters
	TagFilters map[string]string

	// Aggregation functions to compute
	Functions []AggregateFunc
}

AggregateOptions specifies parameters for aggregations

type AggregateResult

type AggregateResult struct {
	// Time buckets
	Buckets []TimeBucket

	// Reference to the metric this result is for
	Metric *protos.Metric

	// Aggregation window used
	Window time.Duration
}

AggregateResult contains time-series aggregation results

type BatchGeneratorResult

type BatchGeneratorResult struct {
	TotalGenerators     int
	ProcessedCount      int // started or stopped
	AlreadyInStateCount int // already running/stopped
	FailedCount         int
	FailedIDs           []string
}

Starts/stops all generators BatchGeneratorResult holds the results of batch generator operations

type Canvas

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

func NewCanvas

func NewCanvas(id string, r *runtime.Runtime) *Canvas

NewCanvas creates a new interactive canvas session with a custom runtime. If runtime is nil, a default runtime with no resolvers will be created.

func (*Canvas) AddGenerator

func (c *Canvas) AddGenerator(gen *GeneratorInfo) error

AddGenerator adds a new traffic generator configuration

func (*Canvas) ApplyFlowStrategy

func (c *Canvas) ApplyFlowStrategy(strategy string) error

ApplyFlowStrategy applies flows from specified strategy as current arrival rates

func (*Canvas) BatchSetParameters

func (c *Canvas) BatchSetParameters(updates map[string]any) (map[string]decl.Value, error)

BatchSetParameters sets multiple parameters atomically

func (*Canvas) Close

func (c *Canvas) Close() error

Close closes the Canvas and cleans up resources

func (*Canvas) CurrentSystem

func (c *Canvas) CurrentSystem() *runtime.SystemInstance

CurrentSystem returns the currently active system

func (*Canvas) EvaluateFlowWithStrategy

func (c *Canvas) EvaluateFlowWithStrategy(strategy string) (*runtime.FlowAnalysisResult, error)

EvaluateFlowWithStrategy evaluates flows using specified strategy

func (*Canvas) ExecuteTrace

func (c *Canvas) ExecuteTrace(componentName, methodName string) (*runtime.TraceData, error)

ExecuteTrace runs a single method call and returns detailed trace data

func (*Canvas) GetAvailableSystemNames

func (c *Canvas) GetAvailableSystemNames() []string

GetAvailableSystemNames returns all system names from loaded SDL files

func (*Canvas) GetComponentTotalRPS

func (c *Canvas) GetComponentTotalRPS(componentID string) float64

GetComponentTotalRPS calculates total RPS for a component by summing all its methods

func (*Canvas) GetCurrentFlowRates

func (c *Canvas) GetCurrentFlowRates() map[string]float64

GetCurrentFlowRates returns the current (applied) flow rates

func (*Canvas) GetCurrentFlowState

func (c *Canvas) GetCurrentFlowState() *runtime.FlowState

GetCurrentFlowState returns the current flow state

func (*Canvas) GetFlowStrategies

func (c *Canvas) GetFlowStrategies() map[string]runtime.StrategyInfo

GetFlowStrategies returns all available flow strategies

func (*Canvas) GetGenerator

func (c *Canvas) GetGenerator(id string) *GeneratorInfo

func (*Canvas) GetProposedFlowRates

func (c *Canvas) GetProposedFlowRates() map[string]float64

GetProposedFlowRates returns the proposed flow rates (being evaluated)

func (*Canvas) GetRuntime

func (c *Canvas) GetRuntime() *runtime.Runtime

GetRuntime returns the runtime instance for this canvas

func (*Canvas) GetSimulationTime

func (c *Canvas) GetSimulationTime() float64

GetSimulationTime returns the current simulation time in seconds For now, we return 0 as we don't have virtual time tracking yet

func (*Canvas) GetSystemDiagram

func (c *Canvas) GetSystemDiagram() (*SystemDiagram, error)

GetSystemDiagram returns the system topology with method-level nodes and edges

func (*Canvas) ListGenerators

func (c *Canvas) ListGenerators() map[string]*GeneratorInfo

ListGenerators returns all generator configurations

func (*Canvas) Load

func (c *Canvas) Load(filePath string) error

Load parses, validates, and loads an SDL file and all its imports into the session. If the file is already loaded, it will be re-loaded and re-validated to ensure freshness.

func (*Canvas) RemoveGenerator

func (c *Canvas) RemoveGenerator(genId string) error

func (*Canvas) Reset

func (c *Canvas) Reset() error

Reset clears the canvas completely - stops all generators, removes metrics, and resets state

func (*Canvas) Set

func (c *Canvas) Set(path string, value any) error

Set modifies a component parameter at runtime. The path is a dot-separated string, e.g., "app.cache.HitRate".

func (*Canvas) SetComponentArrivalRate

func (c *Canvas) SetComponentArrivalRate(component, method string, rate float64) error

SetComponentArrivalRate sets a manual arrival rate override

func (*Canvas) StartAllGenerators

func (c *Canvas) StartAllGenerators() (*BatchGeneratorResult, error)

StartAllGenerators starts all generators and returns detailed results

func (*Canvas) StartGenerator

func (c *Canvas) StartGenerator(genId string) error

func (*Canvas) StopAllGenerators

func (c *Canvas) StopAllGenerators() (*BatchGeneratorResult, error)

StopAllGenerators stops all generators and returns detailed results

func (*Canvas) StopGenerator

func (c *Canvas) StopGenerator(genId string) error

func (*Canvas) ToProto

func (c *Canvas) ToProto() *protos.Canvas

ToProto converts the Canvas to its protobuf representation

func (*Canvas) ToggleAllGenerators

func (c *Canvas) ToggleAllGenerators(start bool) error

ToggleAllGenerators toggles all generators (deprecated, use Start/StopAllGenerators)

func (*Canvas) TraceAllPaths

func (c *Canvas) TraceAllPaths(componentName, methodName string, maxDepth int32) (*runtime.AllPathsTraceData, error)

TraceAllPaths performs breadth-first traversal to discover all possible execution paths

func (*Canvas) UpdateGenerator

func (c *Canvas) UpdateGenerator(gen *protos.Generator) error

UpdateGenerator updates an existing traffic generator configuration

func (*Canvas) Use

func (c *Canvas) Use(systemName string) error

Use uses a system in a given file as the one being tested

type CanvasService

type CanvasService struct {
	protoservices.UnimplementedCanvasServiceServer
	// contains filtered or unexported fields
}

--- CanvasService struct holds configuration and state ---

func NewCanvasService

func NewCanvasService() *CanvasService

--- NewCanvasService Constructor ---

func (*CanvasService) AddGenerator

func (s *CanvasService) AddGenerator(ctx context.Context, req *protos.AddGeneratorRequest) (resp *protos.AddGeneratorResponse, err error)

func (*CanvasService) AddMetric

func (s *CanvasService) AddMetric(ctx context.Context, req *protos.AddMetricRequest) (resp *protos.AddMetricResponse, err error)

func (*CanvasService) AggregateMetrics

AggregateMetrics returns aggregated metric data

func (*CanvasService) BatchSetParameters

BatchSetParameters sets multiple parameters atomically

func (*CanvasService) CreateCanvas

func (s *CanvasService) CreateCanvas(ctx context.Context, req *protos.CreateCanvasRequest) (resp *protos.CreateCanvasResponse, err error)

func (*CanvasService) DeleteCanvas

func (s *CanvasService) DeleteCanvas(ctx context.Context, req *protos.DeleteCanvasRequest) (resp *protos.DeleteCanvasResponse, err error)

func (*CanvasService) DeleteGenerator

func (*CanvasService) DeleteMetric

func (s *CanvasService) DeleteMetric(ctx context.Context, req *protos.DeleteMetricRequest) (resp *protos.DeleteMetricResponse, err error)

func (*CanvasService) EvaluateFlows

func (s *CanvasService) EvaluateFlows(ctx context.Context, req *protos.EvaluateFlowsRequest) (resp *protos.EvaluateFlowsResponse, err error)

EvaluateFlows evaluates system flows using specified strategy

func (*CanvasService) ExecuteTrace

func (s *CanvasService) ExecuteTrace(ctx context.Context, req *protos.ExecuteTraceRequest) (resp *protos.ExecuteTraceResponse, err error)

func (*CanvasService) GetCanvas

func (s *CanvasService) GetCanvas(ctx context.Context, req *protos.GetCanvasRequest) (resp *protos.GetCanvasResponse, err error)

func (*CanvasService) GetDefaultCanvas

func (s *CanvasService) GetDefaultCanvas() *Canvas

GetDefaultCanvas returns the default canvas

func (*CanvasService) GetFlowState

func (s *CanvasService) GetFlowState(ctx context.Context, req *protos.GetFlowStateRequest) (resp *protos.GetFlowStateResponse, err error)

GetFlowState returns the current flow state

func (*CanvasService) GetGenerator

func (s *CanvasService) GetGenerator(ctx context.Context, req *protos.GetGeneratorRequest) (resp *protos.GetGeneratorResponse, err error)

GetGenerator returns a specific generator

func (*CanvasService) GetParameters

func (s *CanvasService) GetParameters(ctx context.Context, req *protos.GetParametersRequest) (resp *protos.GetParametersResponse, err error)

GetParameters gets parameter values

func (*CanvasService) GetSystemDiagram

GetSystemDiagram returns the system topology for visualization

func (*CanvasService) GetUtilization

func (s *CanvasService) GetUtilization(ctx context.Context, req *protos.GetUtilizationRequest) (resp *protos.GetUtilizationResponse, err error)

GetUtilization returns resource utilization information

func (*CanvasService) ListCanvases

func (s *CanvasService) ListCanvases(ctx context.Context, req *protos.ListCanvasesRequest) (resp *protos.ListCanvasesResponse, err error)

func (*CanvasService) ListGenerators

func (s *CanvasService) ListGenerators(ctx context.Context, req *protos.ListGeneratorsRequest) (resp *protos.ListGeneratorsResponse, err error)

func (*CanvasService) ListMetrics

func (s *CanvasService) ListMetrics(ctx context.Context, req *protos.ListMetricsRequest) (resp *protos.ListMetricsResponse, err error)

ListMetrics returns all available metrics

func (*CanvasService) LoadFile

func (s *CanvasService) LoadFile(ctx context.Context, req *protos.LoadFileRequest) (resp *protos.LoadFileResponse, err error)

func (*CanvasService) QueryMetrics

func (s *CanvasService) QueryMetrics(ctx context.Context, req *protos.QueryMetricsRequest) (resp *protos.QueryMetricsResponse, err error)

QueryMetrics returns raw metric data points

func (*CanvasService) ResetCanvas

func (s *CanvasService) ResetCanvas(ctx context.Context, req *protos.ResetCanvasRequest) (resp *protos.ResetCanvasResponse, err error)

func (*CanvasService) SetParameter

func (s *CanvasService) SetParameter(ctx context.Context, req *protos.SetParameterRequest) (resp *protos.SetParameterResponse, err error)

SetParameter sets a component parameter value

func (*CanvasService) StartAllGenerators

func (*CanvasService) StartGenerator

func (s *CanvasService) StartGenerator(ctx context.Context, req *protos.StartGeneratorRequest) (resp *protos.StartGeneratorResponse, err error)

func (*CanvasService) StopAllGenerators

func (*CanvasService) StopGenerator

func (s *CanvasService) StopGenerator(ctx context.Context, req *protos.StopGeneratorRequest) (resp *protos.StopGeneratorResponse, err error)

func (*CanvasService) StreamMetrics

StreamMetrics streams real-time metric updates

func (*CanvasService) TraceAllPaths

func (s *CanvasService) TraceAllPaths(ctx context.Context, req *protos.TraceAllPathsRequest) (resp *protos.TraceAllPathsResponse, err error)

func (*CanvasService) UpdateGenerator

func (*CanvasService) UseSystem

func (s *CanvasService) UseSystem(ctx context.Context, req *protos.UseSystemRequest) (resp *protos.UseSystemResponse, err error)

type ClientMgr

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

func NewClientMgr

func NewClientMgr(svc_addr string) *ClientMgr

func (*ClientMgr) Address

func (c *ClientMgr) Address() string

func (*ClientMgr) ClientContext

func (c *ClientMgr) ClientContext(ctx context.Context, loggedInUserId string) context.Context

func (*ClientMgr) GetCanvasSvcClient

func (c *ClientMgr) GetCanvasSvcClient() v1s.CanvasServiceClient

func (*ClientMgr) GetSystemsSvcClient

func (c *ClientMgr) GetSystemsSvcClient() v1s.SystemsServiceClient

type ConsoleLogger

type ConsoleLogger struct {
	runtime.Logger
	// contains filtered or unexported fields
}

ConsoleLogger wraps runtime.Logger with console-specific features

func NewConsoleLogger

func NewConsoleLogger(output io.Writer, level runtime.LogLevel) *ConsoleLogger

NewConsoleLogger creates a logger suitable for console output

func (*ConsoleLogger) Event

func (l *ConsoleLogger) Event(emoji, format string, args ...any)

Event logs an event with optional emoji

func (*ConsoleLogger) Failure

func (l *ConsoleLogger) Failure(format string, args ...any)

Failure logs a failure message

func (*ConsoleLogger) SetUseEmojis

func (l *ConsoleLogger) SetUseEmojis(use bool)

SetUseEmojis enables or disables emoji output

func (*ConsoleLogger) Start

func (l *ConsoleLogger) Start(format string, args ...any)

Start logs a start event

func (*ConsoleLogger) Stop

func (l *ConsoleLogger) Stop(format string, args ...any)

Stop logs a stop event

func (*ConsoleLogger) Success

func (l *ConsoleLogger) Success(format string, args ...any)

Success logs a success message

type DiagramEdge

type DiagramEdge struct {
	FromID      string
	ToID        string
	FromMethod  string // Source method name
	ToMethod    string // Target method name
	Label       string
	Order       float64 // Execution order
	Condition   string  // Condition expression if conditional
	Probability float64 // Probability of this path
	GeneratorID string  // ID of originating generator
	Color       string  // Visualization color
}

DiagramEdge represents a connection between nodes

type DiagramNode

type DiagramNode struct {
	ID       string
	Name     string
	Type     string // Component type for display
	Methods  []MethodInfo
	Traffic  string // Current traffic flow (e.g., "0 rps")
	FullPath string // Full path from system root
	Icon     string // Icon identifier
}

DiagramNode represents a component in the system diagram

type ExactMatcher

type ExactMatcher struct {
	Value decl.Value
}

ExactMatcher matches an exact string value

func (*ExactMatcher) Matches

func (m *ExactMatcher) Matches(returnValue decl.Value) bool

Matches returns true if the return value exactly matches the expected value

type FilesystemMeta

type FilesystemMeta struct {
	ID         string
	Prefix     string
	Type       string
	ReadOnly   bool
	BasePath   string
	Extensions []string
}

FilesystemMeta stores metadata about a mounted filesystem

type FilesystemService

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

FilesystemService wraps a loader.FileSystem to provide filesystem operations

func NewFilesystemService

func NewFilesystemService() *FilesystemService

NewFilesystemService creates a new FilesystemService with default filesystems mounted

func NewFilesystemServiceWithLoader

func NewFilesystemServiceWithLoader(l *loader.Loader) *FilesystemService

NewFilesystemServiceWithLoader creates a FilesystemService that wraps an existing loader's filesystem

func (*FilesystemService) CreateDirectory

CreateDirectory creates a directory

func (*FilesystemService) DeleteFile

DeleteFile deletes a file

func (*FilesystemService) GetCompositeFS

func (s *FilesystemService) GetCompositeFS() *loader.CompositeFS

GetCompositeFS returns the underlying composite filesystem

func (*FilesystemService) GetFileInfo

GetFileInfo returns information about a file

func (*FilesystemService) ListFiles

ListFiles lists files in a directory

func (*FilesystemService) ListFilesystems

ListFilesystems returns all available filesystems

func (*FilesystemService) MountGitHub

func (s *FilesystemService) MountGitHub()

MountGitHub mounts the GitHub filesystem

func (*FilesystemService) MountHTTP

func (s *FilesystemService) MountHTTP()

MountHTTP mounts the HTTP filesystem

func (*FilesystemService) MountLocal

func (s *FilesystemService) MountLocal(id, basePath string, readOnly bool, extensions []string)

MountLocal mounts a local filesystem at the given ID

func (*FilesystemService) ReadFile

ReadFile reads file content

func (*FilesystemService) WriteFile

WriteFile writes content to a file

type GeneratorInfo

type GeneratorInfo struct {
	*protos.Generator // Use proto type directly

	System *sdlruntime.SystemInstance

	GenFunc func(iter int)
	// contains filtered or unexported fields
}

func (*GeneratorInfo) IsRunning

func (g *GeneratorInfo) IsRunning() bool

IsRunning returns true if the generator is currently running

func (*GeneratorInfo) Start

func (g *GeneratorInfo) Start() error

Start starts a generator

func (*GeneratorInfo) Stop

func (g *GeneratorInfo) Stop(wait bool) error

Stop stops the generator

type MethodInfo

type MethodInfo struct {
	Name       string
	ReturnType string
	Traffic    float64 // Current traffic rate in RPS
}

MethodInfo represents information about a component method

type MetricPoint

type MetricPoint struct {
	// Timestamp of the measurement
	Timestamp time.Time

	// The actual value
	Value float64

	// Optional tags for additional dimensions (e.g., "cache_hit": "true")
	Tags map[string]string
}

MetricPoint represents a single metric measurement

type MetricSpec

type MetricSpec struct {
	*protos.Metric // Use proto type directly

	// The system this metric spec applies to
	System  *runtime.SystemInstance
	Matcher ResultMatcher
	// contains filtered or unexported fields
}

MetricSpec defines what to measure and how The tracer will use this to collect and process events and create metric points out of them This will corresponding to each "LiveMetric" that can be plotted and will result in a series of points

func (*MetricSpec) ProcessTraceEvent

func (ms *MetricSpec) ProcessTraceEvent(ts core.Duration, duration core.Duration, comp *runtime.ComponentInstance, method *decl.MethodDecl, retVal decl.Value, err error) bool

Handles the next trace event. Returns true if event accepted, false otherwise

func (*MetricSpec) Start

func (ms *MetricSpec) Start()

func (*MetricSpec) Stop

func (ms *MetricSpec) Stop()

type MetricStats

type MetricStats struct {
	TotalPoints     int64
	OldestTimestamp float64
	NewestTimestamp float64
}

MetricStats contains summary statistics for a metric

type MetricStore

type MetricStore interface {
	// WritePoint stores a single metric point for a specific metric
	WritePoint(ctx context.Context, metric *protos.Metric, point *MetricPoint) error

	// WriteBatch stores multiple metric points for a specific metric
	WriteBatch(ctx context.Context, metric *protos.Metric, points []*MetricPoint) error

	// Query retrieves raw metric points for a specific metric
	Query(ctx context.Context, metric *protos.Metric, opts QueryOptions) (QueryResult, error)

	// QueryMultiple retrieves points for multiple metrics (e.g., for correlation)
	QueryMultiple(ctx context.Context, metrics []*protos.Metric, opts QueryOptions) (map[string]QueryResult, error)

	// Aggregate computes aggregations for a specific metric
	Aggregate(ctx context.Context, metric *protos.Metric, opts AggregateOptions) (AggregateResult, error)

	// Subscribe creates a subscription for real-time metric updates
	Subscribe(ctx context.Context, metricIDs []string) (<-chan *MetricUpdateBatch, error)

	// GetMetricStats returns statistics for a metric
	GetMetricStats(metric *protos.Metric) MetricStats

	// Close cleanly shuts down the store
	Close() error
}

MetricStore defines the interface for storing and querying metrics

type MetricStoreConfig

type MetricStoreConfig struct {
	// Type of store (e.g., "ringbuffer", "timescaledb", "influxdb")
	Type string

	// Store-specific configuration
	Config map[string]interface{}
}

MetricStoreConfig holds configuration for a metric store

type MetricStoreFactory

type MetricStoreFactory interface {
	// CreateStore creates a new metric store with the given configuration
	CreateStore(config MetricStoreConfig) (MetricStore, error)
}

MetricStoreFactory creates MetricStore instances

type MetricTracer

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

The main tracer that processes TraceEvents and generates metrics from them

func NewMetricTracer

func NewMetricTracer(system *runtime.SystemInstance, canvas *Canvas) *MetricTracer

func (*MetricTracer) AddMetricSpec

func (mt *MetricTracer) AddMetricSpec(spec *MetricSpec) error

func (*MetricTracer) AggregateMetrics

func (mt *MetricTracer) AggregateMetrics(ctx context.Context, specId string, opts AggregateOptions) (AggregateResult, error)

AggregateMetrics computes aggregations for a metric

func (*MetricTracer) Clear

func (mt *MetricTracer) Clear()

func (*MetricTracer) Enter

func (mt *MetricTracer) Enter(ts core.Duration, kind runtime.TraceEventKind, comp *runtime.ComponentInstance, method *decl.MethodDecl, args ...string) int64

func (*MetricTracer) Exit

func (mt *MetricTracer) Exit(ts core.Duration, duration core.Duration, comp *runtime.ComponentInstance, method *decl.MethodDecl, retVal decl.Value, err error)

Main Tracer interface methods

func (*MetricTracer) GetMetricByID

func (mt *MetricTracer) GetMetricByID(id string) *protos.Metric

GetMetricByID finds a metric by its ID

func (*MetricTracer) GetMetricSpec

func (mt *MetricTracer) GetMetricSpec(specId string) (spec *MetricSpec)

func (*MetricTracer) GetMetricStore

func (mt *MetricTracer) GetMetricStore() MetricStore

GetMetricStore returns the current metric store

func (*MetricTracer) ListMetricSpec

func (mt *MetricTracer) ListMetricSpec() []*MetricSpec

func (*MetricTracer) ListMetrics

func (mt *MetricTracer) ListMetrics() []*protos.Metric

ListMetrics returns all configured metrics with statistics

func (*MetricTracer) PopParent

func (mt *MetricTracer) PopParent()

PopParent removes the most recent event ID from the stack.

func (*MetricTracer) PushParentID

func (mt *MetricTracer) PushParentID(id int64)

PushParentID manually pushes a parent ID onto the stack. Used by the aggregator to set the context for evaluating futures.

func (*MetricTracer) QueryMetrics

func (mt *MetricTracer) QueryMetrics(ctx context.Context, specId string, opts QueryOptions) (QueryResult, error)

QueryMetrics queries metrics from the store

func (*MetricTracer) RemoveMetricSpec

func (mt *MetricTracer) RemoveMetricSpec(specId string)

func (*MetricTracer) SetMetricStore

func (mt *MetricTracer) SetMetricStore(store MetricStore)

SetMetricStore sets a custom metric store

type MetricType

type MetricType = string

MetricType represents the type of metric being measured

const (
	// MetricCount tracks the number of events
	MetricCount MetricType = "count"

	// MetricLatency tracks duration values
	MetricLatency MetricType = "latency"

	// MetricUtilization tracks resource utilization (0.0 to 1.0)
	MetricUtilization MetricType = "utilization"
)

type MetricUpdateBatch

type MetricUpdateBatch struct {
	Updates []*MetricUpdateItem
}

MetricUpdateBatch contains metric updates that can be sent to subscribers

type MetricUpdateItem

type MetricUpdateItem struct {
	MetricID string
	Point    *MetricPoint
}

MetricUpdateItem represents a single metric update

type NotMatcher

type NotMatcher struct {
	Inner ResultMatcher
}

NotMatcher inverts the match result

func (*NotMatcher) Matches

func (m *NotMatcher) Matches(returnValue decl.Value) bool

Matches returns true if the inner matcher returns false

type QueryOptions

type QueryOptions struct {
	// Time range
	StartTime time.Time
	EndTime   time.Time

	// Additional tag filters
	TagFilters map[string]string

	// Maximum number of results
	Limit int

	// Offset for pagination
	Offset int
}

QueryOptions specifies parameters for metric queries

type QueryResult

type QueryResult struct {
	Points    []*MetricPoint
	TotalRows int64
	HasMore   bool
}

QueryResult contains the results of a metric query

type ResultMatcher

type ResultMatcher interface {
	Matches(returnValue decl.Value) bool
}

ResultMatcher determines if a return value matches the expected result

func CreateResultMatcher

func CreateResultMatcher(spec string) ResultMatcher

Helper function to create a result matcher from a string specification

type RingBufferStore

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

RingBufferStore implements MetricStore using in-memory ring buffers

func NewRingBufferStore

func NewRingBufferStore(config MetricStoreConfig) (*RingBufferStore, error)

NewRingBufferStore creates a new ring buffer metric store

func (*RingBufferStore) Aggregate

func (s *RingBufferStore) Aggregate(ctx context.Context, metric *protos.Metric, opts AggregateOptions) (AggregateResult, error)

Aggregate computes aggregations over time windows

func (*RingBufferStore) Close

func (s *RingBufferStore) Close() error

func (*RingBufferStore) GetMetricStats

func (s *RingBufferStore) GetMetricStats(metric *protos.Metric) MetricStats

GetMetricStats returns statistics for a specific metric

func (*RingBufferStore) Query

func (s *RingBufferStore) Query(ctx context.Context, metric *protos.Metric, opts QueryOptions) (QueryResult, error)

Query retrieves raw metric points

func (*RingBufferStore) QueryMultiple

func (s *RingBufferStore) QueryMultiple(ctx context.Context, metrics []*protos.Metric, opts QueryOptions) (map[string]QueryResult, error)

QueryMultiple retrieves points for multiple metrics

func (*RingBufferStore) Subscribe

func (s *RingBufferStore) Subscribe(ctx context.Context, metricIDs []string) (<-chan *MetricUpdateBatch, error)

Close shuts down the store Subscribe creates a subscription for real-time metric updates

func (*RingBufferStore) WriteBatch

func (s *RingBufferStore) WriteBatch(ctx context.Context, metric *protos.Metric, points []*MetricPoint) error

WriteBatch stores multiple metric points efficiently

func (*RingBufferStore) WritePoint

func (s *RingBufferStore) WritePoint(ctx context.Context, metric *protos.Metric, point *MetricPoint) error

WritePoint stores a single metric point

type SystemCatalogService

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

SystemCatalogService manages the system examples catalog

func NewSystemCatalogService

func NewSystemCatalogService() *SystemCatalogService

NewSystemCatalogService creates a new system catalog service

func (*SystemCatalogService) GetSystem

func (s *SystemCatalogService) GetSystem(id string) *SystemProject

GetSystem returns a specific system project

func (*SystemCatalogService) ListSystems

func (s *SystemCatalogService) ListSystems() []SystemInfo

ListSystems returns all systems as SystemInfo

type SystemDiagram

type SystemDiagram struct {
	SystemName string
	Nodes      []DiagramNode
	Edges      []DiagramEdge
}

SystemDiagram represents the visual structure of a system

type SystemInfo

type SystemInfo struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Category    string   `json:"category"`
	Difficulty  string   `json:"difficulty"`
	Tags        []string `json:"tags"`
	Icon        string   `json:"icon,omitempty"`
	LastUpdated string   `json:"lastUpdated"`
}

SystemInfo represents a system in the catalog

type SystemProject

type SystemProject struct {
	ID             string                   `json:"id"`
	Name           string                   `json:"name"`
	Description    string                   `json:"description"`
	Category       string                   `json:"category"`
	Difficulty     string                   `json:"difficulty"`
	Tags           []string                 `json:"tags"`
	Icon           string                   `json:"icon,omitempty"`
	Versions       map[string]SystemVersion `json:"versions"`
	DefaultVersion string                   `json:"defaultVersion"`
	LastUpdated    string                   `json:"lastUpdated"`
	// contains filtered or unexported fields
}

SystemProject represents a full system project

type SystemVersion

type SystemVersion struct {
	SDL    string `json:"sdl"`
	Recipe string `json:"recipe"`
	Readme string `json:"readme,omitempty"`
}

SystemVersion represents a version of a system

type SystemsServiceImpl

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

SystemsServiceImpl implements the SystemsService gRPC interface

func NewSystemsService

func NewSystemsService() *SystemsServiceImpl

NewSystemsService creates a new SystemsService implementation

func (*SystemsServiceImpl) GetSystem

GetSystem returns a specific system with metadata

func (*SystemsServiceImpl) GetSystemContent

GetSystemContent returns the SDL and recipe content for a system

func (*SystemsServiceImpl) ListSystems

ListSystems returns all available systems

type TimeBucket

type TimeBucket struct {
	// Start time of this bucket
	Time time.Time

	// Aggregated values keyed by function name
	Values map[AggregateFunc]float64

	// Number of points in this bucket
	Count int64
}

TimeBucket represents aggregated metrics for a time window

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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