This is an automated email from the ASF dual-hosted git repository. ButterBright pushed a commit to branch v0.10.x in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit 7b3227edf1658b63c94ad9f5cf5a6000a2be1721 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 bd27150f3..c752a8c6b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ Release Notes. - 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 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 [...] +- 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_ [...] ## 0.10.2 diff --git a/banyand/trace/metadata.go b/banyand/trace/metadata.go index 60bc4731d..9e2594cff 100644 --- a/banyand/trace/metadata.go +++ b/banyand/trace/metadata.go @@ -607,7 +607,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 d3c520afa..0c3594e2f 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()) + }) + } +}
