Merge pull request #22488 from overleaf/bg-add-filestore-request-logging
add filestore request logging GitOrigin-RevId: 0ec5c413f0e88521e1da268699ee2ee281c560f1
This commit is contained in:
@@ -155,9 +155,9 @@ const FileStoreHandler = {
|
||||
},
|
||||
|
||||
getFileStream(projectId, fileId, query, callback) {
|
||||
let queryString = ''
|
||||
let queryString = '?from=getFileStream'
|
||||
if (query != null && query.format != null) {
|
||||
queryString = `?format=${query.format}`
|
||||
queryString += `&format=${query.format}`
|
||||
}
|
||||
const opts = {
|
||||
method: 'get',
|
||||
@@ -183,7 +183,7 @@ const FileStoreHandler = {
|
||||
|
||||
getFileSize(projectId, fileId, callback) {
|
||||
const url = this._buildUrl(projectId, fileId)
|
||||
request.head(url, (err, res) => {
|
||||
request.head(`${url}?from=getFileSize`, (err, res) => {
|
||||
if (err) {
|
||||
OError.tag(err, 'failed to get file size from filestore', {
|
||||
projectId,
|
||||
|
||||
@@ -3,9 +3,10 @@ function projectHistoryURLWithFilestoreFallback(
|
||||
Settings,
|
||||
projectId,
|
||||
historyId,
|
||||
fileRef
|
||||
fileRef,
|
||||
origin
|
||||
) {
|
||||
const filestoreURL = `${Settings.apis.filestore.url}/project/${projectId}/file/${fileRef._id}`
|
||||
const filestoreURL = `${Settings.apis.filestore.url}/project/${projectId}/file/${fileRef._id}?from=${origin}`
|
||||
if (fileRef.hash) {
|
||||
return {
|
||||
url: `${Settings.apis.project_history.url}/project/${historyId}/blob/${fileRef.hash}`,
|
||||
|
||||
@@ -172,7 +172,8 @@ export default ReferencesHandler = {
|
||||
settings,
|
||||
projectId,
|
||||
historyId,
|
||||
fileRef
|
||||
fileRef,
|
||||
'bibFileUrls'
|
||||
)
|
||||
)
|
||||
const sourceURLs = bibDocUrls.concat(bibFileUrls)
|
||||
|
||||
@@ -87,7 +87,8 @@ async function addFile(params) {
|
||||
settings,
|
||||
projectId,
|
||||
historyId,
|
||||
{ _id: fileId, hash }
|
||||
{ _id: fileId, hash },
|
||||
'tpdsAddFile'
|
||||
)
|
||||
|
||||
await addEntity({
|
||||
|
||||
@@ -386,7 +386,9 @@ describe('FileStoreHandler', function () {
|
||||
return done(err)
|
||||
}
|
||||
this.request.args[0][0].method.should.equal('get')
|
||||
this.request.args[0][0].uri.should.equal(fileUrl)
|
||||
this.request.args[0][0].uri.should.equal(
|
||||
fileUrl + '?from=getFileStream'
|
||||
)
|
||||
done()
|
||||
}
|
||||
)
|
||||
@@ -475,7 +477,8 @@ describe('FileStoreHandler', function () {
|
||||
describe('getFileSize', function () {
|
||||
it('returns the file size reported by filestore', function (done) {
|
||||
const expectedFileSize = 32432
|
||||
const fileUrl = this.getFileUrl(this.projectId, this.fileId)
|
||||
const fileUrl =
|
||||
this.getFileUrl(this.projectId, this.fileId) + '?from=getFileSize'
|
||||
this.request.head.yields(
|
||||
new Error('request.head() received unexpected arguments')
|
||||
)
|
||||
|
||||
@@ -138,8 +138,8 @@ describe('ReferencesHandler', function () {
|
||||
expect(arg.json.docUrls).to.deep.equal([
|
||||
`${this.settings.apis.docstore.url}/project/${this.projectId}/doc/aaa/raw`,
|
||||
`${this.settings.apis.docstore.url}/project/${this.projectId}/doc/ccc/raw`,
|
||||
`${this.settings.apis.filestore.url}/project/${this.projectId}/file/fff`,
|
||||
`${this.settings.apis.filestore.url}/project/${this.projectId}/file/ggg`,
|
||||
`${this.settings.apis.filestore.url}/project/${this.projectId}/file/fff?from=bibFileUrls`,
|
||||
`${this.settings.apis.filestore.url}/project/${this.projectId}/file/ggg?from=bibFileUrls`,
|
||||
])
|
||||
expect(arg.json.sourceURLs.length).to.equal(4)
|
||||
expect(arg.json.sourceURLs).to.deep.equal([
|
||||
@@ -150,11 +150,11 @@ describe('ReferencesHandler', function () {
|
||||
url: `${this.settings.apis.docstore.url}/project/${this.projectId}/doc/ccc/raw`,
|
||||
},
|
||||
{
|
||||
url: `${this.settings.apis.filestore.url}/project/${this.projectId}/file/fff`,
|
||||
url: `${this.settings.apis.filestore.url}/project/${this.projectId}/file/fff?from=bibFileUrls`,
|
||||
},
|
||||
{
|
||||
url: `${this.settings.apis.project_history.url}/project/${this.historyId}/blob/hash`,
|
||||
fallbackURL: `${this.settings.apis.filestore.url}/project/${this.projectId}/file/ggg`,
|
||||
fallbackURL: `${this.settings.apis.filestore.url}/project/${this.projectId}/file/ggg?from=bibFileUrls`,
|
||||
},
|
||||
])
|
||||
expect(arg.json.fullIndex).to.equal(true)
|
||||
|
||||
@@ -138,7 +138,7 @@ describe('TpdsUpdateSender', function () {
|
||||
method: 'pipeStreamFrom',
|
||||
job: {
|
||||
method: 'post',
|
||||
streamOrigin: `${filestoreUrl}/project/${projectId}/file/${fileId}`,
|
||||
streamOrigin: `${filestoreUrl}/project/${projectId}/file/${fileId}?from=tpdsAddFile`,
|
||||
uri: `${thirdPartyDataStoreApiUrl}/user/${userId}/entity/${encodeURIComponent(
|
||||
projectName
|
||||
)}${encodeURIComponent(path)}`,
|
||||
@@ -192,7 +192,7 @@ describe('TpdsUpdateSender', function () {
|
||||
job: {
|
||||
method: 'post',
|
||||
streamOrigin: `${projectHistoryUrl}/project/${historyId}/blob/${hash}`,
|
||||
streamFallback: `${filestoreUrl}/project/${projectId}/file/${fileId}`,
|
||||
streamFallback: `${filestoreUrl}/project/${projectId}/file/${fileId}?from=tpdsAddFile`,
|
||||
uri: `${thirdPartyDataStoreApiUrl}/user/${userId}/entity/${encodeURIComponent(
|
||||
projectName
|
||||
)}${encodeURIComponent(path)}`,
|
||||
|
||||
Reference in New Issue
Block a user