Skip to content

Commit

Permalink
add metric for anchor accepted (#1191)
Browse files Browse the repository at this point in the history
* add metric for anchor accepted

* name the controller metric ANCHOR_REQUEST_ACCEPTED

* add metrics for adding to sqs queue and updating existing requests
  • Loading branch information
gvelez17 authored Apr 17, 2024
1 parent e0538a5 commit 516cc99
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/controllers/request-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class RequestController {
)
}
logger.debug(`Found request for ${requestParams.cid} of stream ${requestParams.streamId}`)
Metrics.count(METRIC_NAMES.ANCHOR_REQUEST_ACCEPTED, 1, { source: parseOrigin(req) })
return res.status(StatusCodes.ACCEPTED).json(found)
} catch (err: any) {
Metrics.count(METRIC_NAMES.REQUEST_NOT_CREATED, 1, { source: parseOrigin(req) })
Expand Down
3 changes: 3 additions & 0 deletions src/services/request-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ export class RequestService {
crt: storedRequest.createdAt,
org: origin,
})
Metrics.count(METRIC_NAMES.PUBLISH_TO_QUEUE, 1)
} else {
await this.requestRepository.markReplaced(storedRequest)
Metrics.count(METRIC_NAMES.UPDATED_STORED_REQUEST, 1)
}

const did = genesisFields?.controllers?.[0]
Expand All @@ -126,6 +128,7 @@ export class RequestService {
cacao: 'cacaoDomain' in params ? params.cacaoDomain : '',
};

// High cardinality business metrics, should be skipped by prometheus
Metrics.count(METRIC_NAMES.WRITE_TOTAL_TSDB, 1, logData)

logger.debug(`Anchor request received: ${JSON.stringify(logData)}`);
Expand Down
4 changes: 4 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ export enum METRIC_NAMES {
ANCHOR_REQUESTS_BATCH_TIME = 'anchor_requests_batch_time',
ANCHOR_REQUESTS_BATCH_FAILURE_TIME = 'anchor_requests_batch_failure_time',

ANCHOR_REQUEST_ACCEPTED = 'anchor_request_accepted', // in controller

// *******************************************************************//
// Request Service
WRITE_TOTAL_TSDB = 'write_total_tsdb', // note _tsdb implies handles high cardinality
MERKLE_CAR_CACHE_HIT = 'merkle_car_cache_hit',
MERKLE_CAR_CACHE_MISS = 'merkle_car_cache_miss',
WITNESS_CAR_CACHE_HIT = 'witness_car_cache_hit',
WITNESS_CAR_CACHE_MISS = 'witness_car_cache_miss',
PUBLISH_TO_QUEUE = 'publish_to_queue',
UPDATED_STORED_REQUEST = 'updated_stored_request',

// *******************************************************************//
// Ceramic Service
Expand Down

0 comments on commit 516cc99

Please sign in to comment.