-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from metrico/pre-release
Pre release
- Loading branch information
Showing
13 changed files
with
215 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package pyroscopereceiver | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/metrico/otel-collector/receiver/pyroscopereceiver/testclient" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type request struct { | ||
urlParams map[string]string | ||
jfr string | ||
} | ||
|
||
// Benchmarks a running otelcol pyroscope write pipeline (collector and Clickhouse). | ||
// Adjust collectorAddr to bench a your target if needed. | ||
// Example: GOMAXPROCS=1 go test -bench ^BenchmarkPyroscopePipeline$ github.com/metrico/otel-collector/receiver/pyroscopereceiver -benchtime 10s -count 6 | ||
func BenchmarkPyroscopePipeline(b *testing.B) { | ||
dist := []request{ | ||
{ | ||
urlParams: map[string]string{ | ||
"name": "com.example.App{dc=us-east-1,kubernetes_pod_name=app-abcd1234}", | ||
"from": "1700332322", | ||
"until": "1700332329", | ||
"format": "jfr", | ||
"sampleRate": "100", | ||
}, | ||
jfr: filepath.Join("..", "receiver", "pyroscopereceiver", "testdata", "cortex-dev-01__kafka-0__cpu__0.jfr"), | ||
}, | ||
{ | ||
urlParams: map[string]string{ | ||
"name": "com.example.App{dc=us-east-1,kubernetes_pod_name=app-abcd1234}", | ||
"from": "1700332322", | ||
"until": "1700332329", | ||
"format": "jfr", | ||
}, | ||
jfr: filepath.Join("..", "receiver", "pyroscopereceiver", "testdata", "memory_alloc_live_example.jfr"), | ||
}, | ||
} | ||
collectorAddr := "http://0.0.0.0:8062" | ||
|
||
b.ReportAllocs() | ||
b.ResetTimer() | ||
b.RunParallel(func(pb *testing.PB) { | ||
j := 0 | ||
for pb.Next() { | ||
err := testclient.Ingest(collectorAddr, dist[j].urlParams, dist[j].jfr) | ||
assert.NoError(b, err, "failed to ingest") | ||
j = (j + 1) % len(dist) | ||
} | ||
}) | ||
} |
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 was deleted.
Oops, something went wrong.
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
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,49 @@ | ||
package pyroscopereceiver | ||
|
||
import ( | ||
"bytes" | ||
"compress/gzip" | ||
"os" | ||
"path/filepath" | ||
"sync" | ||
"testing" | ||
|
||
"github.com/metrico/otel-collector/receiver/pyroscopereceiver/compress" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAllocDecompress(t *testing.T) { | ||
dist := []string{ | ||
filepath.Join("testdata", "cortex-dev-01__kafka-0__cpu__0.jfr"), | ||
filepath.Join("testdata", "memory_alloc_live_example.jfr"), | ||
} | ||
compressed := []*bytes.Buffer{ | ||
loadCompressed(t, dist[0]), | ||
loadCompressed(t, dist[1]), | ||
} | ||
d := compress.NewDecompressor(1024 * 1024 * 1024) | ||
j := 0 | ||
p := &sync.Pool{} | ||
|
||
n := testing.AllocsPerRun(100, func() { | ||
buf := acquireBuf(p) | ||
d.Decompress(compressed[j], compress.Gzip, buf) | ||
releaseBuf(p, buf) | ||
j = (j + 1) % len(dist) | ||
}) | ||
t.Logf("\naverage alloc count: %f", n) | ||
} | ||
|
||
func loadCompressed(t *testing.T, jfr string) *bytes.Buffer { | ||
uncompressed, err := os.ReadFile(jfr) | ||
if err != nil { | ||
assert.NoError(t, err, "failed to load jfr") | ||
} | ||
compressed := new(bytes.Buffer) | ||
gw := gzip.NewWriter(compressed) | ||
if _, err := gw.Write(uncompressed); err != nil { | ||
assert.NoError(t, err, "failed to compress jfr") | ||
} | ||
gw.Close() | ||
return compressed | ||
} |
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
Oops, something went wrong.