metrics

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatedMetric

type AggregatedMetric struct {
	Name            string            `json:"name"`
	AggregationType string            `json:"aggregation_type"`
	Value           float64           `json:"value"`
	Labels          map[string]string `json:"labels"`
	BucketStart     time.Time         `json:"bucket_start"`
	BucketEnd       time.Time         `json:"bucket_end"`
	BucketSize      time.Duration     `json:"bucket_size"`
}

type AssetBreakdown

type AssetBreakdown struct {
	Type      string `json:"type"`
	Provider  string `json:"provider"`
	HasSchema bool   `json:"has_schema"`
	Owner     string `json:"owner"`
	Count     int64  `json:"count"`
}

type AssetCount

type AssetCount struct {
	AssetID       string `json:"asset_id"`
	AssetType     string `json:"asset_type"`
	AssetName     string `json:"asset_name"`
	AssetProvider string `json:"asset_provider"`
	Count         int64  `json:"count"`
}

type Collector

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

func NewCollector

func NewCollector(store Store) *Collector

func (*Collector) RecordAssetView

func (c *Collector) RecordAssetView(assetID, assetType, assetName, assetProvider string) error

func (*Collector) RecordDBQuery

func (c *Collector) RecordDBQuery(operation string, duration time.Duration, success bool)

func (*Collector) RecordHTTPDuration

func (c *Collector) RecordHTTPDuration(method, path string, duration time.Duration)

func (*Collector) RecordHTTPRequest

func (c *Collector) RecordHTTPRequest(method, path, status string) error

func (*Collector) RecordSearchQuery

func (c *Collector) RecordSearchQuery(queryType, query string) error

func (*Collector) SetDBConnections

func (c *Collector) SetDBConnections(count int)

func (*Collector) UpdateAssetMetrics

func (c *Collector) UpdateAssetMetrics(breakdown []AssetBreakdown)

type Metric

type Metric struct {
	Name      string            `json:"name"`
	Type      MetricType        `json:"type"`
	Value     float64           `json:"value"`
	Labels    map[string]string `json:"labels"`
	Timestamp time.Time         `json:"timestamp"`
}

type MetricType

type MetricType string
const (
	Counter   MetricType = "counter"
	Gauge     MetricType = "gauge"
	Histogram MetricType = "histogram"
)

type PostgresStore

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

func (*PostgresStore) AggregateMetrics

func (s *PostgresStore) AggregateMetrics(ctx context.Context, timeRange TimeRange, bucketSize time.Duration) error

func (*PostgresStore) CreatePartition

func (s *PostgresStore) CreatePartition(ctx context.Context, date time.Time) error

func (*PostgresStore) DeleteOldMetrics

func (s *PostgresStore) DeleteOldMetrics(ctx context.Context, olderThan time.Time) error

func (*PostgresStore) GetAggregatedMetrics

func (s *PostgresStore) GetAggregatedMetrics(ctx context.Context, opts QueryOptions) ([]AggregatedMetric, error)

func (*PostgresStore) GetAssetBreakdown

func (s *PostgresStore) GetAssetBreakdown(ctx context.Context) ([]AssetBreakdown, error)

func (*PostgresStore) GetAssetsByOwner

func (s *PostgresStore) GetAssetsByOwner(ctx context.Context, ownerFields []string) (map[string]int64, error)

func (*PostgresStore) GetAssetsByProvider

func (s *PostgresStore) GetAssetsByProvider(ctx context.Context) (map[string]int64, error)

func (*PostgresStore) GetAssetsByType

func (s *PostgresStore) GetAssetsByType(ctx context.Context) (map[string]int64, error)

func (*PostgresStore) GetAssetsWithSchemas

func (s *PostgresStore) GetAssetsWithSchemas(ctx context.Context) (int64, error)

func (*PostgresStore) GetMetrics

func (s *PostgresStore) GetMetrics(ctx context.Context, opts QueryOptions) ([]Metric, error)

func (*PostgresStore) GetTopAssets

func (s *PostgresStore) GetTopAssets(ctx context.Context, timeRange TimeRange, limit int) ([]AssetCount, error)

func (*PostgresStore) GetTopQueries

func (s *PostgresStore) GetTopQueries(ctx context.Context, timeRange TimeRange, limit int) ([]QueryCount, error)

func (*PostgresStore) GetTotalAssets

func (s *PostgresStore) GetTotalAssets(ctx context.Context) (int64, error)

func (*PostgresStore) GetTotalAssetsFiltered

func (s *PostgresStore) GetTotalAssetsFiltered(ctx context.Context, excludedTypes []string, excludedProviders []string) (int64, error)

func (*PostgresStore) RecordMetric

func (s *PostgresStore) RecordMetric(ctx context.Context, metric Metric) error

func (*PostgresStore) RecordMetrics

func (s *PostgresStore) RecordMetrics(ctx context.Context, metrics []Metric) error

type QueryCount

type QueryCount struct {
	Query     string `json:"query"`
	QueryType string `json:"query_type"`
	Count     int64  `json:"count"`
}

type QueryOptions

type QueryOptions struct {
	TimeRange       TimeRange         `json:"time_range"`
	MetricNames     []string          `json:"metric_names"`
	Labels          map[string]string `json:"labels"`
	AggregationType string            `json:"aggregation_type"`
	BucketSize      time.Duration     `json:"bucket_size"`
}

type Recorder

type Recorder interface {
	RecordSearchQuery(ctx context.Context, queryType, query string) error
	RecordAssetView(ctx context.Context, assetID, assetType, assetName, assetProvider string) error
	RecordDBQuery(ctx context.Context, operation string, duration time.Duration, success bool)
	WrapDBQuery(ctx context.Context, operation string, fn func() error) error
	RecordCustomMetrics(ctx context.Context, metrics []Metric) error
}

func NewRecorder

func NewRecorder(collector *Collector) Recorder

type Service

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

func NewService

func NewService(store Store) *Service

func (*Service) Collector

func (s *Service) Collector() *Collector

func (*Service) GetAssetsByOwner

func (s *Service) GetAssetsByOwner(ctx context.Context, ownerFields []string) (map[string]int64, error)

func (*Service) GetAssetsByProvider

func (s *Service) GetAssetsByProvider(ctx context.Context) (map[string]int64, error)

func (*Service) GetAssetsByType

func (s *Service) GetAssetsByType(ctx context.Context) (map[string]int64, error)

func (*Service) GetAssetsWithSchemas

func (s *Service) GetAssetsWithSchemas(ctx context.Context) (int64, error)

func (*Service) GetMetrics

func (s *Service) GetMetrics(ctx context.Context, opts QueryOptions) ([]AggregatedMetric, error)

func (*Service) GetRecorder

func (s *Service) GetRecorder() Recorder

func (*Service) GetTopAssets

func (s *Service) GetTopAssets(ctx context.Context, timeRange TimeRange, limit int) ([]AssetCount, error)

func (*Service) GetTopQueries

func (s *Service) GetTopQueries(ctx context.Context, timeRange TimeRange, limit int) ([]QueryCount, error)

func (*Service) GetTotalAssets

func (s *Service) GetTotalAssets(ctx context.Context) (int64, error)

func (*Service) GetTotalAssetsFiltered

func (s *Service) GetTotalAssetsFiltered(ctx context.Context, excludedTypes []string, excludedProviders []string) (int64, error)

func (*Service) Start

func (s *Service) Start(ctx context.Context)

func (*Service) Stop

func (s *Service) Stop()

type Store

type Store interface {
	RecordMetric(ctx context.Context, metric Metric) error
	RecordMetrics(ctx context.Context, metrics []Metric) error

	GetMetrics(ctx context.Context, opts QueryOptions) ([]Metric, error)
	GetAggregatedMetrics(ctx context.Context, opts QueryOptions) ([]AggregatedMetric, error)

	GetTopQueries(ctx context.Context, timeRange TimeRange, limit int) ([]QueryCount, error)
	GetTopAssets(ctx context.Context, timeRange TimeRange, limit int) ([]AssetCount, error)

	GetTotalAssets(ctx context.Context) (int64, error)
	GetTotalAssetsFiltered(ctx context.Context, excludedTypes []string, excludedProviders []string) (int64, error)
	GetAssetsByType(ctx context.Context) (map[string]int64, error)
	GetAssetsByProvider(ctx context.Context) (map[string]int64, error)
	GetAssetsWithSchemas(ctx context.Context) (int64, error)
	GetAssetsByOwner(ctx context.Context, ownerFields []string) (map[string]int64, error)
	GetAssetBreakdown(ctx context.Context) ([]AssetBreakdown, error)

	AggregateMetrics(ctx context.Context, timeRange TimeRange, bucketSize time.Duration) error
	DeleteOldMetrics(ctx context.Context, olderThan time.Time) error

	CreatePartition(ctx context.Context, date time.Time) error
}

func NewPostgresStore

func NewPostgresStore(db *pgxpool.Pool) Store

type TimeRange

type TimeRange struct {
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
}

Jump to

Keyboard shortcuts

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