mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-25 03:08:34 +00:00
remove deprecated duplicated metrics (#3833)
* remove deprecated duplicated metrics * remove backward compatibility
This commit is contained in:
parent
4cbca6ec78
commit
d6441d8d34
5 changed files with 3 additions and 37 deletions
|
|
@ -13,7 +13,6 @@ const s3 = require('./server/controllers/s3')
|
|||
const url = require('./server/controllers/url')
|
||||
const createEmitter = require('./server/emitter')
|
||||
const redis = require('./server/redis')
|
||||
const { getURLBuilder } = require('./server/helpers/utils')
|
||||
const jobs = require('./server/jobs')
|
||||
const logger = require('./server/logger')
|
||||
const middlewares = require('./server/middlewares')
|
||||
|
|
@ -85,17 +84,6 @@ module.exports.app = (optionsArg = {}) => {
|
|||
|
||||
if (options.metrics) {
|
||||
app.use(middlewares.metrics({ path: options.server.path }))
|
||||
|
||||
// backward compatibility
|
||||
// TODO remove in next major semver
|
||||
if (options.server.path) {
|
||||
const buildUrl = getURLBuilder(options)
|
||||
app.get('/metrics', (req, res) => {
|
||||
process.emitWarning('/metrics is deprecated when specifying a path to companion')
|
||||
const metricsUrl = buildUrl('/metrics', true)
|
||||
res.redirect(metricsUrl)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
app.use(cookieParser()) // server tokens are added to cookies
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ const defaultOptions = {
|
|||
periodicPingUrls: [],
|
||||
streamingUpload: false,
|
||||
clientSocketConnectTimeout: 60000,
|
||||
metrics: true,
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ const getConfigFromEnv = () => {
|
|||
chunkSize: process.env.COMPANION_CHUNK_SIZE ? parseInt(process.env.COMPANION_CHUNK_SIZE, 10) : undefined,
|
||||
clientSocketConnectTimeout: process.env.COMPANION_CLIENT_SOCKET_CONNECT_TIMEOUT
|
||||
? parseInt(process.env.COMPANION_CLIENT_SOCKET_CONNECT_TIMEOUT, 10) : undefined,
|
||||
metrics: process.env.COMPANION_HIDE_METRICS !== 'true',
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ const logger = require('../server/logger')
|
|||
const redis = require('../server/redis')
|
||||
const companion = require('../companion')
|
||||
const helper = require('./helper')
|
||||
const middlewares = require('../server/middlewares')
|
||||
const { getURLBuilder } = require('../server/helpers/utils')
|
||||
|
||||
/**
|
||||
* Configures an Express app for running Companion standalone
|
||||
|
|
@ -102,26 +100,6 @@ module.exports = function server (inputCompanionOptions = {}) {
|
|||
}
|
||||
})
|
||||
|
||||
// for server metrics tracking.
|
||||
// make app metrics available at '/metrics'.
|
||||
// TODO for the next major version: use instead companion option "metrics": true and remove this code
|
||||
// eslint-disable-next-line max-len
|
||||
// See discussion: https://github.com/transloadit/uppy/pull/2854/files/64be97205e4012818abfcc8b0b8b7fe09de91729#diff-68f5e3eb307c1c9d1fd02224fd7888e2f74718744e1b6e35d929fcab1cc50ed1
|
||||
if (process.env.COMPANION_HIDE_METRICS !== 'true') {
|
||||
router.use(middlewares.metrics({ path: companionOptions.server.path }))
|
||||
|
||||
// backward compatibility
|
||||
// TODO remove in next major semver
|
||||
if (companionOptions.server.path) {
|
||||
const buildUrl = getURLBuilder(companionOptions)
|
||||
app.get('/metrics', (req, res) => {
|
||||
process.emitWarning('/metrics is deprecated when specifying a path to companion')
|
||||
const metricsUrl = buildUrl('/metrics', true)
|
||||
res.redirect(metricsUrl)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
router.use(bodyParser.json())
|
||||
router.use(bodyParser.urlencoded({ extended: false }))
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ it('can be served under a subpath', async () => {
|
|||
await request(server).get('/subpath').expect(200)
|
||||
await request(server).get('/subpath/metrics').expect(200)
|
||||
await request(server).get('/').expect(404)
|
||||
// todo in next major:
|
||||
await request(server).get('/metrics').expect(302)
|
||||
// await request(server).get('/metrics').expect(404)
|
||||
await request(server).get('/metrics').expect(404)
|
||||
})
|
||||
|
||||
test('can be served without a subpath', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue