Skip to content

Commit

Permalink
[receiver/influxdbreceiver] log errors at debug level
Browse files Browse the repository at this point in the history
  • Loading branch information
seankhliao committed Nov 25, 2024
1 parent 5698c9d commit 59865aa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion receiver/influxdbreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/receiverhelper"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/sanitize"
)
Expand Down Expand Up @@ -129,6 +130,7 @@ func (r *metricsReceiver) handleWrite(w http.ResponseWriter, req *http.Request)
if precision, ok = precisions[precisionStr]; !ok {
w.WriteHeader(http.StatusBadRequest)
_, _ = fmt.Fprintf(w, "unrecognized precision '%s'", sanitize.String(precisionStr))
r.logger.Debug("unrecognized precision", "precision", sanitize.String(precisionStr))
return
}
}
Expand All @@ -145,6 +147,7 @@ func (r *metricsReceiver) handleWrite(w http.ResponseWriter, req *http.Request)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
_, _ = fmt.Fprintf(w, "failed to parse measurement on line %d", line)
r.logger.Debug("failed to parse measurement", "line", line, zap.Error(err))
return
}

Expand All @@ -155,6 +158,7 @@ func (r *metricsReceiver) handleWrite(w http.ResponseWriter, req *http.Request)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
_, _ = fmt.Fprintf(w, "failed to parse tag on line %d", line)
r.logger.Debug("failed to parse tag", "line", line, zap.Error(err))
return
}

Expand All @@ -165,26 +169,30 @@ func (r *metricsReceiver) handleWrite(w http.ResponseWriter, req *http.Request)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
_, _ = fmt.Fprintf(w, "failed to parse field on line %d", line)
r.logger.Debug("failed to parse field", "line", line, zap.Error(err))
return
}

ts, err := lpDecoder.Time(precision, time.Time{})
if err != nil {
w.WriteHeader(http.StatusBadRequest)
_, _ = fmt.Fprintf(w, "failed to parse timestamp on line %d", line)
r.logger.Debug("failed to parse timestamp", "line", line, zap.Error(err))
return
}

if err = lpDecoder.Err(); err != nil {
w.WriteHeader(http.StatusBadRequest)
_, _ = fmt.Fprintf(w, "failed to parse line: %s", err.Error())
r.logger.Debug("failed to parse line", "line", line, zap.Error(err))
return
}

err = batch.AddPoint(string(measurement), tags, fields, ts, common.InfluxMetricValueTypeUntyped)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
_, _ = fmt.Fprintf(w, "failed to append to the batch")
r.logger.Debug("failed to append to batch", "line", line, zap.Error(err))
return
}
}
Expand All @@ -197,7 +205,7 @@ func (r *metricsReceiver) handleWrite(w http.ResponseWriter, req *http.Request)
} else {
w.WriteHeader(http.StatusInternalServerError)
}
r.logger.Debug("failed to pass metrics to next consumer: %s", err)
r.logger.Debug("failed to pass metrics to next consumer", zap.Error(err))
return
}

Expand Down

0 comments on commit 59865aa

Please sign in to comment.