Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
103914: Expose Ingestions Count Metric r=RahulAggarwal1016 a=RahulAggarwal1016

Fixes: #103744

This change exposes the `Ingest.Count` metric from Pebble to the
Cockroach side.

Related PR (Pebble Changes): cockroachdb/pebble#2568
Release note: None

104104: cli: fix bug in missing-flag warning r=knz a=miraradeva

When the server starts, the user is supposed to see a warning if neither `--listen-addr` nor `--advertise-addr` flags are specified. Currently, even if `--advertise-addr` is specified, the warning is displayed. This patch fixes the small bug causing this behavior.

Fixes: #103897

Epic: CRDB-28249

Release note (bug fix): Warning message for missing `--advertise-addr` flag is no longer displayed when the flag is specified upon server start.

Co-authored-by: Rahul Aggarwal <[email protected]>
Co-authored-by: Mira Radeva <[email protected]>
  • Loading branch information
3 people committed Jun 1, 2023
3 parents 214c573 + f97d24a + ab8b458 commit 08500af
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/generated/eventlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2708,6 +2708,7 @@ Note that because stats are scoped to the lifetime of the process, counters
| `FlushIngestCount` | | no |
| `FlushIngestTableCount` | | no |
| `FlushIngestTableBytes` | | no |
| `IngestCount` | ingest_count is the number of successful ingest operations (counter). | no |
| `MemtableSize` | memtable_size is the total size allocated to all memtables and (large) batches, in bytes (gauge). | no |
| `MemtableCount` | memtable_count is the count of memtables (gauge). | no |
| `MemtableZombieCount` | memtable_zombie_count is the count of memtables no longer referenced by the current DB state, but still in use by an iterator (gauge). | no |
Expand Down
13 changes: 13 additions & 0 deletions pkg/cli/interactive_tests/test_flags.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ interrupt
eexpect ":/# "
end_test

start_test "Check that using --advertise-addr does not cause a user warning."
send "$argv start-single-node --insecure --advertise-addr=172.31.11.189\r"
expect {
"WARNING: neither --listen-addr nor --advertise-addr was specified" {
report "unexpected WARNING: neither --listen-addr nor --advertise-addr was specified"
exit 1
}
}
eexpect "node starting"
interrupt
eexpect ":/# "
end_test

start_test "Check that --listening-url-file gets created with the right data"
send "$argv start-single-node --insecure --listening-url-file=foourl\r"
eexpect "node starting"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ func hintServerCmdFlags(ctx context.Context, cmd *cobra.Command) {
}

changed := func(flagName string) bool {
fl := pf.Lookup(cliflags.ListenAddr.Name)
fl := pf.Lookup(flagName)
return fl != nil && fl.Changed
}

Expand Down
16 changes: 15 additions & 1 deletion pkg/kv/kvserver/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ var (
Unit: metric.Unit_COUNT,
}

//Ingest metrics
metaIngestCount = metric.Metadata{
Name: "storage.ingest.count",
Help: "Number of successful ingestions performed",
Measurement: "Events",
Unit: metric.Unit_COUNT,
}

// Pebble metrics.
metaRdbBlockCacheHits = metric.Metadata{
Name: "rocksdb.block.cache.hits",
Expand Down Expand Up @@ -2325,6 +2333,9 @@ type StoreMetrics struct {
MaxLockWaitDurationNanos *metric.Gauge
MaxLockWaitQueueWaitersForLock *metric.Gauge

// Ingestion metrics
IngestCount *metric.Gauge

// Closed timestamp metrics.
ClosedTimestampMaxBehindNanos *metric.Gauge

Expand Down Expand Up @@ -2764,6 +2775,9 @@ func newStoreMetrics(histogramWindow time.Duration) *StoreMetrics {
BatchCommitWALRotWaitDuration: metric.NewGauge(metaBatchCommitWALRotDuration),
BatchCommitCommitWaitDuration: metric.NewGauge(metaBatchCommitCommitWaitDuration),

// Ingestion metrics
IngestCount: metric.NewGauge(metaIngestCount),

RdbCheckpoints: metric.NewGauge(metaRdbCheckpoints),

// Disk health metrics.
Expand Down Expand Up @@ -3114,6 +3128,7 @@ func (sm *StoreMetrics) updateEngineMetrics(m storage.Metrics) {
sm.FlushableIngestCount.Update(int64(m.Flush.AsIngestCount))
sm.FlushableIngestTableCount.Update(int64(m.Flush.AsIngestTableCount))
sm.FlushableIngestTableSize.Update(int64(m.Flush.AsIngestBytes))
sm.IngestCount.Update(int64(m.Ingest.Count))
sm.BatchCommitCount.Update(int64(m.BatchCommitStats.Count))
sm.BatchCommitDuration.Update(int64(m.BatchCommitStats.TotalDuration))
sm.BatchCommitSemWaitDuration.Update(int64(m.BatchCommitStats.SemaphoreWaitDuration))
Expand All @@ -3122,7 +3137,6 @@ func (sm *StoreMetrics) updateEngineMetrics(m storage.Metrics) {
sm.BatchCommitL0StallDuration.Update(int64(m.BatchCommitStats.L0ReadAmpWriteStallDuration))
sm.BatchCommitWALRotWaitDuration.Update(int64(m.BatchCommitStats.WALRotationDuration))
sm.BatchCommitCommitWaitDuration.Update(int64(m.BatchCommitStats.CommitWaitDuration))

// Update the maximum number of L0 sub-levels seen.
sm.l0SublevelsTracker.Lock()
sm.l0SublevelsTracker.swag.Record(timeutil.Now(), float64(m.Levels[0].Sublevels))
Expand Down
1 change: 1 addition & 0 deletions pkg/storage/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,7 @@ func (m *Metrics) AsStoreStatsEvent() eventpb.StoreStats {
FlushIngestCount: m.Flush.AsIngestCount,
FlushIngestTableCount: m.Flush.AsIngestTableCount,
FlushIngestTableBytes: m.Flush.AsIngestBytes,
IngestCount: m.Ingest.Count,
MemtableSize: m.MemTable.Size,
MemtableCount: m.MemTable.Count,
MemtableZombieCount: m.MemTable.ZombieCount,
Expand Down
9 changes: 9 additions & 0 deletions pkg/util/log/eventpb/json_encode_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/util/log/eventpb/storage_events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ message StoreStats {
uint64 flush_ingest_table_count = 36 [(gogoproto.jsontag) = ",omitempty"];
uint64 flush_ingest_table_bytes = 37 [(gogoproto.jsontag) = ",omitempty"];

// Ingest stats.

// ingest_count is the number of successful ingest operations (counter).
uint64 ingest_count = 38 [(gogoproto.jsontag) = ",omitempty"];

// Memtable stats.

// memtable_size is the total size allocated to all memtables and (large)
Expand Down

0 comments on commit 08500af

Please sign in to comment.