Skip to content

Commit

Permalink
fix(pyroscope.scrape): godeltaprof hiding (#2614)
Browse files Browse the repository at this point in the history
* fix(pyroscope.scrape): godeltaprof hiding

* CHANGELOG.md

* improve test
  • Loading branch information
korniltsev authored Feb 5, 2025
1 parent 0ebef89 commit c52e9ce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Main (unreleased)

- Add support for pushv1.PusherService Connect API in `pyroscope.receive_http`. (@simonswine)

- Fixes godeltaprof hiding (renaming `godeltaprof_*` profile names to regular ones). (@korniltsev)

v1.6.1
-----------------

Expand Down
26 changes: 12 additions & 14 deletions internal/component/pyroscope/scrape/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,21 @@ type Target struct {
// NewTarget creates a reasonably configured target for querying.
func NewTarget(lbls, discoveredLabels labels.Labels, params url.Values) *Target {
publicLabels := make(labels.Labels, 0, len(lbls))
for _, l := range lbls {
for i, l := range lbls {
if strings.HasPrefix(l.Name, model.ReservedLabelPrefix) {
continue
}

// the fact that godeltaprof was used scraping should not be user visible
if l.Name == pprofGoDeltaProfMemory {
switch l.Value {
case pprofGoDeltaProfMemory:
l.Value = pprofMemory
case pprofGoDeltaProfBlock:
l.Value = pprofBlock
case pprofGoDeltaProfMutex:
l.Value = pprofMutex
// the fact that godeltaprof was used scraping should not be user visible
if l.Name == model.MetricNameLabel {
switch l.Value {
case pprofGoDeltaProfMemory:
lbls[i].Value = pprofMemory
case pprofGoDeltaProfBlock:
lbls[i].Value = pprofBlock
case pprofGoDeltaProfMutex:
lbls[i].Value = pprofMutex
}
}
continue
}

publicLabels = append(publicLabels, l)
}
url := urlFromTarget(lbls, params)
Expand Down
5 changes: 5 additions & 0 deletions internal/component/pyroscope/scrape/target_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package scrape

import (
"github.com/stretchr/testify/assert"
"net/url"
"sort"
"testing"
Expand Down Expand Up @@ -283,6 +284,10 @@ func Test_NewTarget_godeltaprof(t *testing.T) {

require.NotEqual(t, withGodeltaprof.allLabels, withoutGodeltaprof.allLabels)
require.Equal(t, withGodeltaprof.publicLabels, withoutGodeltaprof.publicLabels)
assert.Equal(t, pprofMemory, withGodeltaprof.allLabels.Get(model.MetricNameLabel))
assert.Equal(t, pprofMemory, withoutGodeltaprof.allLabels.Get(model.MetricNameLabel))
assert.Equal(t, "/debug/pprof/heap", withoutGodeltaprof.allLabels.Get(ProfilePath))
assert.Equal(t, "/debug/pprof/delta_heap", withGodeltaprof.allLabels.Get(ProfilePath))
}

func Test_targetsFromGroup_withSpecifiedDeltaProfilingDuration(t *testing.T) {
Expand Down

0 comments on commit c52e9ce

Please sign in to comment.