Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to override the profile timestamp before upload #3161

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions cmd/profilecli/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"os"
"time"

"connectrpc.com/connect"
"github.com/go-kit/log/level"
Expand All @@ -23,8 +24,9 @@ func (c *phlareClient) pusherClient() pushv1connect.PusherServiceClient {

type uploadParams struct {
*phlareClient
paths []string
extraLabels map[string]string
paths []string
extraLabels map[string]string
overrideTimestamp bool
}

func addUploadParams(cmd commander) *uploadParams {
Expand All @@ -37,6 +39,7 @@ func addUploadParams(cmd commander) *uploadParams {

cmd.Arg("path", "Path(s) to profile(s) to upload").Required().ExistingFilesVar(&params.paths)
cmd.Flag("extra-labels", "Add additional labels to the profile(s)").StringMapVar(&params.extraLabels)
cmd.Flag("override-timestamp", "Set the profile timestamp to now").BoolVar(&params.overrideTimestamp)
return params
}

Expand Down Expand Up @@ -66,6 +69,14 @@ func upload(ctx context.Context, params *uploadParams) (err error) {
return err
}

if params.overrideTimestamp {
profile.TimeNanos = time.Now().UnixNano()
data, err = pprof.Marshal(profile.Profile, true)
if err != nil {
return err
}
}

// detect name if no name has been set
if lbl.Get(model.LabelNameProfileName) == "" {
name := "unknown"
Expand Down
Loading