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: Improve log messages to be more informative #1322

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion cmd/refinery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,5 @@ func main() {
// unregister ourselves before we go
close(done)
time.Sleep(100 * time.Millisecond)
a.Logger.Error().Logf("Caught signal \"%s\"", sig)
a.Logger.Error().WithField("signal", sig).Logf("Caught OS signal")
}
11 changes: 6 additions & 5 deletions collect/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/sirupsen/logrus"
)

var ErrWouldBlock = errors.New("not adding span, channel buffer is full")
var ErrWouldBlock = errors.New("not adding span, channel buffer is full. Span will not be processed and will be lost.")
MikeGoldsmith marked this conversation as resolved.
Show resolved Hide resolved
var CollectorHealthKey = "collector"

type Collector interface {
Expand Down Expand Up @@ -270,7 +270,7 @@ func (i *InMemCollector) checkAlloc() {
WithField("num_traces_sent", len(tracesSent)).
WithField("datasize_sent", totalDataSizeSent).
WithField("new_trace_count", i.cache.GetCacheCapacity()).
Logf("evicting large traces early due to memory overage")
Logf("evicting large traces early due to memory overage. Evicted traces will be processed and if selected by sampling, sent to Honeycomb.")
MikeGoldsmith marked this conversation as resolved.
Show resolved Hide resolved

// Manually GC here - without this we can easily end up evicting more than we
// need to, since total alloc won't be updated until after a GC pass.
Expand Down Expand Up @@ -796,7 +796,7 @@ func (i *InMemCollector) send(trace *types.Trace, sendReason string) {
// if we're supposed to drop this trace, and dry run mode is not enabled, then we're done.
if !shouldSend && !i.Config.GetIsDryRun() {
i.Metrics.Increment("trace_send_dropped")
i.Logger.Info().WithFields(logFields).Logf("Dropping trace because of sampling")
i.Logger.Info().WithFields(logFields).Logf("Dropping trace because of sampling decision")
return
}
i.Metrics.Increment("trace_send_kept")
Expand All @@ -805,9 +805,10 @@ func (i *InMemCollector) send(trace *types.Trace, sendReason string) {

// ok, we're not dropping this trace; send all the spans
if i.Config.GetIsDryRun() && !shouldSend {
i.Logger.Info().WithFields(logFields).Logf("Trace would have been dropped, but dry run mode is enabled")
i.Logger.Info().WithFields(logFields).Logf("Trace would have been dropped, but sending because dry run mode is enabled")
} else {
i.Logger.Info().WithFields(logFields).Logf("Sending trace")
}
i.Logger.Info().WithFields(logFields).Logf("Sending trace")
for _, sp := range trace.GetSpans() {
if i.Config.GetAddRuleReasonToTrace() {
sp.Data["meta.refinery.reason"] = reason
Expand Down
2 changes: 1 addition & 1 deletion collect/stressRelief.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (s *StressRelief) UpdateFromConfig(cfg config.StressReliefConfig) {
s.mode = Always
default: // validation shouldn't let this happen but we'll be safe...
s.mode = Never
s.Logger.Error().Logf("StressRelief mode is '%s' which shouldn't happen", cfg.Mode)
s.Logger.Error().WithString("mode", cfg.Mode).Logf("Invalid StressRelief mode")
}
s.Logger.Debug().WithField("mode", s.mode).Logf("setting StressRelief mode")

Expand Down
10 changes: 5 additions & 5 deletions metrics/otel_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (o *OTelMetrics) Register(name string, metricType string) {
case "counter":
ctr, err := o.meter.Int64Counter(name)
if err != nil {
o.Logger.Error().WithString("msg", "failed to create counter").WithString("name", name)
MikeGoldsmith marked this conversation as resolved.
Show resolved Hide resolved
o.Logger.Error().WithString("name", name).Logf("failed to create counter")
return
}
o.counters[name] = ctr
Expand All @@ -210,26 +210,26 @@ func (o *OTelMetrics) Register(name string, metricType string) {
metric.WithFloat64Callback(f),
)
if err != nil {
o.Logger.Error().WithString("msg", "failed to create gauge").WithString("name", name)
o.Logger.Error().WithString("name", name).Logf("failed to create gauge")
return
}
o.gauges[name] = g
case "histogram":
h, err := o.meter.Float64Histogram(name)
if err != nil {
o.Logger.Error().WithString("msg", "failed to create histogram").WithString("name", name)
o.Logger.Error().WithString("name", name).Logf("failed to create histogram")
return
}
o.histograms[name] = h
case "updown":
ud, err := o.meter.Int64UpDownCounter(name)
if err != nil {
o.Logger.Error().WithString("msg", "failed to create updown").WithString("name", name)
o.Logger.Error().WithString("name", name).Logf("failed to create updown counter")
return
}
o.updowns[name] = ud
default:
o.Logger.Error().WithString("msg", "unknown metric type").WithString("type", metricType)
o.Logger.Error().WithString("type", metricType).Logf("unknown metric type")
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion sharder/deterministic.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (d *DeterministicSharder) Start() error {
time.Sleep(5 * time.Second)
}

d.Logger.Error().WithFields(map[string]interface{}{"peers": d.peers, "self": self}).Logf("list of current peers")
d.Logger.Error().WithFields(map[string]interface{}{"peers": d.peers, "self": self}).Logf("failed to find self in the peer list")
return errors.New("failed to find self in the peer list")
}

Expand Down
Loading