2024-09-13 18:06:20 +05:30
|
|
|
package anomaly
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2024-09-17 16:12:17 +05:30
|
|
|
|
2025-03-20 21:01:41 +05:30
|
|
|
querierV2 "github.com/SigNoz/signoz/pkg/query-service/app/querier/v2"
|
|
|
|
|
"github.com/SigNoz/signoz/pkg/query-service/app/queryBuilder"
|
2025-05-03 18:30:07 +05:30
|
|
|
"github.com/SigNoz/signoz/pkg/valuer"
|
2024-09-13 18:06:20 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type DailyProvider struct {
|
|
|
|
|
BaseSeasonalProvider
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _ BaseProvider = (*DailyProvider)(nil)
|
|
|
|
|
|
|
|
|
|
func (dp *DailyProvider) GetBaseSeasonalProvider() *BaseSeasonalProvider {
|
|
|
|
|
return &dp.BaseSeasonalProvider
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewDailyProvider uses the same generic option type
|
|
|
|
|
func NewDailyProvider(opts ...GenericProviderOption[*DailyProvider]) *DailyProvider {
|
|
|
|
|
dp := &DailyProvider{
|
|
|
|
|
BaseSeasonalProvider: BaseSeasonalProvider{},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, opt := range opts {
|
|
|
|
|
opt(dp)
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-17 16:12:17 +05:30
|
|
|
dp.querierV2 = querierV2.NewQuerier(querierV2.QuerierOptions{
|
2025-04-05 23:38:06 +05:30
|
|
|
Reader: dp.reader,
|
|
|
|
|
Cache: dp.cache,
|
|
|
|
|
KeyGenerator: queryBuilder.NewKeyGenerator(),
|
|
|
|
|
FluxInterval: dp.fluxInterval,
|
2024-09-17 16:12:17 +05:30
|
|
|
})
|
|
|
|
|
|
2024-09-13 18:06:20 +05:30
|
|
|
return dp
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-03 18:30:07 +05:30
|
|
|
func (p *DailyProvider) GetAnomalies(ctx context.Context, orgID valuer.UUID, req *GetAnomaliesRequest) (*GetAnomaliesResponse, error) {
|
2024-09-17 16:12:17 +05:30
|
|
|
req.Seasonality = SeasonalityDaily
|
2025-05-03 18:30:07 +05:30
|
|
|
return p.getAnomalies(ctx, orgID, req)
|
2024-09-13 18:06:20 +05:30
|
|
|
}
|