Skip to content

Commit

Permalink
clarify metric names
Browse files Browse the repository at this point in the history
  • Loading branch information
gvelez17 committed Apr 17, 2024
1 parent f954794 commit f96d9c5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/ancillary/anchor-request-params-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ export class AnchorRequestParamsParser {
parse(req: ExpReq): Validation<RequestAnchorParams> {
if (req.get('Content-Type') !== 'application/vnd.ipld.car') {
// Legacy requests
Metrics.count(METRIC_NAMES.LEGACY_REQUESTED, 1)
Metrics.count(METRIC_NAMES.C_LEGACY_REQUESTED, 1)
return validate(RequestAnchorParamsV1, req.body)
} else {
// Next version of anchor requests, using the CAR file format
// TODO: CDB-2212 Store the car file somewhere for future reference/validation of signatures
// (as it also includes the tip commit and optionally CACAO for the tip commit)
Metrics.count(METRIC_NAMES.CAR_REQUESTED, 1)
Metrics.count(METRIC_NAMES.C_CAR_REQUESTED, 1)
return validate(this.v2decoder, req.body)
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/request-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class RequestController {
return res.status(StatusCodes.OK).json(response)
} catch (err: any) {
if (err instanceof RequestDoesNotExistError) {
Metrics.count(METRIC_NAMES.REQUEST_NOT_FOUND, 1, { source: parseOrigin(req) })
Metrics.count(METRIC_NAMES.C_REQUEST_NOT_FOUND, 1, { source: parseOrigin(req) })
return res.status(StatusCodes.NOT_FOUND).json({
error: err.message,
})
Expand All @@ -107,7 +107,7 @@ export class RequestController {
if (isLeft(validation)) {
const errorMessage = report(validation).join(';')
logger.err(errorMessage)
Metrics.count(METRIC_NAMES.REQUEST_INVALID, 1, { source: parseOrigin(req) })
Metrics.count(METRIC_NAMES.C_INVALID_REQUEST, 1, { source: parseOrigin(req) })
return res.status(StatusCodes.BAD_REQUEST).json({
error: errorMessage,
})
Expand All @@ -123,7 +123,7 @@ export class RequestController {

// request was newly created
if (body) {
Metrics.count(METRIC_NAMES.ANCHOR_REQUESTED, 1, { source: parseOrigin(req) })
Metrics.count(METRIC_NAMES.C_NEW_ANCHOR_REQUEST, 1, { source: parseOrigin(req) })
return res.status(StatusCodes.CREATED).json(body)
}

Expand All @@ -135,10 +135,10 @@ 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) })
Metrics.count(METRIC_NAMES.C_FOUND_EXISTING_REQUEST, 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) })
Metrics.count(METRIC_NAMES.C_ERROR_CREATING_REQUEST, 1, { source: parseOrigin(req) })
return this.getBadRequestResponse(
res,
err,
Expand Down
29 changes: 18 additions & 11 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
export enum METRIC_NAMES {
// *******************************************************************//
// All metrics are counts unless noted otherwise
// counts are running totals and should be used with rate() or increase()

// Anchor Service (counts)

// NOTE that anchor service worker metrics are not currently showing up in dev cas

// Happy path
ACCEPTED_REQUESTS = 'accepted_requests',
ANCHOR_SUCCESS = 'anchor_success',
ACCEPTED_REQUESTS = 'accepted_requests', // Anchor service: request candidates accepted
ANCHOR_SUCCESS = 'anchor_success', // Anchor service: requests successfully anchored

// Errors and warnings
ALREADY_ANCHORED_REQUESTS = 'already_anchored_requests',
// Anchor Service Errors and warnings
ALREADY_ANCHORED_REQUESTS = 'already_anchored_requests',
CONFLICTING_REQUESTS = 'conflicting_requests',
ERROR_IPFS = 'error_ipfs',
ERROR_MULTIQUERY = 'error_multiquery',
Expand Down Expand Up @@ -51,11 +56,12 @@ 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
// DO NOT change TSDB as it is used downstream

MERKLE_CAR_CACHE_HIT = 'merkle_car_cache_hit',
MERKLE_CAR_CACHE_MISS = 'merkle_car_cache_miss',
WITNESS_CAR_CACHE_HIT = 'witness_car_cache_hit',
Expand All @@ -73,10 +79,11 @@ export enum METRIC_NAMES {
IPFS_GET_FAILED = 'ipfs_get_failed',

// Request Controller
ANCHOR_REQUESTED = 'anchor_requested',
CAR_REQUESTED = 'car_requested',
LEGACY_REQUESTED = 'legacy_requested',
REQUEST_INVALID = 'request_invalid',
REQUEST_NOT_CREATED = 'request_not_created',
REQUEST_NOT_FOUND = 'request_not_found',
C_NEW_ANCHOR_REQUEST = 'c_new_anchor_request',
C_FOUND_EXISTING_REQUEST = 'c_found_existing_request',
C_CAR_REQUESTED = 'c_car_requested',
C_LEGACY_REQUESTED = 'c_legacy_requested',
C_INVALID_REQUEST = 'c_invalid_request',
C_ERROR_CREATING_REQUEST = 'c_error_creating_request',
C_REQUEST_NOT_FOUND = 'c_request_not_found',
}

0 comments on commit f96d9c5

Please sign in to comment.