mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* simple fetch data for token instance page * generate enhanced metadata * group query params in page props * make base gSSP function generic * add metric for search engine bots * measure api request duration * get API data for token, address and dapp pages * improve typings for apiData prop * add ENV variable * tweak logs for /media-type requests * [skip ci] add prefix to default metrics
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import * as promClient from 'prom-client';
|
|
|
|
const metrics = (() => {
|
|
// eslint-disable-next-line no-restricted-properties
|
|
if (process.env.PROMETHEUS_METRICS_ENABLED !== 'true') {
|
|
return;
|
|
}
|
|
|
|
promClient.register.clear();
|
|
|
|
const socialPreviewBotRequests = new promClient.Counter({
|
|
name: 'social_preview_bot_requests_total',
|
|
help: 'Number of incoming requests from social preview bots',
|
|
labelNames: [ 'route', 'bot' ] as const,
|
|
});
|
|
|
|
const searchEngineBotRequests = new promClient.Counter({
|
|
name: 'search_engine_bot_requests_total',
|
|
help: 'Number of incoming requests from search engine bots',
|
|
labelNames: [ 'route', 'bot' ] as const,
|
|
});
|
|
|
|
const apiRequestDuration = new promClient.Histogram({
|
|
name: 'api_request_duration_seconds',
|
|
help: 'Duration of requests to API in seconds',
|
|
labelNames: [ 'route', 'code' ],
|
|
buckets: [ 0.2, 0.5, 1, 3, 10 ],
|
|
});
|
|
|
|
return { socialPreviewBotRequests, searchEngineBotRequests, apiRequestDuration };
|
|
})();
|
|
|
|
export default metrics;
|