Skip to content

Commit

Permalink
chore(db): add metric for batched upserts (#838)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedragon committed Jul 1, 2024
1 parent de0fed0 commit 59b162c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/runtime/src/db-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const STORE_BATCH_SIZE = process.env['STORE_BATCH_SIZE'] ? parseInt(process.env[
type Request = Omit<DBRequest, 'opId'>
type RequestType = keyof Request

const meter = metrics.getMeter('store')
const meter = metrics.getMeter('processor_store')
const send_counts: Record<RequestType, Counter<Attributes>> = {
get: meter.createCounter('store_get_count'),
upsert: meter.createCounter('store_upsert_count'),
Expand All @@ -42,6 +42,9 @@ const request_errors: Record<RequestType, Counter<Attributes>> = {
delete: meter.createCounter('store_delete_error')
}

const batched_total_count = meter.createCounter('batched_total_count')
const batched_request_count = meter.createCounter('batched_request_count')

const unsolved_requests = meter.createGauge('store_unsolved_requests')

export const timeoutError = Symbol()
Expand Down Expand Up @@ -210,6 +213,8 @@ export class StoreContext {
processId: this.processId
})
send_counts['upsert']?.add(1)
batched_request_count.add(1)
batched_total_count.add(request.entity.length)
}
}
}
2 changes: 1 addition & 1 deletion packages/runtime/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { StoreContext } from './db-context.js'
import { Subject } from 'rxjs'
import { metrics } from '@opentelemetry/api'

const meter = metrics.getMeter('store')
const meter = metrics.getMeter('processor_service')
const process_binding_count = meter.createCounter('process_binding_count')
const process_binding_time = meter.createCounter('process_binding_time')
const process_binding_error = meter.createCounter('process_binding_error')
Expand Down

0 comments on commit 59b162c

Please sign in to comment.