Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: structured logging for HTTP server ErrorLog #21235

Merged
merged 2 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The prefix used for Prometheus metrics from the query controller has changed fro
1. [21090](https://github.com/influxdata/influxdb/pull/21090): Update UI to match InfluxDB Cloud.
1. [21127](https://github.com/influxdata/influxdb/pull/21127): Allow for disabling concurrency-limits in Flux controller.
1. [21158](https://github.com/influxdata/influxdb/pull/21158): Replace unique resource IDs (UI assets, backup shards) with slugs to reduce cardinality of telemetry data.
1. [21235](https://github.com/influxdata/influxdb/pull/21235): HTTP server errors output logs following the standard format.

### Bug Fixes

Expand Down
5 changes: 3 additions & 2 deletions cmd/influxd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ func (m *Launcher) run(ctx context.Context, opts *InfluxdOpts) (err error) {
if !opts.ReportingDisabled {
m.runReporter(ctx)
}
if err := m.runHTTP(opts, httpHandler); err != nil {
if err := m.runHTTP(opts, httpHandler, httpLogger); err != nil {
return err
}

Expand All @@ -944,7 +944,7 @@ func (m *Launcher) run(ctx context.Context, opts *InfluxdOpts) (err error) {
// runHTTP configures and launches a listener for incoming HTTP(S) requests.
// The listener is run in a separate goroutine. If it fails to start up, it
// will cancel the launcher.
func (m *Launcher) runHTTP(opts *InfluxdOpts, handler nethttp.Handler) error {
func (m *Launcher) runHTTP(opts *InfluxdOpts, handler nethttp.Handler, httpLogger *zap.Logger) error {
log := m.log.With(zap.String("service", "tcp-listener"))

m.httpServer = &nethttp.Server{
Expand All @@ -954,6 +954,7 @@ func (m *Launcher) runHTTP(opts *InfluxdOpts, handler nethttp.Handler) error {
ReadTimeout: opts.HttpReadTimeout,
WriteTimeout: opts.HttpWriteTimeout,
IdleTimeout: opts.HttpIdleTimeout,
ErrorLog: zap.NewStdLog(httpLogger),
}

ln, err := net.Listen("tcp", opts.HttpBindAddress)
Expand Down