Documentation
¶
Index ¶
- type AggregatedMetric
- type AssetBreakdown
- type AssetCount
- type Collector
- func (c *Collector) RecordAssetView(assetID, assetType, assetName, assetProvider string)
- func (c *Collector) RecordDBQuery(operation string, duration time.Duration, success bool)
- func (c *Collector) RecordHTTPDuration(method, path string, duration time.Duration)
- func (c *Collector) RecordHTTPRequest(method, path, status string)
- func (c *Collector) RecordSearchQuery(queryType, query string)
- func (c *Collector) SetDBConnections(count int)
- func (c *Collector) StartAsyncRecording()
- func (c *Collector) StopAsyncRecording()
- func (c *Collector) UpdateAssetMetrics(breakdown []AssetBreakdown)
- type Metric
- type MetricType
- type PostgresStore
- func (s *PostgresStore) CreatePartition(ctx context.Context, date time.Time) error
- func (s *PostgresStore) DeleteOldMetrics(ctx context.Context, olderThan time.Time) error
- func (s *PostgresStore) GetAggregatedMetrics(ctx context.Context, opts QueryOptions) ([]AggregatedMetric, error)
- func (s *PostgresStore) GetAssetBreakdown(ctx context.Context) ([]AssetBreakdown, error)
- func (s *PostgresStore) GetAssetsByOwner(ctx context.Context, ownerFields []string) (map[string]int64, error)
- func (s *PostgresStore) GetAssetsByProvider(ctx context.Context) (map[string]int64, error)
- func (s *PostgresStore) GetAssetsByType(ctx context.Context) (map[string]int64, error)
- func (s *PostgresStore) GetAssetsWithSchemas(ctx context.Context) (int64, error)
- func (s *PostgresStore) GetMetrics(ctx context.Context, opts QueryOptions) ([]Metric, error)
- func (s *PostgresStore) GetTopAssets(ctx context.Context, timeRange TimeRange, limit int) ([]AssetCount, error)
- func (s *PostgresStore) GetTopQueries(ctx context.Context, timeRange TimeRange, limit int) ([]QueryCount, error)
- func (s *PostgresStore) GetTotalAssets(ctx context.Context) (int64, error)
- func (s *PostgresStore) GetTotalAssetsFiltered(ctx context.Context, excludedTypes []string, excludedProviders []string) (int64, error)
- func (s *PostgresStore) RecordMetric(ctx context.Context, metric Metric) error
- func (s *PostgresStore) RecordMetrics(ctx context.Context, metrics []Metric) error
- func (s *PostgresStore) RefreshAssetStatistics(ctx context.Context, ownerFields []string) error
- func (s *PostgresStore) RefreshMetadataValueCounts(ctx context.Context) error
- type QueryCount
- type QueryOptions
- type Recorder
- type Service
- func (s *Service) Collector() *Collector
- func (s *Service) GetAssetsByOwner(ctx context.Context, ownerFields []string) (map[string]int64, error)
- func (s *Service) GetAssetsByProvider(ctx context.Context) (map[string]int64, error)
- func (s *Service) GetAssetsByType(ctx context.Context) (map[string]int64, error)
- func (s *Service) GetAssetsWithSchemas(ctx context.Context) (int64, error)
- func (s *Service) GetMetrics(ctx context.Context, opts QueryOptions) ([]AggregatedMetric, error)
- func (s *Service) GetRecorder() Recorder
- func (s *Service) GetTopAssets(ctx context.Context, timeRange TimeRange, limit int) ([]AssetCount, error)
- func (s *Service) GetTopQueries(ctx context.Context, timeRange TimeRange, limit int) ([]QueryCount, error)
- func (s *Service) GetTotalAssets(ctx context.Context) (int64, error)
- func (s *Service) GetTotalAssetsFiltered(ctx context.Context, excludedTypes []string, excludedProviders []string) (int64, error)
- func (s *Service) SetOwnerFields(fields []string)
- func (s *Service) Start(ctx context.Context)
- func (s *Service) Stop()
- type Store
- type TimeRange
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" swaggertype:"integer"`
}
type AssetBreakdown ¶
type AssetCount ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
func NewCollector ¶
func (*Collector) RecordAssetView ¶
func (*Collector) RecordDBQuery ¶
func (*Collector) RecordHTTPDuration ¶
func (*Collector) RecordHTTPRequest ¶
func (*Collector) RecordSearchQuery ¶
func (*Collector) SetDBConnections ¶
func (*Collector) StartAsyncRecording ¶ added in v0.6.0
func (c *Collector) StartAsyncRecording()
StartAsyncRecording starts the background worker for async metric recording
func (*Collector) StopAsyncRecording ¶ added in v0.6.0
func (c *Collector) StopAsyncRecording()
StopAsyncRecording stops the background worker and flushes remaining metrics
func (*Collector) UpdateAssetMetrics ¶
func (c *Collector) UpdateAssetMetrics(breakdown []AssetBreakdown)
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) CreatePartition ¶
CreatePartition creates a partition for the given date.
func (*PostgresStore) DeleteOldMetrics ¶
DeleteOldMetrics drops partitions older than the cutoff date.
func (*PostgresStore) GetAggregatedMetrics ¶
func (s *PostgresStore) GetAggregatedMetrics(ctx context.Context, opts QueryOptions) ([]AggregatedMetric, error)
GetAggregatedMetrics returns aggregated metrics using pre-computed values.
func (*PostgresStore) GetAssetBreakdown ¶
func (s *PostgresStore) GetAssetBreakdown(ctx context.Context) ([]AssetBreakdown, error)
func (*PostgresStore) GetAssetsByOwner ¶
func (*PostgresStore) GetAssetsByProvider ¶
func (*PostgresStore) GetAssetsByType ¶
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)
GetMetrics returns raw metric data points by unnesting arrays.
func (*PostgresStore) GetTopAssets ¶
func (s *PostgresStore) GetTopAssets(ctx context.Context, timeRange TimeRange, limit int) ([]AssetCount, error)
GetTopAssets returns the most viewed assets.
func (*PostgresStore) GetTopQueries ¶
func (s *PostgresStore) GetTopQueries(ctx context.Context, timeRange TimeRange, limit int) ([]QueryCount, error)
GetTopQueries returns the most frequent search queries.
func (*PostgresStore) GetTotalAssets ¶
func (s *PostgresStore) GetTotalAssets(ctx context.Context) (int64, error)
func (*PostgresStore) GetTotalAssetsFiltered ¶
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
RecordMetrics appends metrics to the array-based timeseries table. Groups metrics by (name, labels, hour) and performs batch upserts. Deadlocks are handled gracefully since metrics are best-effort.
func (*PostgresStore) RefreshAssetStatistics ¶ added in v0.6.0
func (s *PostgresStore) RefreshAssetStatistics(ctx context.Context, ownerFields []string) error
RefreshAssetStatistics updates the pre-computed asset statistics table.
func (*PostgresStore) RefreshMetadataValueCounts ¶ added in v0.6.0
func (s *PostgresStore) RefreshMetadataValueCounts(ctx context.Context) error
RefreshMetadataValueCounts refreshes the materialized view for metadata autocomplete.
type QueryCount ¶
type QueryOptions ¶
type Recorder ¶
type Recorder interface {
RecordSearchQuery(ctx context.Context, queryType, query string)
RecordAssetView(ctx context.Context, assetID, assetType, assetName, assetProvider string)
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 ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) GetAssetsByOwner ¶
func (*Service) GetAssetsByProvider ¶
func (*Service) GetAssetsByType ¶
func (*Service) GetAssetsWithSchemas ¶
func (*Service) GetMetrics ¶
func (s *Service) GetMetrics(ctx context.Context, opts QueryOptions) ([]AggregatedMetric, error)
func (*Service) GetRecorder ¶
func (*Service) GetTopAssets ¶
func (*Service) GetTopQueries ¶
func (*Service) GetTotalAssets ¶
func (*Service) GetTotalAssetsFiltered ¶
func (*Service) SetOwnerFields ¶ added in v0.6.0
SetOwnerFields configures which metadata fields to use for owner statistics.
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)
// Asset statistics (from pre-computed table)
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)
// Maintenance
RefreshAssetStatistics(ctx context.Context, ownerFields []string) error
RefreshMetadataValueCounts(ctx context.Context) error
CreatePartition(ctx context.Context, date time.Time) error
DeleteOldMetrics(ctx context.Context, olderThan time.Time) error
}