This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new af0b2cf49 fix(trace): move storage metrics under trace.storage
subscope (#1155)
af0b2cf49 is described below
commit af0b2cf49f06872b6ba9dd231acbfd00c86e9931
Author: Gao Hongtao <[email protected]>
AuthorDate: Thu Jun 4 20:14:03 2026 +0800
fix(trace): move storage metrics under trace.storage subscope (#1155)
The trace package's StorageMetricsFactory was using the root `trace`
scope, so per-segment inverted-index metrics from
`pkg/index/inverted` were emitted as `banyandb_trace_inverted_index_*`.
The dashboard in `docs/operation/grafana-cluster.json` (and the
sibling stream package) expect `banyandb_trace_storage_inverted_index_*`.
---
CHANGES.md | 1 +
banyand/trace/metadata.go | 2 +-
banyand/trace/metrics.go | 4 +--
banyand/trace/storage_scope_test.go | 54 +++++++++++++++++++++++++++++++++++++
4 files changed, 58 insertions(+), 3 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 19ab8f97d..2c4c52f9a 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -103,6 +103,7 @@ Release Notes.
- Fix lifecycle migration placing data in the wrong target segment when the
source segment interval is not a multiple of the target stage's interval, by
row-level replaying parts that straddle a target-segment boundary instead of
chunk-copying them into a single segment.
- Fix trace query identity-tag projection: when `trace_id`/`span_id` are
explicitly projected, reconstruct them from span identity at response build
time instead of requesting them as stored tags, and preserve tag order with
null-filled per-span value alignment in the distributed trace result iterator.
- Fix measure, stream, and trace queries returning data from segments already
expired by the TTL. Retention removes a segment only on its next scheduled run,
so a fully expired segment can linger on disk and keep serving TTL-expired
data; queries now skip segments whose whole time range is past the retention
deadline, matching retention's own removal condition.
+- Trace storage metrics now expose the `storage` sub-scope, matching the
`stream_storage_*` naming. The `StorageMetricsFactory` for trace switched from
the root `trace` scope to `trace.storage`, so per-segment inverted-index
metrics (`inverted_index_total_updates`, `inverted_index_total_doc_count`,
`inverted_index_total_term_searchers_started`) are now emitted as
`banyandb_trace_storage_*` instead of `banyandb_trace_*`, aligning the
dashboard query names. Other trace metrics (`trace_tst_ [...]
- Fix flaky measure snapshot tests that gated on the part directory appearing
in `tab/` as the flush-completion signal. That directory is created by the
first line of `memPart.mustFlush`, before the mem→file introduction reaches the
in-memory snapshot and before the `.snp` manifest is persisted, so under
`-race`/CI load `TakeFileSnapshot` could observe only mem parts and `Close`
could drop the in-flight flush; gate on the persisted `.snp` manifest instead.
- Fix FODC proxy corrupting Prometheus metric types. The agent dropped the `#
TYPE` line while parsing banyandb `/metrics`, the `StreamMetrics` proto carried
no type field, and the proxy guessed the type from a name-suffix heuristic —
downgrading counters to gauge, mislabeling `_count`-suffixed counters as
histograms, and splitting summaries into two conflicting `# TYPE` lines.
Capture the type with the Prometheus `expfmt` parser, store it in the flight
recorder, thread it through a new [...]
diff --git a/banyand/trace/metadata.go b/banyand/trace/metadata.go
index 08cf7d4e5..e7becbf73 100644
--- a/banyand/trace/metadata.go
+++ b/banyand/trace/metadata.go
@@ -636,7 +636,7 @@ func (s *supplier) OpenDB(groupSchema *commonv1.Group)
(resourceSchema.DB, error
Option: s.option,
SeriesIndexFlushTimeoutSeconds:
s.option.flushTimeout.Nanoseconds() / int64(time.Second),
SeriesIndexCacheMaxBytes:
int(s.option.seriesCacheMaxSize),
- StorageMetricsFactory:
s.omr.With(traceScope.ConstLabels(meter.ToLabelPairs(common.DBLabelNames(),
p.DBLabelValues()))),
+ StorageMetricsFactory:
s.omr.With(storageScope.ConstLabels(meter.ToLabelPairs(common.DBLabelNames(),
p.DBLabelValues()))),
SegmentIdleTimeout: segmentIdleTimeout,
DisableRetention: disableRetention,
DisableRotation: disableRotation,
diff --git a/banyand/trace/metrics.go b/banyand/trace/metrics.go
index 2d84dccee..2ff4597df 100644
--- a/banyand/trace/metrics.go
+++ b/banyand/trace/metrics.go
@@ -26,8 +26,8 @@ import (
)
var (
- streamScope = observability.RootScope.SubScope("trace")
- tbScope = streamScope.SubScope("tst")
+ tbScope = traceScope.SubScope("tst")
+ storageScope = traceScope.SubScope("storage")
)
type metrics struct {
diff --git a/banyand/trace/storage_scope_test.go
b/banyand/trace/storage_scope_test.go
new file mode 100644
index 000000000..3d3e458cd
--- /dev/null
+++ b/banyand/trace/storage_scope_test.go
@@ -0,0 +1,54 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package trace
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+
+ "github.com/apache/skywalking-banyandb/pkg/meter"
+)
+
+// TestStorageScopeNamespace verifies that the new storageScope in this
+// package produces the metric-name namespace expected by the dashboard
+// and by the sibling stream package.
+//
+// Expected namespace chain (root separator is "_"):
+//
+// banyandb → banyandb_trace → banyandb_trace_tst (tbScope, unchanged)
+// banyandb_trace_storage (storageScope, NEW)
+func TestStorageScopeNamespace(t *testing.T) {
+ cases := []struct {
+ name string
+ scope meter.Scope
+ want string
+ }{
+ {"traceScope", traceScope, "banyandb_trace"},
+ {"tbScope", tbScope, "banyandb_trace_tst"},
+ {"storageScope", storageScope, "banyandb_trace_storage"},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ hs, ok := tc.scope.(*meter.HierarchicalScope)
+ require.Truef(t, ok, "%s must be a
*meter.HierarchicalScope, got %T", tc.name, tc.scope)
+ assert.Equal(t, tc.want, hs.GetNamespace())
+ })
+ }
+}