generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bucketize latency attribute (#2269)
This PR bucketizes the latency _attribute_ (NOT the latency _metric_! That would be very bad!) For better filtering capabilities in datadog, we need to bucket our high-cardinality numeric attributes. This uses log base8 because: 1. That seems to give the most useful results for current production numbers we're seeing in DD - good functional granularity for analysis purposes without being so granular that it's annoying to sort through the buckets. Current values range from 62 to 20279, concentrated in the 100-1000 range. 2. Base 8 bucket labels are all powers of 2, so it's relatively easy for our brains to skim Sample output: ``` -> ftl.async_call.time_since_scheduled_at_ms.bucket: Str([8,64)) ``` Issue: #2194
- Loading branch information
Showing
3 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package observability | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/alecthomas/assert/v2" | ||
) | ||
|
||
func TestLogBucket(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
base int | ||
num int | ||
want string | ||
}{ | ||
{ | ||
name: "<1", | ||
base: 8, | ||
num: 0, | ||
want: "<1", | ||
}, | ||
{ | ||
name: "EqualLowEndOfRange", | ||
base: 8, | ||
num: 1, | ||
want: "[1,8)", | ||
}, | ||
{ | ||
name: "HigherEndOfRange", | ||
base: 8, | ||
num: 7, | ||
want: "[1,8)", | ||
}, | ||
{ | ||
name: "BigInputNum", | ||
base: 8, | ||
num: 16800000, | ||
want: "[16777216,134217728)", | ||
}, | ||
{ | ||
name: "Base2", | ||
base: 2, | ||
num: 8, | ||
want: "[8,16)", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
assert.Equal(t, test.want, logBucket(test.base, int64(test.num))) | ||
}) | ||
} | ||
} |