fixed logging #329
@@ -50,19 +50,19 @@ func (r *feeResolver) ResolveFeeRule(ctx context.Context, orgRef *primitive.Obje
|
|||||||
if rule, selErr := selectRule(plan, trigger, at, attrs); selErr == nil {
|
if rule, selErr := selectRule(plan, trigger, at, attrs); selErr == nil {
|
||||||
return plan, rule, nil
|
return plan, rule, nil
|
||||||
} else if !errors.Is(selErr, ErrNoFeeRuleFound) {
|
} else if !errors.Is(selErr, ErrNoFeeRuleFound) {
|
||||||
r.logger.Warn("Failed selecting rule for org plan", zap.Error(selErr), zap.String("org_ref", orgRef.Hex()))
|
r.logger.Warn("Failed selecting rule for org plan", zap.Error(selErr), mzap.ObjRef("org_ref", *orgRef))
|
||||||
return nil, nil, selErr
|
return nil, nil, selErr
|
||||||
}
|
}
|
||||||
r.logger.Debug(
|
orgFields := []zap.Field{
|
||||||
"No matching rule in org plan; falling back to global",
|
|
||||||
mzap.ObjRef("org_ref", *orgRef),
|
mzap.ObjRef("org_ref", *orgRef),
|
||||||
zap.String("trigger", string(trigger)),
|
zap.String("trigger", string(trigger)),
|
||||||
zap.Time("booked_at", at),
|
zap.Time("booked_at", at),
|
||||||
zap.Any("attributes", attrs),
|
zap.Any("attributes", attrs),
|
||||||
zapFieldsForPlan(plan)...,
|
}
|
||||||
)
|
orgFields = append(orgFields, zapFieldsForPlan(plan)...)
|
||||||
|
r.logger.Debug("No matching rule in org plan; falling back to global", orgFields...)
|
||||||
} else if !errors.Is(err, storage.ErrFeePlanNotFound) {
|
} else if !errors.Is(err, storage.ErrFeePlanNotFound) {
|
||||||
r.logger.Warn("Failed resolving org fee plan", zap.Error(err), zap.String("org_ref", orgRef.Hex()))
|
r.logger.Warn("Failed resolving org fee plan", zap.Error(err), mzap.ObjRef("org_ref", *orgRef))
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,9 +84,13 @@ func (r *feeResolver) ResolveFeeRule(ctx context.Context, orgRef *primitive.Obje
|
|||||||
if !errors.Is(err, ErrNoFeeRuleFound) {
|
if !errors.Is(err, ErrNoFeeRuleFound) {
|
||||||
r.logger.Warn("Failed selecting rule in global plan", zap.Error(err))
|
r.logger.Warn("Failed selecting rule in global plan", zap.Error(err))
|
||||||
} else {
|
} else {
|
||||||
r.logger.Debug("No matching rule in global plan", zap.String("trigger", string(trigger)),
|
globalFields := []zap.Field{
|
||||||
zap.Time("booked_at", at), zap.Any("attributes", attrs), zapFieldsForPlan(plan)...,
|
zap.String("trigger", string(trigger)),
|
||||||
)
|
zap.Time("booked_at", at),
|
||||||
|
zap.Any("attributes", attrs),
|
||||||
|
}
|
||||||
|
globalFields = append(globalFields, zapFieldsForPlan(plan)...)
|
||||||
|
r.logger.Debug("No matching rule in global plan", globalFields...)
|
||||||
}
|
}
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@@ -178,12 +182,12 @@ func zapFieldsForPlan(plan *model.FeePlan) []zap.Field {
|
|||||||
fields = append(fields, zap.Bool("plan_effective_to_set", false))
|
fields = append(fields, zap.Bool("plan_effective_to_set", false))
|
||||||
}
|
}
|
||||||
if plan.OrganizationRef != nil && !plan.OrganizationRef.IsZero() {
|
if plan.OrganizationRef != nil && !plan.OrganizationRef.IsZero() {
|
||||||
fields = append(fields, zap.String("plan_org_ref", plan.OrganizationRef.Hex()))
|
fields = append(fields, mzap.ObjRef("plan_org_ref", *plan.OrganizationRef))
|
||||||
} else {
|
} else {
|
||||||
fields = append(fields, zap.Bool("plan_org_ref_set", false))
|
fields = append(fields, zap.Bool("plan_org_ref_set", false))
|
||||||
}
|
}
|
||||||
if plan.GetID() != nil && !plan.GetID().IsZero() {
|
if plan.GetID() != nil && !plan.GetID().IsZero() {
|
||||||
fields = append(fields, zap.String("plan_id", plan.GetID().Hex()))
|
fields = append(fields, mzap.StorableRef(plan))
|
||||||
}
|
}
|
||||||
return fields
|
return fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -412,7 +412,7 @@ func (s *Service) computeQuote(ctx context.Context, orgRef primitive.ObjectID, i
|
|||||||
return s.computeQuoteWithTime(ctx, orgRef, intent, overrides, trace, s.clock.Now())
|
return s.computeQuoteWithTime(ctx, orgRef, intent, overrides, trace, s.clock.Now())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) computeQuoteWithTime(ctx context.Context, orgRef primitive.ObjectID, intent *feesv1.Intent, overrides *feesv1.PolicyOverrides, trace *tracev1.TraceContext, now time.Time) ([]*feesv1.DerivedPostingLine, []*feesv1.AppliedRule, *feesv1.FXUsed, error) {
|
func (s *Service) computeQuoteWithTime(ctx context.Context, orgRef primitive.ObjectID, intent *feesv1.Intent, _ *feesv1.PolicyOverrides, trace *tracev1.TraceContext, now time.Time) ([]*feesv1.DerivedPostingLine, []*feesv1.AppliedRule, *feesv1.FXUsed, error) {
|
||||||
bookedAt := now
|
bookedAt := now
|
||||||
if intent.GetBookedAt() != nil && intent.GetBookedAt().IsValid() {
|
if intent.GetBookedAt() != nil && intent.GetBookedAt().IsValid() {
|
||||||
bookedAt = intent.GetBookedAt().AsTime()
|
bookedAt = intent.GetBookedAt().AsTime()
|
||||||
|
|||||||
Reference in New Issue
Block a user