Skip to content

Commit

Permalink
Merge pull request #139 from newrelic/jthurman/servicename
Browse files Browse the repository at this point in the history
fix(newrelic): Add option to set ServiceName in Config
  • Loading branch information
Jonathan Thurman authored Feb 19, 2020
2 parents fbdad71 + f14d227 commit c5c220c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions newrelic/newrelic.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ func ConfigUserAgent(ua string) ConfigOption {
}
}

// ConfigServiceName sets the service name logged
func ConfigServiceName(name string) ConfigOption {
return func(cfg *config.Config) error {
if name != "" {
cfg.ServiceName = name
}

return nil
}
}

// ConfigBaseURL sets the base URL used to make requests to the REST API V2.
func ConfigBaseURL(url string) ConfigOption {
return func(cfg *config.Config) error {
Expand Down
8 changes: 8 additions & 0 deletions newrelic/newrelic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ func TestNew_optionUserAgent(t *testing.T) {
assert.NoError(t, err)
}

func TestNew_optionServiceName(t *testing.T) {
t.Parallel()

nr, err := New(ConfigAPIKey(testAPIkey), ConfigServiceName("my-service"))
assert.NotNil(t, nr)
assert.NoError(t, err)
}

func TestNew_optionBaseURL(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit c5c220c

Please sign in to comment.