Skip to content

Commit

Permalink
profiler: remove WithHostname
Browse files Browse the repository at this point in the history
  • Loading branch information
gbbr committed Feb 21, 2020
1 parent 96ee23d commit d12f0ad
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 17 deletions.
7 changes: 0 additions & 7 deletions profiler/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ func WithURL(url string) Option {
}
}

// WithHostname allows specifying a custom hostname.
func WithHostname(hostname string) Option {
return func(cfg *config) {
cfg.hostname = hostname
}
}

// WithPeriod specifies the interval at which to collect profiles.
func WithPeriod(d time.Duration) Option {
return func(cfg *config) {
Expand Down
6 changes: 0 additions & 6 deletions profiler/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ func TestOptions(t *testing.T) {
assert.Equal(t, "my-url", cfg.apiURL)
})

t.Run("WithHostname", func(t *testing.T) {
var cfg config
WithHostname("my-hostname")(&cfg)
assert.Equal(t, "my-hostname", cfg.hostname)
})

t.Run("WithPeriod", func(t *testing.T) {
var cfg config
WithPeriod(2 * time.Second)(&cfg)
Expand Down
3 changes: 1 addition & 2 deletions profiler/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ var (
var ErrMissingAPIKey = errors.New("API key is missing; provide it using the profiler.WithAPIKey option")

// Start starts the profiler. It may return an error if an API key is not provided by means of
// the WithAPIKey option, or if a hostname is not found. In the latter case, it may be provided
// using the WithHostname option.
// the WithAPIKey option, or if a hostname is not found.
func Start(opts ...Option) error {
cfg := defaultConfig()
for _, opt := range opts {
Expand Down
4 changes: 2 additions & 2 deletions profiler/profiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ func TestStart(t *testing.T) {
})

t.Run("options", func(t *testing.T) {
if err := Start(WithAPIKey("123"), WithHostname("my-host")); err != nil {
if err := Start(WithAPIKey("123")); err != nil {
t.Fatal(err)
}
defer Stop()

mu.Lock()
require.NotNil(t, activeProfiler)
assert.Equal(t, "my-host", activeProfiler.cfg.hostname)
assert.NotEmpty(t, activeProfiler.cfg.hostname)
mu.Unlock()
})
}
Expand Down

0 comments on commit d12f0ad

Please sign in to comment.