feat(logging): add agent logging for API interactions and error handling across backend and frontend components
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m48s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m48s
This commit is contained in:
@@ -148,6 +148,9 @@ function createTextDataPOST(s3Key, formatLine, validate, validateItem = null) {
|
||||
} catch {}
|
||||
|
||||
if (current && (ifMatch || etag) && current !== String(ifMatch || etag)) {
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H2',location:'backend/routes/textDataRoutes.js:etag-mismatch',message:'ETag mismatch detected in text POST',data:{s3Key:String(s3Key||''),currentEtag:String(current||''),providedEtag:String(ifMatch||etag||'')},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
const { headMeta } = require('../services/s3Service');
|
||||
const meta = await headMeta(s3Key);
|
||||
return sendError(res, 412, 'Precondition Failed: ETag mismatch', 'E_ETAG_MISMATCH', {
|
||||
|
||||
@@ -412,12 +412,18 @@ app.post('/api/server-filters/:serverId', serverConfigsRoutes.postServerFilters)
|
||||
// === LOCKS ===
|
||||
app.get('/api/locks/:resource', (req, res) => {
|
||||
const status = getLockStatus(req.params.resource);
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H4',location:'backend/server.js:locks-get',message:'Lock status requested',data:{resource:String(req?.params?.resource||''),locked:Boolean(status?.locked)},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
res.json(status);
|
||||
});
|
||||
|
||||
app.post('/api/locks/:resource', (req, res) => {
|
||||
const { owner = 'anonymous', ttlSeconds = 120 } = req.body || {};
|
||||
const result = acquireLock(req.params.resource, owner, ttlSeconds);
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H4',location:'backend/server.js:locks-post',message:'Lock acquire attempted',data:{resource:String(req?.params?.resource||''),owner:String(owner||''),success:Boolean(result?.success),locked:Boolean(result?.locked)},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
if (!result.success) {
|
||||
return sendError(res, 423, 'Resource is locked by another user', 'E_RESOURCE_LOCKED', {
|
||||
owner: result.owner,
|
||||
@@ -429,6 +435,9 @@ app.post('/api/locks/:resource', (req, res) => {
|
||||
|
||||
app.delete('/api/locks/:resource', (req, res) => {
|
||||
const result = releaseLock(req.params.resource);
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H4',location:'backend/server.js:locks-delete',message:'Lock released',data:{resource:String(req?.params?.resource||''),released:Boolean(result?.released)},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
res.json(result);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user