Skip to content

Commit

Permalink
influxdbreceiver: update to pass TelemetrySettings in ToServer
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Boten committed Sep 13, 2021
1 parent 089ccbe commit 52f311f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions receiver/influxdbreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,5 @@ func createDefaultConfig() config.Receiver {
}

func createMetricsReceiver(_ context.Context, params component.ReceiverCreateSettings, cfg config.Receiver, nextConsumer consumer.Metrics) (component.MetricsReceiver, error) {
influxLogger := newZapInfluxLogger(params.Logger)

return newMetricsReceiver(cfg.(*Config), influxLogger, nextConsumer)
return newMetricsReceiver(cfg.(*Config), params.TelemetrySettings, nextConsumer)
}
8 changes: 6 additions & 2 deletions receiver/influxdbreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ type metricsReceiver struct {
wg sync.WaitGroup

logger common.Logger

settings component.TelemetrySettings
}

func newMetricsReceiver(config *Config, influxLogger common.Logger, nextConsumer consumer.Metrics) (*metricsReceiver, error) {
func newMetricsReceiver(config *Config, settings component.TelemetrySettings, nextConsumer consumer.Metrics) (*metricsReceiver, error) {
influxLogger := newZapInfluxLogger(settings.Logger)
converter, err := influx2otel.NewLineProtocolToOtelMetrics(influxLogger)
if err != nil {
return nil, err
Expand All @@ -51,6 +54,7 @@ func newMetricsReceiver(config *Config, influxLogger common.Logger, nextConsumer
httpServerSettings: &config.HTTPServerSettings,
converter: converter,
logger: influxLogger,
settings: settings,
}
return receiver, nil
}
Expand All @@ -66,7 +70,7 @@ func (r *metricsReceiver) Start(_ context.Context, host component.Host) error {
router.HandleFunc("/api/v2/write", r.handleWrite) // InfluxDB 2.x

r.wg.Add(1)
r.server = r.httpServerSettings.ToServer(router)
r.server = r.httpServerSettings.ToServer(router, r.settings)
go func() {
defer r.wg.Done()
if err := r.server.Serve(ln); err != nil && err != http.ErrServerClosed {
Expand Down

0 comments on commit 52f311f

Please sign in to comment.