mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-22 16:36:27 +01:00
fb90a56de2
This commit adds only JSON support - https://docs.datadoghq.com/api/latest/metrics/#submit-metrics , while recent versions of DataDog Agent send data to /api/v2/series in undocumented Protobuf format. The support for this format will be added later. Thanks to @AndrewChubatiuk for the initial implementation at https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5094 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4451
44 lines
831 B
Go
44 lines
831 B
Go
package datadogv2
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func BenchmarkRequestUnmarshalJSON(b *testing.B) {
|
|
reqBody := []byte(`{
|
|
"series": [
|
|
{
|
|
"metric": "system.load.1",
|
|
"type": 0,
|
|
"points": [
|
|
{
|
|
"timestamp": 1636629071,
|
|
"value": 0.7
|
|
}
|
|
],
|
|
"resources": [
|
|
{
|
|
"name": "dummyhost",
|
|
"type": "host"
|
|
}
|
|
],
|
|
"tags": ["environment:test"]
|
|
}
|
|
]
|
|
}`)
|
|
b.SetBytes(int64(len(reqBody)))
|
|
b.ReportAllocs()
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
var req Request
|
|
for pb.Next() {
|
|
if err := UnmarshalJSON(&req, reqBody); err != nil {
|
|
panic(fmt.Errorf("unexpected error: %w", err))
|
|
}
|
|
if len(req.Series) != 1 {
|
|
panic(fmt.Errorf("unexpected number of series unmarshaled: got %d; want 4", len(req.Series)))
|
|
}
|
|
}
|
|
})
|
|
}
|