Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
thampiotr committed Jan 22, 2025
1 parent 45ab51b commit 82ce9f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion internal/component/discovery/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ func TestDecodeMap(t *testing.T) {
get, ok := actual.Get("foo")
require.True(t, ok)
require.Equal(t, "bar", get)

actual.Delete("foo")
get, ok = actual.Get("foo")
require.False(t, ok)
require.Equal(t, "", get)

// Some loggers print targets out, check it's all good. But without caring about order.
str := fmt.Sprintf("%s", actual)
valid := str == `{a="5", b="10"}` || str == `{b="10", a="5"}`
require.True(t, valid)
}

func TestConvertFromNative(t *testing.T) {
Expand Down
9 changes: 7 additions & 2 deletions internal/component/pyroscope/java/java.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,14 @@ func (j *javaComponent) updateTargets(args Arguments) {

active := make(map[int]struct{})
for _, target := range args.Targets {
pid64, err := strconv.ParseInt(target[labelProcessID], 10, 32)
pidStr, ok := target.Get(labelProcessID)
if !ok {
_ = level.Error(j.opts.Logger).Log("msg", "could not find PID label", "pid", pidStr)
continue
}
pid64, err := strconv.ParseInt(pidStr, 10, 32)
if err != nil {
_ = level.Error(j.opts.Logger).Log("msg", "could not convert process ID to a 32 bit integer", "pid", target[labelProcessID], "err", err)
_ = level.Error(j.opts.Logger).Log("msg", "could not convert process ID to a 32 bit integer", "pid", pidStr, "err", err)
continue
}
pid := int(pid64)
Expand Down

0 comments on commit 82ce9f8

Please sign in to comment.