Skip to content

Commit

Permalink
Update configure() to newConfig() per new style guide (#336)
Browse files Browse the repository at this point in the history
* Update configure() to newConfig() per new style guide

* Update gocql newConfig to reflect correct type it initializes

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
  • Loading branch information
Aneurysm9 and MrAlias committed Sep 11, 2020
1 parent 071a049 commit 9e80ea6
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
`labstack/echo`, `emicklei/go-restful`, `bradfitz/gomemcache`, `Shopify/sarama`, `net/http` and `beego`. (#303)
- Update instrumentation guidelines about uniform provider options. Also, update style guide. (#303)
- Make config struct of instrumentation unexported. (#303)
- Instrumentations have been updated to adhere to the [configuration style guide's](https://github.com/open-telemetry/opentelemetry-go/blob/master/CONTRIBUTING.md#config)
updated recommendation to use `newConfig()` instead of `configure()`. (#336)

## [0.11.0] - 2020-08-25

Expand Down
2 changes: 1 addition & 1 deletion instrumentation/github.com/astaxie/beego/beego.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func defaultSpanNameFormatter(operation string, req *http.Request) string {
// Parameter service should describe the name of the (virtual) server handling the request.
// The OTelBeegoMiddleWare can be configured using the provided Options.
func NewOTelBeegoMiddleWare(service string, options ...Option) beego.MiddleWare {
cfg := configure(options...)
cfg := newConfig(options...)

httpOptions := []otelhttp.Option{
otelhttp.WithTracerProvider(cfg.tracerProvider),
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/github.com/astaxie/beego/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func WithSpanNameFormatter(f SpanNameFormatter) OptionFunc {

// ------------------------------------------ Private Functions

func configure(options ...Option) *config {
func newConfig(options ...Option) *config {
config := &config{
tracerProvider: global.TraceProvider(),
meterProvider: global.MeterProvider(),
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/github.com/gocql/gocql/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func WithConnectInstrumentation(enabled bool) TracedSessionOption {

// ------------------------------------------ Private Functions

func configure(options ...TracedSessionOption) *TracedSessionConfig {
func newTracedSessionConfig(options ...TracedSessionOption) *TracedSessionConfig {
config := &TracedSessionConfig{
tracerProvider: global.TraceProvider(),
meterProvider: global.MeterProvider(),
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/github.com/gocql/gocql/gocql.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
// configuration enabling tracing for queries, batch queries, and connection attempts.
// You may use additional observers and disable specific tracing using the provided `TracedSessionOption`s.
func NewSessionWithTracing(ctx context.Context, cluster *gocql.ClusterConfig, options ...TracedSessionOption) (*gocql.Session, error) {
config := configure(options...)
config := newTracedSessionConfig(options...)
instruments := newInstruments(config.meterProvider)
tracer := config.tracerProvider.Tracer(
instrumentationName,
Expand Down
6 changes: 3 additions & 3 deletions instrumentation/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ var (
LabelNetworkReceive = []label.KeyValue{label.String("direction", "receive")}
)

// configure computes a config from a list of Options.
func configure(opts ...Option) config {
// newConfig computes a config from a list of Options.
func newConfig(opts ...Option) config {
c := config{
MeterProvider: global.MeterProvider(),
}
Expand All @@ -97,7 +97,7 @@ func configure(opts ...Option) config {

// Start initializes reporting of host metrics using the supplied config.
func Start(opts ...Option) error {
c := configure(opts...)
c := newConfig(opts...)
if c.MeterProvider == nil {
c.MeterProvider = global.MeterProvider()
}
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/net/http/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func NewTransport(base http.RoundTripper, opts ...Option) *Transport {
}

c := newConfig(append(defaultOpts, opts...)...)
t.configure(c)
t.applyConfig(c)

return &t
}

func (t *Transport) configure(c *config) {
func (t *Transport) applyConfig(c *config) {
t.tracer = c.Tracer
t.propagators = c.Propagators
t.spanStartOptions = c.SpanStartOptions
Expand Down
6 changes: 3 additions & 3 deletions instrumentation/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func (o metricProviderOption) ApplyRuntime(c *config) {
c.MeterProvider = o.Provider
}

// configure computes a config from the supplied Options.
func configure(opts ...Option) config {
// newConfig computes a config from the supplied Options.
func newConfig(opts ...Option) config {
c := config{
MeterProvider: global.MeterProvider(),
MinimumReadMemStatsInterval: DefaultMinimumReadMemStatsInterval,
Expand All @@ -100,7 +100,7 @@ func configure(opts ...Option) config {

// Start initializes reporting of runtime metrics using the supplied config.
func Start(opts ...Option) error {
c := configure(opts...)
c := newConfig(opts...)
if c.MinimumReadMemStatsInterval < 0 {
c.MinimumReadMemStatsInterval = DefaultMinimumReadMemStatsInterval
}
Expand Down

0 comments on commit 9e80ea6

Please sign in to comment.