Compare commits
No commits in common. "1abae5844aaf6a8a9782a30faffda5205760e3b2" and "a85b99424791d4d092ade06a3a42bf17976e0549" have entirely different histories.
1abae5844a
...
a85b994247
|
@ -188,12 +188,7 @@ export default function routes(
|
|||
tracer?: any,
|
||||
) {
|
||||
parentSpanFromCloudserver.addEvent('Arsenal::routes() Validating and processing request');
|
||||
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 => {
|
||||
return tracer.startActiveSpan('Using Arsenal to validate request', requestValidatorSpan => {
|
||||
requestValidatorSpan.setAttribute('code.function', 'routes');
|
||||
requestValidatorSpan.setAttribute('code.filepath', 'arsenal/lib/s3routes/routes.ts');
|
||||
requestValidatorSpan.setAttribute('code.lineno', 192);
|
||||
|
|
|
@ -11,9 +11,7 @@ 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) => {
|
||||
|
@ -23,7 +21,7 @@ export default function routeDELETE(
|
|||
}
|
||||
log.debug('routing request', { method: 'routeDELETE' });
|
||||
|
||||
const { query, objectKey, bucketName } = request as any
|
||||
const { query, objectKey } = request as any
|
||||
if (query?.uploadId) {
|
||||
if (objectKey === undefined) {
|
||||
const message = 'A key must be specified';
|
||||
|
@ -52,14 +50,8 @@ 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
|
||||
|
@ -72,6 +64,6 @@ export default function routeDELETE(
|
|||
routesUtils.statsReport500(err, statsClient);
|
||||
return routesUtils.responseNoBody(null, corsHeaders, response,
|
||||
204, log);
|
||||
}, tracer);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,9 @@ 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
|
||||
|
||||
|
@ -225,18 +222,12 @@ 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;
|
||||
// need special context for HTTPs requests going externally from cloudserver
|
||||
// const ctx = apiSpan.spanContext()
|
||||
const ctx = opentelemetry.trace.setSpan(
|
||||
opentelemetry.context.active(),
|
||||
apiSpan,
|
||||
|
@ -407,6 +407,9 @@ 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', {
|
||||
|
@ -432,12 +435,11 @@ 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();
|
||||
});
|
||||
|
@ -447,13 +449,11 @@ 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 process.nextTick(() => {
|
||||
callApiMethodSpan.end();
|
||||
return next(err);
|
||||
});
|
||||
return next(err);
|
||||
});
|
||||
currentStream = readable;
|
||||
return readable.pipe(response, { end: false });
|
||||
|
@ -678,7 +678,8 @@ export function responseStreamData(
|
|||
}
|
||||
response.on('finish', () => {
|
||||
// TODO ARSN-216 Fix logger
|
||||
callApiMethodSpan.addEvent('Sending response to Client');
|
||||
apiSpan.addEvent('Sending response to Client');
|
||||
apiSpan.end();
|
||||
callApiMethodSpan.end();
|
||||
// @ts-expect-error
|
||||
log.end().info('responded with streamed content', {
|
||||
|
|
Loading…
Reference in New Issue