Skip to content

Commit a670343

Browse files
committed
blobstore: Add metrics_tag config field
WIP; more description to come
1 parent 0941111 commit a670343

File tree

4 files changed

+437
-414
lines changed

4 files changed

+437
-414
lines changed

pkg/blobstore/configuration/new_blob_access.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,10 @@ func (nc *simpleNestedBlobAccessCreator) NewNestedBlobAccess(configuration *pb.B
546546
}).NewNestedBlobAccess(config.Backend, creator)
547547
case *pb.BlobAccessConfiguration_Label:
548548
if labelBackend, ok := nc.labels[backend.Label]; ok {
549-
return labelBackend, nil
549+
return BlobAccessInfo{
550+
BlobAccess: blobstore.NewMetricsBlobAccess(labelBackend.BlobAccess, clock.SystemClock, creator.GetStorageTypeName(), "label", configuration.GetMetricsTag()),
551+
DigestKeyFormat: labelBackend.DigestKeyFormat,
552+
}, nil
550553
}
551554
return BlobAccessInfo{}, status.Errorf(codes.InvalidArgument, "Label %#v not declared", backend.Label)
552555
}
@@ -556,7 +559,7 @@ func (nc *simpleNestedBlobAccessCreator) NewNestedBlobAccess(configuration *pb.B
556559
return BlobAccessInfo{}, err
557560
}
558561
return BlobAccessInfo{
559-
BlobAccess: blobstore.NewMetricsBlobAccess(backend.BlobAccess, clock.SystemClock, creator.GetStorageTypeName(), backendType),
562+
BlobAccess: blobstore.NewMetricsBlobAccess(backend.BlobAccess, clock.SystemClock, creator.GetStorageTypeName(), backendType, configuration.GetMetricsTag()),
560563
DigestKeyFormat: backend.DigestKeyFormat,
561564
}, nil
562565
}

pkg/blobstore/metrics_blob_access.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var (
2828
Help: "Size of blobs being inserted/retrieved, in bytes.",
2929
Buckets: prometheus.ExponentialBuckets(1.0, 2.0, 33),
3030
},
31-
[]string{"storage_type", "backend_type", "operation"})
31+
[]string{"storage_type", "backend_type", "operation", "metrics_tag"})
3232
blobAccessOperationsFindMissingBatchSize = prometheus.NewHistogramVec(
3333
prometheus.HistogramOpts{
3434
Namespace: "buildbarn",
@@ -37,7 +37,7 @@ var (
3737
Help: "Number of digests provided to FindMissing().",
3838
Buckets: prometheus.ExponentialBuckets(1.0, 2.0, 17),
3939
},
40-
[]string{"storage_type", "backend_type"})
40+
[]string{"storage_type", "backend_type", "metrics_tag"})
4141
blobAccessOperationsDurationSeconds = prometheus.NewHistogramVec(
4242
prometheus.HistogramOpts{
4343
Namespace: "buildbarn",
@@ -46,7 +46,7 @@ var (
4646
Help: "Amount of time spent per operation on blob access objects, in seconds.",
4747
Buckets: util.DecimalExponentialBuckets(-3, 6, 2),
4848
},
49-
[]string{"storage_type", "backend_type", "operation", "grpc_code"})
49+
[]string{"storage_type", "backend_type", "operation", "metrics_tag", "grpc_code"})
5050
)
5151

5252
type metricsBlobAccess struct {
@@ -66,7 +66,7 @@ type metricsBlobAccess struct {
6666

6767
// NewMetricsBlobAccess creates an adapter for BlobAccess that adds
6868
// basic instrumentation in the form of Prometheus metrics.
69-
func NewMetricsBlobAccess(blobAccess BlobAccess, clock clock.Clock, storageType, backendType string) BlobAccess {
69+
func NewMetricsBlobAccess(blobAccess BlobAccess, clock clock.Clock, storageType, backendType, metricsTag string) BlobAccess {
7070
blobAccessOperationsPrometheusMetrics.Do(func() {
7171
prometheus.MustRegister(blobAccessOperationsBlobSizeBytes)
7272
prometheus.MustRegister(blobAccessOperationsFindMissingBatchSize)
@@ -77,15 +77,15 @@ func NewMetricsBlobAccess(blobAccess BlobAccess, clock clock.Clock, storageType,
7777
blobAccess: blobAccess,
7878
clock: clock,
7979

80-
getBlobSizeBytes: blobAccessOperationsBlobSizeBytes.WithLabelValues(storageType, backendType, "Get"),
81-
getDurationSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "Get"}),
82-
getFromCompositeBlobSizeBytes: blobAccessOperationsBlobSizeBytes.WithLabelValues(storageType, backendType, "GetFromComposite"),
83-
getFromCompositeDurationSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "GetFromComposite"}),
84-
putBlobSizeBytes: blobAccessOperationsBlobSizeBytes.WithLabelValues(storageType, backendType, "Put"),
85-
putDurationSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "Put"}),
86-
findMissingBatchSize: blobAccessOperationsFindMissingBatchSize.WithLabelValues(storageType, backendType),
87-
findMissingDurationSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "FindMissing"}),
88-
getCapabilitiesSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "GetCapabilities"}),
80+
getBlobSizeBytes: blobAccessOperationsBlobSizeBytes.WithLabelValues(storageType, backendType, "Get", metricsTag),
81+
getDurationSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "Get", "metrics_tag": metricsTag}),
82+
getFromCompositeBlobSizeBytes: blobAccessOperationsBlobSizeBytes.WithLabelValues(storageType, backendType, "GetFromComposite", metricsTag),
83+
getFromCompositeDurationSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "GetFromComposite", "metrics_tag": metricsTag}),
84+
putBlobSizeBytes: blobAccessOperationsBlobSizeBytes.WithLabelValues(storageType, backendType, "Put", metricsTag),
85+
putDurationSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "Put", "metrics_tag": metricsTag}),
86+
findMissingBatchSize: blobAccessOperationsFindMissingBatchSize.WithLabelValues(storageType, backendType, metricsTag),
87+
findMissingDurationSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "FindMissing", "metrics_tag": metricsTag}),
88+
getCapabilitiesSeconds: blobAccessOperationsDurationSeconds.MustCurryWith(map[string]string{"storage_type": storageType, "backend_type": backendType, "operation": "GetCapabilities", "metrics_tag": metricsTag}),
8989
}
9090
}
9191

0 commit comments

Comments
 (0)