forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage: make pebbleLogger.Eventf also log
This is useful when tracing is not enabled, but verbosity of logging can be increased. Also, we currently have gaps in context propagation in tracing which this can help mitigate for scenarios where slowness is reproducible. Relates to cockroachdb/pebble#3728 Epic: none Release note: None
- Loading branch information
1 parent
7ca8340
commit 6442226
Showing
5 changed files
with
132 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package storage | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/cockroachdb/pebble" | ||
) | ||
|
||
type pebbleLogger struct { | ||
ctx context.Context | ||
depth int | ||
} | ||
|
||
var _ pebble.LoggerAndTracer = pebbleLogger{} | ||
|
||
func (l pebbleLogger) Infof(format string, args ...interface{}) { | ||
log.Storage.InfofDepth(l.ctx, l.depth, format, args...) | ||
} | ||
|
||
func (l pebbleLogger) Fatalf(format string, args ...interface{}) { | ||
log.Storage.FatalfDepth(l.ctx, l.depth, format, args...) | ||
} | ||
|
||
// pebble.LoggerAndTracer does not expose verbosity levels in its logging | ||
// interface, and Pebble logs go to a separate STORAGE channel. | ||
// | ||
// The tracing part of the interface is meant for user-facing activities, so | ||
// in addition to outputting the event when tracing is enabled, we also log. | ||
// The eventAlsoLogVerbosityLevel of 2 is chosen semi-arbitrarily since this | ||
// is the only verbosity level in this file. | ||
const eventAlsoLogVerbosityLevel = 2 | ||
|
||
func (l pebbleLogger) Eventf(ctx context.Context, format string, args ...interface{}) { | ||
log.VEventf(ctx, eventAlsoLogVerbosityLevel, format, args...) | ||
} | ||
|
||
func (l pebbleLogger) IsTracingEnabled(ctx context.Context) bool { | ||
return log.HasSpanOrEvent(ctx) || log.ExpensiveLogEnabled(ctx, eventAlsoLogVerbosityLevel) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters