Compare commits
10 Commits
a85b994247
...
1abae5844a
Author | SHA1 | Date |
---|---|---|
Anurag Mittal | 1abae5844a | |
Anurag Mittal | 9c7298c915 | |
Anurag Mittal | 50669bd150 | |
Anurag Mittal | ee91142dba | |
Anurag Mittal | 08a8df9539 | |
Anurag Mittal | 028133b661 | |
Anurag Mittal | cfd8aebe6c | |
Anurag Mittal | 1d7baa4ce4 | |
Anurag Mittal | da142fc3dd | |
Anurag Mittal | afb0bc5cf7 |
|
@ -188,7 +188,12 @@ export default function routes(
|
|||
tracer?: any,
|
||||
) {
|
||||
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.filepath', 'arsenal/lib/s3routes/routes.ts');
|
||||
requestValidatorSpan.setAttribute('code.lineno', 192);
|
||||
|
|
|
@ -11,7 +11,9 @@ export default function routeDELETE(
|
|||
api: { callApiMethod: routesUtils.CallApiMethod },
|
||||
log: RequestLogger,
|
||||
statsClient?: StatsClient,
|
||||
dataRetrievalParams?: any,
|
||||
tracer?: any,
|
||||
parentSpanFromCloudserver?: any,
|
||||
) {
|
||||
const call = (name: string) => {
|
||||
return api.callApiMethod(name, request, response, log, (err, corsHeaders) => {
|
||||
|
@ -21,7 +23,7 @@ export default function routeDELETE(
|
|||
}
|
||||
log.debug('routing request', { method: 'routeDELETE' });
|
||||
|
||||
const { query, objectKey } = request as any
|
||||
const { query, objectKey, bucketName } = request as any
|
||||
if (query?.uploadId) {
|
||||
if (objectKey === undefined) {
|
||||
const message = 'A key must be specified';
|
||||
|
@ -50,8 +52,14 @@ export default function routeDELETE(
|
|||
if (query?.tagging !== undefined) {
|
||||
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,
|
||||
(err, corsHeaders) => {
|
||||
parentSpanFromCloudserver.addEvent('DeleteObject API request completed');
|
||||
parentSpanFromCloudserver.end();
|
||||
/*
|
||||
* Since AWS expects a 204 regardless of the existence of
|
||||
the object, the errors NoSuchKey and NoSuchVersion should not
|
||||
|
@ -64,6 +72,6 @@ export default function routeDELETE(
|
|||
routesUtils.statsReport500(err, statsClient);
|
||||
return routesUtils.responseNoBody(null, corsHeaders, response,
|
||||
204, log);
|
||||
});
|
||||
}, tracer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,12 @@ export default function routePUT(
|
|||
api: { callApiMethod: routesUtils.CallApiMethod },
|
||||
log: RequestLogger,
|
||||
statsClient?: StatsClient,
|
||||
dataRetrievalParams?: any,
|
||||
tracer?: any,
|
||||
parentSpanFromCloudserver?: any,
|
||||
) {
|
||||
log.debug('routing request', { method: 'routePUT' });
|
||||
parentSpanFromCloudserver.addEvent('checking which API to call');
|
||||
|
||||
const { objectKey, query, bucketName, parsedContentLength } = request as any
|
||||
|
||||
|
@ -222,12 +225,18 @@ export default function routePUT(
|
|||
// TODO ARSN-216 What's happening?
|
||||
// @ts-ignore
|
||||
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,
|
||||
(err, resHeaders) => {
|
||||
routesUtils.statsReport500(err, statsClient);
|
||||
parentSpanFromCloudserver.addEvent('PutObject API request completed');
|
||||
parentSpanFromCloudserver.end();
|
||||
return routesUtils.responseNoBody(err, resHeaders,
|
||||
response, 200, log);
|
||||
});
|
||||
}, tracer);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
|
|
|
@ -392,7 +392,7 @@ function retrieveData(
|
|||
locStorageCheckFn,
|
||||
vault,
|
||||
} = retrieveDataParams;
|
||||
// const ctx = apiSpan.spanContext()
|
||||
// need special context for HTTPs requests going externally from cloudserver
|
||||
const ctx = opentelemetry.trace.setSpan(
|
||||
opentelemetry.context.active(),
|
||||
apiSpan,
|
||||
|
@ -407,9 +407,6 @@ function retrieveData(
|
|||
return eachSeries(locations,
|
||||
(current, next) => data.get(current, response, log,
|
||||
(err: any, readable: http.IncomingMessage) => {
|
||||
if (apiSpan) {
|
||||
apiSpan.addEvent('generated a stream');
|
||||
}
|
||||
// NB: readable is of IncomingMessage type
|
||||
if (err) {
|
||||
log.error('failed to get object', {
|
||||
|
@ -435,11 +432,12 @@ function retrieveData(
|
|||
}
|
||||
// readable stream successfully consumed
|
||||
readable.on('end', () => {
|
||||
currentStream = null;
|
||||
dataSpan.end();
|
||||
if (apiSpan) {
|
||||
apiSpan.addEvent('Readable stream successfully consumed');
|
||||
apiSpan.end();
|
||||
}
|
||||
dataSpan.end();
|
||||
currentStream = null;
|
||||
log.debug('readable stream end reached');
|
||||
return next();
|
||||
});
|
||||
|
@ -449,11 +447,13 @@ function retrieveData(
|
|||
if (apiSpan) {
|
||||
apiSpan.addEvent('Unable to stream object from Sproxyd');
|
||||
apiSpan.end();
|
||||
callApiMethodSpan.end();
|
||||
}
|
||||
log.error('error piping data from source');
|
||||
_destroyResponse();
|
||||
return next(err);
|
||||
return process.nextTick(() => {
|
||||
callApiMethodSpan.end();
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
currentStream = readable;
|
||||
return readable.pipe(response, { end: false });
|
||||
|
@ -678,8 +678,7 @@ export function responseStreamData(
|
|||
}
|
||||
response.on('finish', () => {
|
||||
// TODO ARSN-216 Fix logger
|
||||
apiSpan.addEvent('Sending response to Client');
|
||||
apiSpan.end();
|
||||
callApiMethodSpan.addEvent('Sending response to Client');
|
||||
callApiMethodSpan.end();
|
||||
// @ts-expect-error
|
||||
log.end().info('responded with streamed content', {
|
||||
|
|
Loading…
Reference in New Issue