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

remove deprecated duplicated metrics #3833

Merged
merged 2 commits into from Jun 27, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 0 additions & 12 deletions packages/@uppy/companion/src/companion.js
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/companion/src/config/companion.js
Expand Up @@ -22,6 +22,7 @@ const defaultOptions = {
periodicPingUrls: [],
streamingUpload: false,
clientSocketConnectTimeout: 60000,
metrics: true,
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/companion/src/standalone/helper.js
Expand Up @@ -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',
}
}

Expand Down
22 changes: 0 additions & 22 deletions packages/@uppy/companion/src/standalone/index.js
Expand Up @@ -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
Expand Down Expand Up @@ -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 }))

Expand Down
4 changes: 1 addition & 3 deletions packages/@uppy/companion/test/__tests__/subpath.js
Expand Up @@ -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 () => {
Expand Down