mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 13:17:08 +00:00
Add hookshot_
prefix on hookshot specific metrics (#701)
* Add hookshot_ prefix on all metrics * Only add prefix to hookshot specific metrics * Add old metric names as deprecated * Fix feeds metrics names * Update metrics docs --------- Co-authored-by: Will Hunt <will@half-shot.uk>
This commit is contained in:
parent
6345ad2347
commit
cafe05b0a2
1
changelog.d/701.misc
Normal file
1
changelog.d/701.misc
Normal file
@ -0,0 +1 @@
|
||||
Ensure all Hookshot specific metrics have a `hookshot_` prefix.
|
@ -1369,7 +1369,7 @@
|
||||
},
|
||||
"editorMode": "builder",
|
||||
"exemplar": false,
|
||||
"expr": "feed_count",
|
||||
"expr": "hookshot_feeds_count",
|
||||
"instant": false,
|
||||
"legendFormat": "{{__name__}}",
|
||||
"range": true,
|
||||
@ -1462,7 +1462,7 @@
|
||||
"uid": "${datasource}"
|
||||
},
|
||||
"editorMode": "builder",
|
||||
"expr": "feed_fetch_ms",
|
||||
"expr": "hookshot_feeds_fetch_ms",
|
||||
"legendFormat": "{{__name__}}",
|
||||
"range": true,
|
||||
"refId": "A"
|
||||
|
@ -31,6 +31,9 @@ Below is the generated list of Prometheus metrics for Hookshot.
|
||||
| hookshot_notifications_push | Number of notifications pushed | service |
|
||||
| hookshot_notifications_service_up | Is the notification service up or down | service |
|
||||
| hookshot_notifications_watchers | Number of notifications watchers running | service |
|
||||
| hookshot_feeds_count | The number of RSS feeds that hookshot is subscribed to | |
|
||||
| hookshot_feeds_fetch_ms | The time taken for hookshot to fetch all feeds | |
|
||||
| hookshot_feeds_failing | The number of RSS feeds that hookshot is failing to read | reason |
|
||||
## matrix
|
||||
| Metric | Help | Labels |
|
||||
|--------|------|--------|
|
||||
@ -41,9 +44,9 @@ Below is the generated list of Prometheus metrics for Hookshot.
|
||||
## feed
|
||||
| Metric | Help | Labels |
|
||||
|--------|------|--------|
|
||||
| feed_count | The number of RSS feeds that hookshot is subscribed to | |
|
||||
| feed_fetch_ms | The time taken for hookshot to fetch all feeds | |
|
||||
| feed_failing | The number of RSS feeds that hookshot is failing to read | reason |
|
||||
| feed_count | (Deprecated) The number of RSS feeds that hookshot is subscribed to | |
|
||||
| feed_fetch_ms | (Deprecated) The time taken for hookshot to fetch all feeds | |
|
||||
| feed_failing | (Deprecated) The number of RSS feeds that hookshot is failing to read | reason |
|
||||
## process
|
||||
| Metric | Help | Labels |
|
||||
|--------|------|--------|
|
||||
|
@ -24,15 +24,18 @@ export class Metrics {
|
||||
public readonly matrixAppserviceEvents = new Counter({ name: "matrix_appservice_events", help: "The number of events sent over the AS API", labelNames: [], registers: [this.registry]});
|
||||
public readonly matrixAppserviceDecryptionFailed = new Counter({ name: "matrix_appservice_decryption_failed", help: "The number of events sent over the AS API that failed to decrypt", registers: [this.registry]});
|
||||
|
||||
public readonly feedsCount = new Gauge({ name: "feed_count", help: "The number of RSS feeds that hookshot is subscribed to", labelNames: [], registers: [this.registry]});
|
||||
public readonly feedFetchMs = new Gauge({ name: "feed_fetch_ms", help: "The time taken for hookshot to fetch all feeds", labelNames: [], registers: [this.registry]});
|
||||
public readonly feedsFailing = new Gauge({ name: "feed_failing", help: "The number of RSS feeds that hookshot is failing to read", labelNames: ["reason"], registers: [this.registry]});
|
||||
public readonly feedsCount = new Gauge({ name: "hookshot_feeds_count", help: "The number of RSS feeds that hookshot is subscribed to", labelNames: [], registers: [this.registry]});
|
||||
public readonly feedFetchMs = new Gauge({ name: "hookshot_feeds_fetch_ms", help: "The time taken for hookshot to fetch all feeds", labelNames: [], registers: [this.registry]});
|
||||
public readonly feedsFailing = new Gauge({ name: "hookshot_feeds_failing", help: "The number of RSS feeds that hookshot is failing to read", labelNames: ["reason"], registers: [this.registry]});
|
||||
public readonly feedsCountDeprecated = new Gauge({ name: "feed_count", help: "(Deprecated) The number of RSS feeds that hookshot is subscribed to", labelNames: [], registers: [this.registry]});
|
||||
public readonly feedsFetchMsDeprecated = new Gauge({ name: "feed_fetch_ms", help: "(Deprecated) The time taken for hookshot to fetch all feeds", labelNames: [], registers: [this.registry]});
|
||||
public readonly feedsFailingDeprecated = new Gauge({ name: "feed_failing", help: "(Deprecated) The number of RSS feeds that hookshot is failing to read", labelNames: ["reason"], registers: [this.registry]});
|
||||
|
||||
|
||||
constructor(private registry: Registry = register) {
|
||||
this.expressRouter.get('/metrics', this.metricsFunc.bind(this));
|
||||
collectDefaultMetrics({
|
||||
register: this.registry
|
||||
register: this.registry,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ export class FeedReader {
|
||||
private seenEntries: Map<string, string[]> = new Map();
|
||||
// A set of last modified times for each url.
|
||||
private cacheTimes: Map<string, { etag?: string, lastModified?: string}> = new Map();
|
||||
|
||||
|
||||
// Reason failures to url map.
|
||||
private feedsFailingHttp = new Set();
|
||||
private feedsFailingParsing = new Set();
|
||||
@ -232,6 +232,7 @@ export class FeedReader {
|
||||
this.feedQueue = shuffle([...this.observedFeedUrls.values()]);
|
||||
|
||||
Metrics.feedsCount.set(this.observedFeedUrls.size);
|
||||
Metrics.feedsCountDeprecated.set(this.observedFeedUrls.size);
|
||||
}
|
||||
|
||||
private async loadSeenEntries(): Promise<void> {
|
||||
@ -268,7 +269,7 @@ export class FeedReader {
|
||||
* Poll a given feed URL for data, pushing any entries found into the message queue.
|
||||
* We also check the `cacheTimes` cache to see if the feed has recent entries that we can
|
||||
* filter out.
|
||||
*
|
||||
*
|
||||
* @param url The URL to be polled.
|
||||
* @returns A boolean that returns if we saw any changes on the feed since the last poll time.
|
||||
*/
|
||||
@ -288,7 +289,7 @@ export class FeedReader {
|
||||
this.config.pollTimeoutSeconds * 1000,
|
||||
this.parser,
|
||||
);
|
||||
|
||||
|
||||
// Store any entity tags/cache times.
|
||||
if (response.headers.ETag) {
|
||||
this.cacheTimes.set(url, { etag: response.headers.ETag});
|
||||
@ -354,7 +355,7 @@ export class FeedReader {
|
||||
// Some RSS feeds can return a very small number of items then bounce
|
||||
// back to their "normal" size, so we cannot just clobber the recent GUID list per request or else we'll
|
||||
// forget what we sent and resend it. Instead, we'll keep 2x the max number of items that we've ever
|
||||
// seen from this feed, up to a max of 10,000.
|
||||
// seen from this feed, up to a max of 10,000.
|
||||
// Adopted from https://github.com/matrix-org/go-neb/blob/babb74fa729882d7265ff507b09080e732d060ae/services/rssbot/rssbot.go#L304
|
||||
const maxGuids = Math.min(Math.max(2 * newGuids.length, seenGuids.length), 10_000);
|
||||
const newSeenItems = Array.from(new Set([ ...newGuids, ...seenGuids ]).values()).slice(0, maxGuids);
|
||||
@ -399,9 +400,12 @@ export class FeedReader {
|
||||
|
||||
Metrics.feedsFailing.set({ reason: "http" }, this.feedsFailingHttp.size );
|
||||
Metrics.feedsFailing.set({ reason: "parsing" }, this.feedsFailingParsing.size);
|
||||
Metrics.feedsFailingDeprecated.set({ reason: "http" }, this.feedsFailingHttp.size );
|
||||
Metrics.feedsFailingDeprecated.set({ reason: "parsing" }, this.feedsFailingParsing.size);
|
||||
|
||||
const elapsed = Date.now() - fetchingStarted;
|
||||
Metrics.feedFetchMs.set(elapsed);
|
||||
Metrics.feedsFetchMsDeprecated.set(elapsed);
|
||||
|
||||
const sleepFor = Math.max(this.sleepingInterval - elapsed, 0);
|
||||
log.debug(`Feed fetching took ${elapsed / 1000}s, sleeping for ${sleepFor / 1000}s`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user