Skip to content

Commit e19ba5f

Browse files
authored
chore: add storage type tag to metrics subscope (#81)
+ unify metrics name + add storage type tag to metrics
1 parent ad42980 commit e19ba5f

File tree

8 files changed

+26
-9
lines changed

8 files changed

+26
-9
lines changed

internal/dlq/sqs/dlq.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ var (
6969

7070
func New(params DLQParams) (DLQ, error) {
7171
client := sqs.New(params.Session)
72-
metrics := params.Metrics.SubScope("dlq")
72+
metrics := params.Metrics.SubScope("dlq").Tagged(map[string]string{
73+
"storage_type": "sqs",
74+
})
7375
impl := &dlqImpl{
7476
config: params.Config,
75-
logger: log.WithPackage(params.Logger),
77+
logger: log.WithPackage(params.Logger).With(zap.String("storage_type", "sqs")),
7678
client: client,
7779
instrumentSendMessage: instrument.New(metrics, "send_message"),
7880
instrumentResendMessage: instrument.New(metrics, "resend_message"),

internal/storage/blobstorage/s3/blob_storage.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ func (f *blobStorageFactory) Create() (internal.BlobStorage, error) {
8080
}
8181

8282
func New(params BlobStorageParams) (internal.BlobStorage, error) {
83-
metrics := params.Metrics.SubScope("blob_storage")
83+
metrics := params.Metrics.SubScope("blob_storage").Tagged(map[string]string{
84+
"storage_type": "s3",
85+
})
8486
return &blobStorageImpl{
8587
logger: log.WithPackage(params.Logger),
8688
config: params.Config,
@@ -217,6 +219,7 @@ func (s *blobStorageImpl) Download(ctx context.Context, metadata *api.BlockMetad
217219
func (s *blobStorageImpl) logDuration(method string, start time.Time) {
218220
s.logger.Debug(
219221
"blob_storage",
222+
zap.String("storage_type", "s3"),
220223
zap.String("method", method),
221224
zap.Duration("duration", time.Since(start)),
222225
)

internal/storage/metastorage/dynamodb/block_storage.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ func newBlockStorage(params Params) (internal.BlockStorage, error) {
7373
return nil, xerrors.Errorf("failed to create metadata accessor: %w", err)
7474
}
7575

76-
metrics := params.Metrics.SubScope("block_storage")
76+
metrics := params.Metrics.SubScope("block_storage").Tagged(map[string]string{
77+
"storage_type": "dynamodb",
78+
})
7779
accessor := blockStorageImpl{
7880
blockTable: metadataTable,
7981
blockStartHeight: params.Config.Chain.BlockStartHeight,

internal/storage/metastorage/dynamodb/event_storage.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ func newEventStorage(params Params) (internal.EventStorage, error) {
7373
return nil, xerrors.Errorf("failed to create versioned event table: %w", err)
7474
}
7575

76-
metrics := params.Metrics.SubScope("event_storage")
76+
metrics := params.Metrics.SubScope("event_storage").Tagged(map[string]string{
77+
"storage_type": "dynamodb",
78+
})
7779
storage := eventStorageImpl{
7880
eventTable: eventTable,
7981
heightIndexName: heightIndexName,

internal/storage/metastorage/dynamodb/transaction_storage.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ func newTransactionStorage(params Params) (internal.TransactionStorage, error) {
5757
return nil, xerrors.Errorf("failed to create transaction table accessor: %w", err)
5858
}
5959

60-
metrics := params.Metrics.SubScope("transaction_storage")
60+
metrics := params.Metrics.SubScope("transaction_storage").Tagged(map[string]string{
61+
"storage_type": "dynamodb",
62+
})
6163

6264
return &transactionStorageImpl{
6365
transactionTable: transactionTable,

internal/storage/metastorage/firestore/block_storage.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ type (
3636
)
3737

3838
func newBlockStorage(params Params, client *firestore.Client) (internal.BlockStorage, error) {
39-
metrics := params.Metrics.SubScope("block_storage_firestore")
39+
metrics := params.Metrics.SubScope("block_storage").Tagged(map[string]string{
40+
"storage_type": "firestore",
41+
})
4042
accessor := blockStorageImpl{
4143
client: client,
4244
projectId: params.Config.GCP.Project,

internal/storage/metastorage/firestore/event_storage.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ type (
3939
)
4040

4141
func newEventStorage(params Params, client *firestore.Client) (internal.EventStorage, error) {
42-
metrics := params.Metrics.SubScope("event_storage_firestore")
42+
metrics := params.Metrics.SubScope("event_storage").Tagged(map[string]string{
43+
"storage_type": "firestore",
44+
})
4345
storage := eventStorageImpl{
4446
client: client,
4547
env: params.Config.ConfigName,

internal/storage/metastorage/firestore/transaction_storage.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ type (
2121
var _ internal.TransactionStorage = (*transactionStorageImpl)(nil)
2222

2323
func newTransactionStorage(params Params, client *firestore.Client) (internal.TransactionStorage, error) {
24-
metrics := params.Metrics.SubScope("transaction_storage_firestore")
24+
metrics := params.Metrics.SubScope("transaction_storage").Tagged(map[string]string{
25+
"storage_type": "firestore",
26+
})
2527
return &transactionStorageImpl{
2628
client: client,
2729
instrumentAddOrUpdateTransaction: instrument.New(metrics, "add_transactions"),

0 commit comments

Comments
 (0)