Skip to content

Commit

Permalink
profiler: add WithService
Browse files Browse the repository at this point in the history
This change adds `WithService` to the tracer as an alias for
`WithServiceName` which now becomes marked as deprecated. It also
renames `WithServiceName` to `WithService` in the `profiler` package.

Additionally, these are added to the example, along with the version
tag.
  • Loading branch information
gbbr committed Feb 24, 2020
1 parent 9f381b9 commit 2eb7e00
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion ddtrace/tracer/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,14 @@ func WithPropagator(p Propagator) StartOption {
}
}

// WithServiceName sets the default service name to be used with the tracer.
// WithServiceName sets the default service name to be used with the tracer. It is
// deprecated in favour of WithService and will be removed in the next major version.
func WithServiceName(name string) StartOption {
return WithService(name)
}

// WithService sets the default service name to be used with the tracer.
func WithService(name string) StartOption {
return func(c *config) {
c.serviceName = name
}
Expand Down
2 changes: 2 additions & 0 deletions profiler/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import (
func Example() {
err := profiler.Start(
profiler.WithAPIKey("123key"),
profiler.WithService("users-db"),
profiler.WithEnv("staging"),
profiler.WithTags("version:1.2.0"),
)
if err != nil {
log.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions profiler/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ func WithProfileTypes(types ...ProfileType) Option {
}
}

// WithServiceName specifies the service name to attach a profile.
func WithServiceName(name string) Option {
// WithService specifies the service name to attach a profile.
func WithService(name string) Option {
return func(cfg *config) {
cfg.service = name
}
Expand Down
2 changes: 1 addition & 1 deletion profiler/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestTryUpload(t *testing.T) {
defer func(old *http.Client) { httpClient = old }(httpClient)
p := unstartedProfiler(
WithURL(srv.URL+"/"),
WithServiceName("my-service"),
WithService("my-service"),
WithEnv("my-env"),
WithTags("tag1:1", "tag2:2"),
)
Expand Down

0 comments on commit 2eb7e00

Please sign in to comment.