Compare commits

...

10 Commits

Author SHA1 Message Date
Anurag Mittal 1abae5844a
fixup 2024-06-13 18:01:06 +02:00
Anurag Mittal 9c7298c915
updated delete route 2024-06-13 17:50:47 +02:00
Anurag Mittal 50669bd150
updated message for put object 2024-06-13 16:45:38 +02:00
Anurag Mittal ee91142dba
linked manual span to arsenal 2024-06-13 15:54:38 +02:00
Anurag Mittal 08a8df9539
ended Parent Span 2024-06-13 15:45:02 +02:00
Anurag Mittal 028133b661
updated Put params 2024-06-13 15:25:47 +02:00
Anurag Mittal cfd8aebe6c
added instrumentation for put object 2024-06-13 14:33:54 +02:00
Anurag Mittal 1d7baa4ce4
Get Object done 2024-06-13 11:33:54 +02:00
Anurag Mittal da142fc3dd
added more details to method span 2024-06-13 09:35:23 +02:00
Anurag Mittal afb0bc5cf7
added links and removed unnecessary events 2024-06-13 09:06:35 +02:00
4 changed files with 35 additions and 14 deletions

View File

@ -188,7 +188,12 @@ export default function routes(
tracer?: any, tracer?: any,
) { ) {
parentSpanFromCloudserver.addEvent('Arsenal::routes() Validating and processing request'); parentSpanFromCloudserver.addEvent('Arsenal::routes() Validating and processing request');
return tracer.startActiveSpan('Using Arsenal to validate request', requestValidatorSpan => { const ctx = opentelemetry.trace.setSpan(
opentelemetry.context.active(),
parentSpanFromCloudserver,
);
const spanOptions = { links: [{ context: parentSpanFromCloudserver.spanContext() }] };
return tracer.startActiveSpan('Using Arsenal to validate request', spanOptions, ctx, requestValidatorSpan => {
requestValidatorSpan.setAttribute('code.function', 'routes'); requestValidatorSpan.setAttribute('code.function', 'routes');
requestValidatorSpan.setAttribute('code.filepath', 'arsenal/lib/s3routes/routes.ts'); requestValidatorSpan.setAttribute('code.filepath', 'arsenal/lib/s3routes/routes.ts');
requestValidatorSpan.setAttribute('code.lineno', 192); requestValidatorSpan.setAttribute('code.lineno', 192);

View File

@ -11,7 +11,9 @@ export default function routeDELETE(
api: { callApiMethod: routesUtils.CallApiMethod }, api: { callApiMethod: routesUtils.CallApiMethod },
log: RequestLogger, log: RequestLogger,
statsClient?: StatsClient, statsClient?: StatsClient,
dataRetrievalParams?: any,
tracer?: any, tracer?: any,
parentSpanFromCloudserver?: any,
) { ) {
const call = (name: string) => { const call = (name: string) => {
return api.callApiMethod(name, request, response, log, (err, corsHeaders) => { return api.callApiMethod(name, request, response, log, (err, corsHeaders) => {
@ -21,7 +23,7 @@ export default function routeDELETE(
} }
log.debug('routing request', { method: 'routeDELETE' }); log.debug('routing request', { method: 'routeDELETE' });
const { query, objectKey } = request as any const { query, objectKey, bucketName } = request as any
if (query?.uploadId) { if (query?.uploadId) {
if (objectKey === undefined) { if (objectKey === undefined) {
const message = 'A key must be specified'; const message = 'A key must be specified';
@ -50,8 +52,14 @@ export default function routeDELETE(
if (query?.tagging !== undefined) { if (query?.tagging !== undefined) {
return call('objectDeleteTagging'); return call('objectDeleteTagging');
} }
parentSpanFromCloudserver.addEvent('Detected Object Delete API request');
parentSpanFromCloudserver.updateName(`DeleteObject API with bucket: ${bucketName}`);
parentSpanFromCloudserver.setAttribute('aws.request_id', log.getUids()[0]);
parentSpanFromCloudserver.setAttribute('rpc.method', 'PutObject');
api.callApiMethod('objectDelete', request, response, log, api.callApiMethod('objectDelete', request, response, log,
(err, corsHeaders) => { (err, corsHeaders) => {
parentSpanFromCloudserver.addEvent('DeleteObject API request completed');
parentSpanFromCloudserver.end();
/* /*
* Since AWS expects a 204 regardless of the existence of * Since AWS expects a 204 regardless of the existence of
the object, the errors NoSuchKey and NoSuchVersion should not the object, the errors NoSuchKey and NoSuchVersion should not
@ -64,6 +72,6 @@ export default function routeDELETE(
routesUtils.statsReport500(err, statsClient); routesUtils.statsReport500(err, statsClient);
return routesUtils.responseNoBody(null, corsHeaders, response, return routesUtils.responseNoBody(null, corsHeaders, response,
204, log); 204, log);
}); }, tracer);
} }
} }

View File

@ -11,9 +11,12 @@ export default function routePUT(
api: { callApiMethod: routesUtils.CallApiMethod }, api: { callApiMethod: routesUtils.CallApiMethod },
log: RequestLogger, log: RequestLogger,
statsClient?: StatsClient, statsClient?: StatsClient,
dataRetrievalParams?: any,
tracer?: any, tracer?: any,
parentSpanFromCloudserver?: any,
) { ) {
log.debug('routing request', { method: 'routePUT' }); log.debug('routing request', { method: 'routePUT' });
parentSpanFromCloudserver.addEvent('checking which API to call');
const { objectKey, query, bucketName, parsedContentLength } = request as any const { objectKey, query, bucketName, parsedContentLength } = request as any
@ -222,12 +225,18 @@ export default function routePUT(
// TODO ARSN-216 What's happening? // TODO ARSN-216 What's happening?
// @ts-ignore // @ts-ignore
log.end().addDefaultFields({ contentLength: request.parsedContentLength }); log.end().addDefaultFields({ contentLength: request.parsedContentLength });
parentSpanFromCloudserver.addEvent('Detected Object Put API request');
parentSpanFromCloudserver.updateName(`PutObject API with bucket: ${bucketName}`);
parentSpanFromCloudserver.setAttribute('aws.request_id', log.getUids()[0]);
parentSpanFromCloudserver.setAttribute('rpc.method', 'PutObject');
api.callApiMethod('objectPut', request, response, log, api.callApiMethod('objectPut', request, response, log,
(err, resHeaders) => { (err, resHeaders) => {
routesUtils.statsReport500(err, statsClient); routesUtils.statsReport500(err, statsClient);
parentSpanFromCloudserver.addEvent('PutObject API request completed');
parentSpanFromCloudserver.end();
return routesUtils.responseNoBody(err, resHeaders, return routesUtils.responseNoBody(err, resHeaders,
response, 200, log); response, 200, log);
}); }, tracer);
} }
} }
return undefined; return undefined;

View File

@ -392,7 +392,7 @@ function retrieveData(
locStorageCheckFn, locStorageCheckFn,
vault, vault,
} = retrieveDataParams; } = retrieveDataParams;
// const ctx = apiSpan.spanContext() // need special context for HTTPs requests going externally from cloudserver
const ctx = opentelemetry.trace.setSpan( const ctx = opentelemetry.trace.setSpan(
opentelemetry.context.active(), opentelemetry.context.active(),
apiSpan, apiSpan,
@ -407,9 +407,6 @@ function retrieveData(
return eachSeries(locations, return eachSeries(locations,
(current, next) => data.get(current, response, log, (current, next) => data.get(current, response, log,
(err: any, readable: http.IncomingMessage) => { (err: any, readable: http.IncomingMessage) => {
if (apiSpan) {
apiSpan.addEvent('generated a stream');
}
// NB: readable is of IncomingMessage type // NB: readable is of IncomingMessage type
if (err) { if (err) {
log.error('failed to get object', { log.error('failed to get object', {
@ -435,11 +432,12 @@ function retrieveData(
} }
// readable stream successfully consumed // readable stream successfully consumed
readable.on('end', () => { readable.on('end', () => {
currentStream = null;
dataSpan.end();
if (apiSpan) { if (apiSpan) {
apiSpan.addEvent('Readable stream successfully consumed'); apiSpan.addEvent('Readable stream successfully consumed');
apiSpan.end();
} }
dataSpan.end();
currentStream = null;
log.debug('readable stream end reached'); log.debug('readable stream end reached');
return next(); return next();
}); });
@ -449,12 +447,14 @@ function retrieveData(
if (apiSpan) { if (apiSpan) {
apiSpan.addEvent('Unable to stream object from Sproxyd'); apiSpan.addEvent('Unable to stream object from Sproxyd');
apiSpan.end(); apiSpan.end();
callApiMethodSpan.end();
} }
log.error('error piping data from source'); log.error('error piping data from source');
_destroyResponse(); _destroyResponse();
return process.nextTick(() => {
callApiMethodSpan.end();
return next(err); return next(err);
}); });
});
currentStream = readable; currentStream = readable;
return readable.pipe(response, { end: false }); return readable.pipe(response, { end: false });
}), err => { }), err => {
@ -678,8 +678,7 @@ export function responseStreamData(
} }
response.on('finish', () => { response.on('finish', () => {
// TODO ARSN-216 Fix logger // TODO ARSN-216 Fix logger
apiSpan.addEvent('Sending response to Client'); callApiMethodSpan.addEvent('Sending response to Client');
apiSpan.end();
callApiMethodSpan.end(); callApiMethodSpan.end();
// @ts-expect-error // @ts-expect-error
log.end().info('responded with streamed content', { log.end().info('responded with streamed content', {