Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add metric for anchor accepted #1191

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) })
samika98 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading