Skip to content

Commit

Permalink
chore: set timestamps and request id on Variant responses
Browse files Browse the repository at this point in the history
  • Loading branch information
yquansah committed Jun 30, 2023
1 parent d0b2b9d commit c7f6aa1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rpc/flipt/evaluation/evaluation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ func (x *EvaluationResponse) SetRequestIDIfNotBlank(id string) string {
return ""
}

func (x *VariantEvaluationResponse) SetRequestIDIfNotBlank(id string) string {
if x.RequestId == "" {
x.RequestId = id
}

return x.RequestId
}

// SetRequestIDIfNotBlank attempts to set the provided ID on the instance
// If the ID was blank, it returns the ID provided to this call.
// If the ID was not blank, it returns the ID found on the instance.
Expand Down Expand Up @@ -93,6 +101,11 @@ func (x *EvaluationResponse) SetTimestamps(start, end time.Time) {
}
}

func (x *VariantEvaluationResponse) SetTimestamps(start, end time.Time) {
x.Timestamp = timestamppb.New(end)
x.RequestDurationMillis = float64(end.Sub(start)) / float64(time.Millisecond)
}

// SetTimestamps records the start and end times on the target instance.
func (x *BatchEvaluationResponse) SetTimestamps(start, end time.Time) {
x.RequestDurationMillis = float64(end.Sub(start)) / float64(time.Millisecond)
Expand Down

0 comments on commit c7f6aa1

Please sign in to comment.