diff --git a/api.go b/api.go index 77ab667..8361771 100644 --- a/api.go +++ b/api.go @@ -23,19 +23,6 @@ type Config struct { DisableGCRuns bool // this will disable automatic runtime.GC runs between getting the heap profiles HTTPHeaders map[string]string HTTPClient remote.HTTPClient - - // Deprecated: the field will be removed in future releases. - // Use BasicAuthUser and BasicAuthPassword instead. - AuthToken string // specify this token when using pyroscope cloud - // Deprecated: the field will be removed in future releases. - // Use UploadRate instead. - DisableAutomaticResets bool - // Deprecated: the field will be removed in future releases. - // DisableCumulativeMerge is ignored. - DisableCumulativeMerge bool - // Deprecated: the field will be removed in future releases. - // SampleRate is set to 100 and is not configurable. - SampleRate uint32 } type Profiler struct { @@ -59,7 +46,6 @@ func Start(cfg Config) (*Profiler, error) { } rc := remote.Config{ - AuthToken: cfg.AuthToken, TenantID: cfg.TenantID, BasicAuthUser: cfg.BasicAuthUser, BasicAuthPassword: cfg.BasicAuthPassword, @@ -76,14 +62,13 @@ func Start(cfg Config) (*Profiler, error) { } sc := SessionConfig{ - Upstream: uploader, - Logger: cfg.Logger, - AppName: cfg.ApplicationName, - Tags: cfg.Tags, - ProfilingTypes: cfg.ProfileTypes, - DisableGCRuns: cfg.DisableGCRuns, - DisableAutomaticResets: cfg.DisableAutomaticResets, - UploadRate: cfg.UploadRate, + Upstream: uploader, + Logger: cfg.Logger, + AppName: cfg.ApplicationName, + Tags: cfg.Tags, + ProfilingTypes: cfg.ProfileTypes, + DisableGCRuns: cfg.DisableGCRuns, + UploadRate: cfg.UploadRate, } s, err := NewSession(sc) diff --git a/example/simple/main.go b/example/simple/main.go index 272a1aa..3d36939 100644 --- a/example/simple/main.go +++ b/example/simple/main.go @@ -51,7 +51,6 @@ func main() { ApplicationName: "simple.golang.app-new", ServerAddress: "http://localhost:4040", Logger: pyroscope.StandardLogger, - AuthToken: os.Getenv("PYROSCOPE_AUTH_TOKEN"), TenantID: os.Getenv("PYROSCOPE_TENANT_ID"), BasicAuthUser: os.Getenv("PYROSCOPE_BASIC_AUTH_USER"), BasicAuthPassword: os.Getenv("PYROSCOPE_BASIC_AUTH_PASSWORD"), diff --git a/session.go b/session.go index 2bd2861..b78f497 100644 --- a/session.go +++ b/session.go @@ -2,7 +2,6 @@ package pyroscope import ( "bytes" - "math" "runtime" "runtime/debug" "runtime/pprof" @@ -20,8 +19,6 @@ type Session struct { profileTypes []ProfileType uploadRate time.Duration disableGCRuns bool - // Deprecated: the field will be removed in future releases. - DisableAutomaticResets bool logger Logger stopOnce sync.Once @@ -54,16 +51,6 @@ type SessionConfig struct { ProfilingTypes []ProfileType DisableGCRuns bool UploadRate time.Duration - - // Deprecated: the field will be removed in future releases. - // Use UploadRate instead. - DisableAutomaticResets bool - // Deprecated: the field will be removed in future releases. - // DisableCumulativeMerge is ignored. - DisableCumulativeMerge bool - // Deprecated: the field will be removed in future releases. - // SampleRate is set to 100 and is not configurable. - SampleRate uint32 } type flush struct { @@ -84,10 +71,6 @@ func NewSession(c SessionConfig) (*Session, error) { c.Logger.Infof(" DisableGCRuns: %+v", c.DisableGCRuns) c.Logger.Infof(" UploadRate: %+v", c.UploadRate) - if c.DisableAutomaticResets { - c.UploadRate = math.MaxInt64 - } - appName, err := mergeTagsWithAppName(c.AppName, newSessionID(), c.Tags) if err != nil { return nil, err diff --git a/upstream/remote/remote.go b/upstream/remote/remote.go index 8a21f4f..aed8821 100644 --- a/upstream/remote/remote.go +++ b/upstream/remote/remote.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "encoding/json" - "errors" "fmt" "io" "mime/multipart" @@ -13,24 +12,12 @@ import ( "path" "runtime/debug" "strconv" - "strings" "sync" "time" "github.com/grafana/pyroscope-go/upstream" ) -var errCloudTokenRequired = errors.New("please provide an authentication token." + - " You can find it here: https://pyroscope.io/cloud") - -const ( - authTokenDeprecationWarning = "Authtoken is specified, but deprecated and ignored. " + - "Please switch to BasicAuthUser and BasicAuthPassword. " + - "If you need to use Bearer token authentication for a custom setup, " + - "you can use the HTTPHeaders option to set the Authorization header manually." - cloudHostnameSuffix = "pyroscope.cloud" -) - type Remote struct { mu sync.Mutex cfg Config @@ -49,9 +36,6 @@ type HTTPClient interface { } type Config struct { - // Deprecated: AuthToken will be removed in future releases. - // Use BasicAuthUser and BasicAuthPassword instead. - AuthToken string BasicAuthUser string // http basic auth user BasicAuthPassword string // http basic auth password TenantID string @@ -101,10 +85,7 @@ func NewRemote(cfg Config) (*Remote, error) { return nil, err } - // authorize the token first - if cfg.AuthToken == "" && isOGPyroscopeCloud(u) { - return nil, errCloudTokenRequired - } + _ = u return r, nil } @@ -201,14 +182,8 @@ func (r *Remote) uploadProfile(j *upstream.UploadJob) error { request.Header.Set("Content-Type", contentType) // request.Header.Set("Content-Type", "binary/octet-stream+"+string(j.Format)) - switch { - case r.cfg.AuthToken != "" && isOGPyroscopeCloud(u): - request.Header.Set("Authorization", "Bearer "+r.cfg.AuthToken) - case r.cfg.BasicAuthUser != "" && r.cfg.BasicAuthPassword != "": + if r.cfg.BasicAuthUser != "" && r.cfg.BasicAuthPassword != "" { request.SetBasicAuth(r.cfg.BasicAuthUser, r.cfg.BasicAuthPassword) - case r.cfg.AuthToken != "": - request.Header.Set("Authorization", "Bearer "+r.cfg.AuthToken) - r.logger.Infof(authTokenDeprecationWarning) } if r.cfg.TenantID != "" { request.Header.Set("X-Scope-OrgID", r.cfg.TenantID) @@ -255,10 +230,6 @@ func (r *Remote) handleJobs() { } } -func isOGPyroscopeCloud(u *url.URL) bool { - return strings.HasSuffix(u.Host, cloudHostnameSuffix) -} - // do safe upload func (r *Remote) safeUpload(job *upstream.UploadJob) { defer func() { diff --git a/upstream/remote/remote_test.go b/upstream/remote/remote_test.go index 839d546..730e047 100644 --- a/upstream/remote/remote_test.go +++ b/upstream/remote/remote_test.go @@ -9,10 +9,8 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/grafana/pyroscope-go/internal/testutil" "github.com/grafana/pyroscope-go/upstream" @@ -24,35 +22,15 @@ func TestUploadProfile(t *testing.T) { cfg Config serverAddress string expectedAuthHeader string - expectWarning bool }{ { - name: "OG Pyroscope Cloud with AuthToken", - cfg: Config{ - AuthToken: "test-token", - Address: "https://example.pyroscope.cloud", - }, - expectedAuthHeader: "Bearer test-token", - expectWarning: false, - }, - { - name: "Non-OG Server with BasicAuth", + name: "Server with BasicAuth", cfg: Config{ BasicAuthUser: "user", BasicAuthPassword: "pass", Address: "https://example.com", }, expectedAuthHeader: "Basic dXNlcjpwYXNz", // Base64 encoded "user:pass" - expectWarning: false, - }, - { - name: "Non-OG Server with AuthToken (Deprecated)", - cfg: Config{ - AuthToken: "deprecated-token", - Address: "https://example.com", - }, - expectedAuthHeader: "Bearer deprecated-token", - expectWarning: true, }, } @@ -82,12 +60,6 @@ func TestUploadProfile(t *testing.T) { }) require.NoError(t, err) - if tt.expectWarning { - assert.Contains(t, logger.Lines(), authTokenDeprecationWarning) - } else { - assert.NotContains(t, logger.Lines(), authTokenDeprecationWarning) - } - mockClient.AssertCalled(t, "Do", mock.MatchedBy(func(req *http.Request) bool { return req.Header.Get("Authorization") == tt.expectedAuthHeader }))