Add prometheus counter for changeMedia

This commit is contained in:
Calvin Montgomery 2017-08-05 18:50:27 -07:00
parent dac2e41488
commit 0b560f15a9
2 changed files with 8 additions and 1 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.44.2",
"version": "3.44.3",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -9,6 +9,7 @@ var db = require("../database");
var CustomEmbedFilter = require("../customembed").filter;
var XSS = require("../xss");
import counters from '../counters';
import { Counter } from 'prom-client';
const LOGGER = require('@calzoneman/jsli')('playlist');
@ -281,6 +282,11 @@ PlaylistModule.prototype.sendPlaylist = function (users) {
});
};
const changeMediaCounter = new Counter({
name: 'cytube_playlist_played_count',
help: 'Counter for number of playlist items played',
labelNames: ['shortCode']
});
PlaylistModule.prototype.sendChangeMedia = function (users) {
if (!this.current || !this.current.media || this._refreshing) {
return;
@ -295,6 +301,7 @@ PlaylistModule.prototype.sendChangeMedia = function (users) {
var m = this.current.media;
this.channel.logger.log("[playlist] Now playing: " + m.title +
" (" + m.type + ":" + m.id + ")");
changeMediaCounter.labels(m.type).inc();
} else {
users.forEach(function (u) {
u.socket.emit("setCurrent", uid);