Skip to content

Commit ab04d97

Browse files
author
Soumya Mohapatra
committed
metrics: enable native histograms on all duration metrics
Enable Prometheus native histogram collection (dual mode) by setting NativeHistogramBucketFactor: 1.1 on all duration-based histogram definitions across the SDK services. This provides exponentially-spaced buckets (schema=3, ~9% growth per bucket) alongside the existing fixed buckets, improving percentile accuracy without breaking existing monitoring setups. Affected services: - token/services/ttx (endorsement, audit approval, ordering durations) - token/services/ttx/finality (on-status duration) - token/services/auditor (audit, append durations) - token/services/certifier/interactive (certification request duration) - token/services/selector/sherdlock (selection duration) - token/services/network/fabricx/finality/queue (processing duration) - token/core/zkatdlog/nogh/v1 (ZK issue and transfer proof durations) The ImmediateRetries histogram (discrete integer distribution 0-5) is intentionally excluded as native histograms provide no benefit for small discrete distributions. Depends-On: hyperledger-labs/fabric-smart-client#XXXX Signed-off-by: Soumya8898 <soumyaranjanmohapatra784@gmail.com> Signed-off-by: Soumya Mohapatra <mohapatras@microsoft.com>
1 parent 9f8bc40 commit ab04d97

7 files changed

Lines changed: 67 additions & 39 deletions

File tree

token/core/zkatdlog/nogh/v1/metrics.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ import (
1515

1616
var (
1717
zkIssueDurationOpts = metrics.HistogramOpts{
18-
Name: "issue_duration",
19-
Help: "Duration of zk issue token",
20-
LabelNames: []string{"network", "channel", "namespace"},
21-
Buckets: utils.ExponentialBucketTimeRange(0, 1*time.Second, 10),
18+
Name: "issue_duration",
19+
Help: "Duration of zk issue token",
20+
LabelNames: []string{"network", "channel", "namespace"},
21+
Buckets: utils.ExponentialBucketTimeRange(0, 1*time.Second, 10),
22+
NativeHistogramBucketFactor: 1.1,
23+
NativeHistogramMaxBucketNumber: 100,
2224
}
2325
zkTransferDurationOpts = metrics.HistogramOpts{
24-
Name: "transfer_duration",
25-
Help: "Duration of zk transfer token",
26-
LabelNames: []string{"network", "channel", "namespace"},
27-
Buckets: utils.ExponentialBucketTimeRange(0, 1*time.Second, 10),
26+
Name: "transfer_duration",
27+
Help: "Duration of zk transfer token",
28+
LabelNames: []string{"network", "channel", "namespace"},
29+
Buckets: utils.ExponentialBucketTimeRange(0, 1*time.Second, 10),
30+
NativeHistogramBucketFactor: 1.1,
31+
NativeHistogramMaxBucketNumber: 100,
2832
}
2933
)
3034

token/services/auditor/metrics.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,22 @@ func newMetrics(p metrics.Provider) *Metrics {
4040

4141
return &Metrics{
4242
AuditDuration: p.NewHistogram(metrics.HistogramOpts{
43-
Name: "auditor_audit_duration_seconds",
44-
Help: "Histogram of Audit() processing time per transaction (including lock acquisition), in seconds",
45-
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
43+
Name: "auditor_audit_duration_seconds",
44+
Help: "Histogram of Audit() processing time per transaction (including lock acquisition), in seconds",
45+
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
46+
NativeHistogramBucketFactor: 1.1,
47+
NativeHistogramMaxBucketNumber: 100,
4648
}),
4749
AuditLockConflicts: p.NewCounter(metrics.CounterOpts{
4850
Name: "auditor_audit_lock_conflicts_total",
4951
Help: "Total number of Audit() calls that failed to acquire enrollment-ID locks",
5052
}),
5153
AppendDuration: p.NewHistogram(metrics.HistogramOpts{
52-
Name: "auditor_append_duration_seconds",
53-
Help: "Histogram of Append() processing time per transaction, in seconds",
54-
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
54+
Name: "auditor_append_duration_seconds",
55+
Help: "Histogram of Append() processing time per transaction, in seconds",
56+
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
57+
NativeHistogramBucketFactor: 1.1,
58+
NativeHistogramMaxBucketNumber: 100,
5559
}),
5660
AppendErrors: p.NewCounter(metrics.CounterOpts{
5761
Name: "auditor_append_errors_total",

token/services/certifier/interactive/metrics.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ var (
1818
}
1919

2020
certificationRequestDuration = metrics.HistogramOpts{
21-
Name: "certification_request_duration_seconds",
22-
Help: "Histogram of certification batch request durations in seconds.",
23-
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
24-
LabelNames: []string{"channel", "namespace"},
21+
Name: "certification_request_duration_seconds",
22+
Help: "Histogram of certification batch request durations in seconds.",
23+
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
24+
LabelNames: []string{"channel", "namespace"},
25+
NativeHistogramBucketFactor: 1.1,
26+
NativeHistogramMaxBucketNumber: 100,
2527
}
2628

2729
certificationErrors = metrics.CounterOpts{

token/services/network/fabricx/finality/queue/metrics.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ func newMetrics(p metrics.Provider) *Metrics {
4848
Help: "Total number of errors returned by event.Process in worker goroutines",
4949
}),
5050
ProcessingDuration: p.NewHistogram(metrics.HistogramOpts{
51-
Name: "finality_queue_processing_duration_seconds",
52-
Help: "Histogram of successful event processing time in worker goroutines (seconds)",
53-
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5},
51+
Name: "finality_queue_processing_duration_seconds",
52+
Help: "Histogram of successful event processing time in worker goroutines (seconds)",
53+
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5},
54+
NativeHistogramBucketFactor: 1.1,
55+
NativeHistogramMaxBucketNumber: 100,
5456
}),
5557
}
5658
}

token/services/selector/sherdlock/metrics.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ func NewMetrics(p metrics.Provider) *Metrics {
3838
LabelNames: []string{fetcherTypeLabel},
3939
}),
4040
SelectionDuration: p.NewHistogram(metrics.HistogramOpts{
41-
Name: "selection_duration_seconds",
42-
Help: "Duration of a token selection call in seconds",
43-
Buckets: selectionDurationBuckets,
41+
Name: "selection_duration_seconds",
42+
Help: "Duration of a token selection call in seconds",
43+
Buckets: selectionDurationBuckets,
44+
NativeHistogramBucketFactor: 1.1,
45+
NativeHistogramMaxBucketNumber: 100,
4446
}),
4547
SelectionOutcome: p.NewCounter(metrics.CounterOpts{
4648
Name: "selection_outcome_total",

token/services/ttx/finality/metrics.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ func newMetrics(p metrics.Provider) *Metrics {
5858
Help: "Total number of transactions whose finality processing was abandoned after all retries were exhausted",
5959
}),
6060
OnStatusDuration: p.NewHistogram(metrics.HistogramOpts{
61-
Name: "finality_listener_on_status_duration_seconds",
62-
Help: "Histogram of total OnStatus processing time per transaction (including retries), in seconds",
63-
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
61+
Name: "finality_listener_on_status_duration_seconds",
62+
Help: "Histogram of total OnStatus processing time per transaction (including retries), in seconds",
63+
Buckets: []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
64+
NativeHistogramBucketFactor: 1.1,
65+
NativeHistogramMaxBucketNumber: 100,
6466
}),
6567
}
6668
}

token/services/ttx/metrics.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import (
1515

1616
var defaultDurationBuckets = []float64{.01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 30}
1717

18+
// defaultNativeHistogramBucketFactor sets the resolution for native histogram
19+
// buckets (schema=3, ~9% growth between boundaries). Setting this alongside
20+
// classic Buckets enables dual-mode emission: old scrapers see classic buckets,
21+
// new scrapers get the higher-resolution native histogram data.
22+
const defaultNativeHistogramBucketFactor = 1.1
23+
1824
var (
1925
spKey = reflect.TypeOf((*Metrics)(nil))
2026

@@ -34,22 +40,28 @@ var (
3440
LabelNames: []string{"network", "channel", "namespace"},
3541
}
3642
endorsementDuration = metrics.HistogramOpts{
37-
Name: "endorsement_duration_seconds",
38-
Help: "Duration of the full endorsement collection phase including signatures, audit, and chaincode approval.",
39-
LabelNames: []string{"network", "channel", "namespace"},
40-
Buckets: defaultDurationBuckets,
43+
Name: "endorsement_duration_seconds",
44+
Help: "Duration of the full endorsement collection phase including signatures, audit, and chaincode approval.",
45+
LabelNames: []string{"network", "channel", "namespace"},
46+
Buckets: defaultDurationBuckets,
47+
NativeHistogramBucketFactor: defaultNativeHistogramBucketFactor,
48+
NativeHistogramMaxBucketNumber: 100,
4149
}
4250
auditApprovalDuration = metrics.HistogramOpts{
43-
Name: "audit_approval_duration_seconds",
44-
Help: "Duration of the auditor approval phase including validation, append, and signing.",
45-
LabelNames: []string{"network", "channel", "namespace"},
46-
Buckets: defaultDurationBuckets,
51+
Name: "audit_approval_duration_seconds",
52+
Help: "Duration of the auditor approval phase including validation, append, and signing.",
53+
LabelNames: []string{"network", "channel", "namespace"},
54+
Buckets: defaultDurationBuckets,
55+
NativeHistogramBucketFactor: defaultNativeHistogramBucketFactor,
56+
NativeHistogramMaxBucketNumber: 100,
4757
}
4858
orderingDuration = metrics.HistogramOpts{
49-
Name: "ordering_duration_seconds",
50-
Help: "Duration of the transaction broadcast to the ordering service.",
51-
LabelNames: []string{"network", "channel", "namespace"},
52-
Buckets: defaultDurationBuckets,
59+
Name: "ordering_duration_seconds",
60+
Help: "Duration of the transaction broadcast to the ordering service.",
61+
LabelNames: []string{"network", "channel", "namespace"},
62+
Buckets: defaultDurationBuckets,
63+
NativeHistogramBucketFactor: defaultNativeHistogramBucketFactor,
64+
NativeHistogramMaxBucketNumber: 100,
5365
}
5466
)
5567

0 commit comments

Comments
 (0)