Skip to content

Commit 21169f2

Browse files
authored
Remove internal package from interface type to be potentially impleme… (#14)
* Remove internal package from interface type to be potentially implemented by thrid-party users * Provide logger for UnmarshalConfig
1 parent fa91f02 commit 21169f2

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

bootstrap.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func Run(ec *config.Extended, opts ...Option) {
8181
os.Exit(1)
8282
}
8383

84-
sr, err := gl.App.Metrics.NewReporter(logger)
84+
sr, err := gl.App.Metrics.NewReporter(logger.Logger)
8585
if err != nil {
8686
logger.Error("error initializing stats", zap.Error(err))
8787
}

config/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func Get(cc *CLIConfig, ec *Extended, logger *log.Logger) (*AppConfig, error) {
202202
return nil, err
203203
}
204204

205-
mc, err := ec.Metrics.UnmarshalConfig(data, *cc.ConfigFile)
205+
mc, err := ec.Metrics.UnmarshalConfig(data, *cc.ConfigFile, logger.Logger)
206206
if err != nil {
207207
return nil, err
208208
}

metrics/metrics.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ package metrics
2323
import (
2424
"time"
2525

26-
"github.com/uber/arachne/internal/log"
26+
"go.uber.org/zap"
2727
)
2828

2929
// Opt is an interface for config unmarshaled in local configuration files.
3030
type Opt interface {
31-
UnmarshalConfig(data []byte, fname string) (Config, error)
31+
UnmarshalConfig(data []byte, fname string, logger *zap.Logger) (Config, error)
3232
}
3333

3434
// Config is an interface for creating metrics-specific stats reporters.
3535
type Config interface {
36-
NewReporter(logger *log.Logger) (Reporter, error)
36+
NewReporter(logger *zap.Logger) (Reporter, error)
3737
}
3838

3939
// Tags is an alias of map[string]string, a type for tags associated with a statistic.

metrics/metrics_statsd.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import (
2424
"fmt"
2525
"time"
2626

27-
"github.com/uber/arachne/internal/log"
28-
2927
"github.com/DataDog/datadog-go/statsd"
3028
"github.com/pkg/errors"
3129
"go.uber.org/zap"
@@ -72,7 +70,7 @@ var (
7270
)
7371

7472
// UnmarshalConfig fetches the configuration file from local path.
75-
func (c StatsdConfiger) UnmarshalConfig(data []byte, fname string) (Config, error) {
73+
func (c StatsdConfiger) UnmarshalConfig(data []byte, fname string, logger *zap.Logger) (Config, error) {
7674

7775
cfg := new(StatsdConfig)
7876
if err := yaml.Unmarshal(data, cfg); err != nil {
@@ -89,7 +87,7 @@ func (c StatsdConfiger) UnmarshalConfig(data []byte, fname string) (Config, erro
8987
}
9088

9189
// NewReporter creates a new metrics backend talking to Statsd.
92-
func (c StatsdConfig) NewReporter(logger *log.Logger) (Reporter, error) {
90+
func (c StatsdConfig) NewReporter(logger *zap.Logger) (Reporter, error) {
9391
s, err := statsd.New(c.Metrics.Statsd.HostPort)
9492
if err != nil {
9593
return nil, err

0 commit comments

Comments
 (0)