sravani-revuri commented on code in PR #10020:
URL: https://github.com/apache/ozone/pull/10020#discussion_r3158727732
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/TracingFilter.java:
##########
@@ -46,34 +49,57 @@ public class TracingFilter implements
ContainerRequestFilter,
public void filter(ContainerRequestContext requestContext) {
finishAndCloseActiveSpan();
- TracingUtil.TraceCloseable activatedSpan =
-
TracingUtil.createActivatedSpan(resourceInfo.getResourceClass().getSimpleName()
+ "." +
- resourceInfo.getResourceMethod().getName());
- requestContext.setProperty(TRACING_SPAN_CLOSABLE, activatedSpan);
+ String traceparent = requestContext.getHeaderString("traceparent");
+ String tracestate = requestContext.getHeaderString("tracestate");
+ String encodedParent = TracingUtil.buildTraceContextCarrier(traceparent,
tracestate);
+
+ String spanName = resourceInfo.getResourceClass().getSimpleName() + "." +
+ resourceInfo.getResourceMethod().getName();
+
+ TracingUtil.TraceCloseable traceCloseable =
+ TracingUtil.createActivatedSpanWithParent(spanName, encodedParent);
+
+ requestContext.setProperty(TRACING_SPAN_CLOSABLE, traceCloseable);
}
@Override
public void filter(ContainerRequestContext requestContext,
ContainerResponseContext responseContext) {
final TracingUtil.TraceCloseable spanClosable
= (TracingUtil.TraceCloseable)
requestContext.getProperty(TRACING_SPAN_CLOSABLE);
+ if (spanClosable == null) {
+ return;
+ }
// HDDS-7064: Operation performed while writing StreamingOutput response
// should only be closed once the StreamingOutput callback has completely
// written the data to the destination
- OutputStream out = responseContext.getEntityStream();
- if (out != null) {
- responseContext.setEntityStream(new WrappedOutputStream(out) {
- @Override
- public void close() throws IOException {
- super.close();
- finishAndClose(spanClosable);
- }
- });
+ if (isStreamingGetObject(requestContext)) {
+ OutputStream out = responseContext.getEntityStream();
+ if (out != null) {
+ responseContext.setEntityStream(new WrappedOutputStream(out) {
+ @Override
+ public void close() throws IOException {
+ super.close();
+ finishAndClose(spanClosable);
+ }
+ });
+ } else {
+ finishAndClose(spanClosable);
+ }
} else {
finishAndClose(spanClosable);
}
}
+ private boolean isStreamingGetObject(ContainerRequestContext req) {
+ if (!HTTP_GET_METHOD.equalsIgnoreCase(req.getMethod())) {
Review Comment:
The case is still being traced. Tracing for get is being delayed until
StreamingOutput is done and data is fully written. (as per HDDS-7064)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]