Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
fix(pyroscope): use nanos sample type units for cpu & wall profiles (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
korniltsev authored Apr 26, 2023
1 parent 0aa3f23 commit a47996b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.39.0
github.com/prometheus/prometheus v1.99.0
github.com/pyroscope-io/pyroscope v0.37.3-0.20230328035933-35db4234452a
github.com/pyroscope-io/pyroscope v0.37.3-0.20230424172735-981d3aa1203f
github.com/samber/lo v1.37.0
github.com/segmentio/parquet-go v0.0.0-20221214174709-7a0ad59e0540
github.com/sirupsen/logrus v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ github.com/prometheus/prometheus v0.41.0/go.mod h1:Uu5817xm7ibU/VaDZ9pu1ssGzcpO9
github.com/prometheus/statsd_exporter v0.15.0/go.mod h1:Dv8HnkoLQkeEjkIE4/2ndAA7WL1zHKK7WMqFQqu72rw=
github.com/pyroscope-io/jfr-parser v0.6.0 h1:4cQqs+9edZMbZ1ogJ0XDGtgM+PoII4kybJOunVMeD9I=
github.com/pyroscope-io/jfr-parser v0.6.0/go.mod h1:ZMcbJjfDkOwElEK8CvUJbpetztRWRXszCmf5WU0erV8=
github.com/pyroscope-io/pyroscope v0.37.3-0.20230328035933-35db4234452a h1:PbppLKCTjK5dN3FeQxchCz5IJO+EqGmoS5AouzB7XWQ=
github.com/pyroscope-io/pyroscope v0.37.3-0.20230328035933-35db4234452a/go.mod h1:BQfXcD5+jFB/B0jZRGmvyfn7+twVvC6syMBBpd8Pifk=
github.com/pyroscope-io/pyroscope v0.37.3-0.20230424172735-981d3aa1203f h1:BhFAmuGi5aOm+6Qx2mKCKSF6lc+gEgZKHYzC0xy/zQg=
github.com/pyroscope-io/pyroscope v0.37.3-0.20230424172735-981d3aa1203f/go.mod h1:BQfXcD5+jFB/B0jZRGmvyfn7+twVvC6syMBBpd8Pifk=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down
14 changes: 12 additions & 2 deletions pkg/ingester/pyroscope/ingest_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const (
metricWall = "wall"
stUnitCount = "count"
stTypeSamples = "samples"
stTypeCPU = "cpu"
stTypeWall = "wall"
stUnitBytes = "bytes"
stTypeContentions = "contentions"
stTypeDelay = "delay"
Expand All @@ -72,9 +74,17 @@ func (p *pyroscopeIngesterAdapter) Put(ctx context.Context, pi *storage.PutInput
StartTime: pi.StartTime,
}
if pi.SampleRate != 0 && (metric == metricWall || metric == metricProcessCPU) {
mdata.Period = time.Second.Nanoseconds() / int64(pi.SampleRate)
period := time.Second.Nanoseconds() / int64(pi.SampleRate)
mdata.Period = period
mdata.PeriodType = "cpu"
mdata.PeriodUnit = stUnitNanos
if metric == metricWall {
mdata.Type = stTypeWall
} else {
mdata.Type = stTypeCPU
}
mdata.Unit = stUnitNanos
pi.Val.Scale(uint64(period))
}
pprof := pi.Val.Pprof(mdata)
b, err := proto.Marshal(pprof)
Expand Down Expand Up @@ -141,7 +151,7 @@ func convertMetadata(pi *storage.PutInput) (metricName, stType, stUnit, app stri
stType = stTypeSamples
stUnit = stUnitCount
case "wall":
metricName = "wall"
metricName = metricWall
stType = stTypeSamples
stUnit = stUnitCount
case "inuse_objects":
Expand Down

0 comments on commit a47996b

Please sign in to comment.