fix: lint

This commit is contained in:
nityanandagohain
2026-04-30 18:33:21 +05:30
parent 2a858adae7
commit 95d100aedf
2 changed files with 24 additions and 13 deletions

View File

@@ -41,10 +41,9 @@ func (module *module) CreateOrUpdate(ctx context.Context, orgID valuer.UUID, use
for _, u := range rules {
existing, err := module.findExisting(ctx, orgID, u)
if err != nil {
return err
}
if existing == nil {
if !errors.Ast(err, errors.TypeNotFound) {
return err
}
if err := module.store.Create(ctx, llmpricingruletypes.NewLLMPricingRuleFromUpdatable(u, orgID, userEmail, now)); err != nil {
return err
}
@@ -76,20 +75,16 @@ func (module *module) Delete(ctx context.Context, orgID, id valuer.UUID) error {
return nil
}
// findExisting returns the row matching the updatable's ID or SourceID.
// Returns a TypeNotFound error when neither matches; the caller treats that
// as "insert new".
func (module *module) findExisting(ctx context.Context, orgID valuer.UUID, u llmpricingruletypes.UpdatableLLMPricingRule) (*llmpricingruletypes.LLMPricingRule, error) {
switch {
case u.ID != nil:
return module.store.Get(ctx, orgID, *u.ID)
case u.SourceID != nil:
s, err := module.store.GetBySourceID(ctx, orgID, *u.SourceID)
if err != nil {
if errors.Ast(err, errors.TypeNotFound) {
return nil, nil
}
return nil, err
}
return s, nil
return module.store.GetBySourceID(ctx, orgID, *u.SourceID)
default:
return nil, nil
return nil, errors.Newf(errors.TypeNotFound, llmpricingruletypes.ErrCodePricingRuleNotFound, "rule has neither id nor sourceId")
}
}

View File

@@ -3,6 +3,22 @@ receivers:
protocols:
grpc:
processors:
signozllmpricing:
attrs:
model: gen_ai.request.model
in: gen_ai.usage.input_tokens
out: gen_ai.usage.output_tokens
cache_read: gen_ai.usage.cache_read.input_tokens
cache_write: gen_ai.usage.cache_creation.input_tokens
default_pricing:
unit: per_million_tokens
rules: []
output_attrs:
in: _signoz.gen_ai.cost_input
out: _signoz.gen_ai.cost_output
cache_read: _signoz.gen_ai.cost_cache_read
cache_write: _signoz.gen_ai.cost_cache_write
total: _signoz.gen_ai.total_cost
batch: {}
exporters:
otlp: