51
51
import java .util .concurrent .ThreadPoolExecutor ;
52
52
import java .util .concurrent .atomic .AtomicBoolean ;
53
53
import java .util .concurrent .atomic .AtomicInteger ;
54
+
54
55
import javax .net .ssl .SSLContext ;
55
56
import javax .net .ssl .SSLEngine ;
57
+
56
58
import org .slf4j .Logger ;
57
59
import org .slf4j .LoggerFactory ;
60
+
58
61
import io .netty .bootstrap .ServerBootstrap ;
59
62
import io .netty .channel .ChannelDuplexHandler ;
60
63
import io .netty .channel .ChannelFuture ;
@@ -297,43 +300,43 @@ class HTTPHandler extends SimpleChannelInboundHandler<HttpRequest> {
297
300
298
301
@ Override
299
302
protected void channelRead0 (ChannelHandlerContext ctx , HttpRequest httpRequest ) {
300
- // Context context = null;
301
- // Span span = null;
302
- // if (useTrace) {
303
- //
304
- // //if the client injected span context,this will extract the context from httpRequest or it will be null
305
- // context = textMapPropagator.extract(Context.current(), httpRequest, new TextMapGetter<HttpRequest>() {
306
- // @Override
307
- // public Iterable<String> keys(HttpRequest carrier) {
308
- // return carrier.headers().names();
309
- // }
310
- //
311
- // @Override
312
- // public String get(HttpRequest carrier, String key) {
313
- // return carrier.headers().get(key);
314
- // }
315
- // });
316
- //
317
- // span = tracer.spanBuilder("HTTP " + httpRequest.method())
318
- // .setParent(context)
319
- // .setSpanKind(SpanKind.SERVER)
320
- // .startSpan();
321
- // //attach the span to the server context
322
- // context = context.with(SpanKey.SERVER_KEY, span);
323
- // //put the context in channel
324
- // ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).set(context);
325
- // }
303
+ // Context context = null;
304
+ // Span span = null;
305
+ // if (useTrace) {
306
+ //
307
+ // //if the client injected span context,this will extract the context from httpRequest or it will be null
308
+ // context = textMapPropagator.extract(Context.current(), httpRequest, new TextMapGetter<HttpRequest>() {
309
+ // @Override
310
+ // public Iterable<String> keys(HttpRequest carrier) {
311
+ // return carrier.headers().names();
312
+ // }
313
+ //
314
+ // @Override
315
+ // public String get(HttpRequest carrier, String key) {
316
+ // return carrier.headers().get(key);
317
+ // }
318
+ // });
319
+ //
320
+ // span = tracer.spanBuilder("HTTP " + httpRequest.method())
321
+ // .setParent(context)
322
+ // .setSpanKind(SpanKind.SERVER)
323
+ // .startSpan();
324
+ // //attach the span to the server context
325
+ // context = context.with(SpanKey.SERVER_KEY, span);
326
+ // //put the context in channel
327
+ // ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).set(context);
328
+ // }
326
329
327
330
328
331
329
332
Span span = null ;
330
- // Context context = null;
331
- // context = EventMeshServer.getTrace().extractFrom();
332
- // span = EventMeshServer.getTrace().createSpan("", context);
333
- // //attach the span to the server context
334
- // context = context.with(SpanKey.SERVER_KEY, span);
335
- // //put the context in channel
336
- // ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).set(context);
333
+ // Context context = null;
334
+ // context = EventMeshServer.getTrace().extractFrom();
335
+ // span = EventMeshServer.getTrace().createSpan("", context);
336
+ // //attach the span to the server context
337
+ // context = context.with(SpanKey.SERVER_KEY, span);
338
+ // //put the context in channel
339
+ // ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).set(context);
337
340
338
341
try {
339
342
preProcessHttpRequestHeader (ctx , httpRequest );
@@ -384,11 +387,11 @@ protected void channelRead0(ChannelHandlerContext ctx, HttpRequest httpRequest)
384
387
requestCommand .setHttpVersion (httpRequest .protocolVersion ().protocolName ());
385
388
requestCommand .setRequestCode (requestCode );
386
389
387
- // if (useTrace) {
388
- // span.setAttribute(SemanticAttributes.HTTP_METHOD, httpRequest.method().name());
389
- // span.setAttribute(SemanticAttributes.HTTP_FLAVOR, httpRequest.protocolVersion().protocolName());
390
- // span.setAttribute(String.valueOf(SemanticAttributes.HTTP_STATUS_CODE), requestCode);
391
- // }
390
+ // if (useTrace) {
391
+ // span.setAttribute(SemanticAttributes.HTTP_METHOD, httpRequest.method().name());
392
+ // span.setAttribute(SemanticAttributes.HTTP_FLAVOR, httpRequest.protocolVersion().protocolName());
393
+ // span.setAttribute(String.valueOf(SemanticAttributes.HTTP_STATUS_CODE), requestCode);
394
+ // }
392
395
393
396
HttpCommand responseCommand = null ;
394
397
@@ -428,8 +431,6 @@ protected void channelRead0(ChannelHandlerContext ctx, HttpRequest httpRequest)
428
431
429
432
} catch (Exception ex ) {
430
433
httpServerLogger .error ("AbrstractHTTPServer.HTTPHandler.channelRead0 err" , ex );
431
-
432
- // EventMeshServer.getTrace().finishSpan(span, null, null, ex);
433
434
}
434
435
}
435
436
@@ -514,8 +515,10 @@ public void processEventMeshRequest(final ChannelHandlerContext ctx,
514
515
sendResponse (ctx , responseCommand .httpResponse ());
515
516
516
517
Map <String , Object > traceMap = asyncContext .getRequest ().getHeader ().toMap ();
517
- Span span = TraceUtils .prepareServerSpan (traceMap , EventMeshTraceConstants .TRACE_UPSTREAM_EVENTMESH_SERVER_SPAN , false );
518
- TraceUtils .finishSpanWithException (span , traceMap , EventMeshRetCode .EVENTMESH_REJECT_BY_PROCESSOR_ERROR .getErrMsg (), null );
518
+ Span span = TraceUtils .prepareServerSpan (traceMap , EventMeshTraceConstants .TRACE_UPSTREAM_EVENTMESH_SERVER_SPAN ,
519
+ false );
520
+ TraceUtils .finishSpanWithException (span , traceMap ,
521
+ EventMeshRetCode .EVENTMESH_REJECT_BY_PROCESSOR_ERROR .getErrMsg (), null );
519
522
}
520
523
return ;
521
524
}
@@ -534,8 +537,6 @@ public void processEventMeshRequest(final ChannelHandlerContext ctx,
534
537
535
538
sendResponse (ctx , asyncContext .getResponse ().httpResponse ());
536
539
537
- // EventMeshServer.getTrace().finishSpan(ctx, StatusCode.OK);
538
-
539
540
} catch (Exception e ) {
540
541
httpServerLogger .error ("process error" , e );
541
542
}
@@ -551,7 +552,6 @@ public void processEventMeshRequest(final ChannelHandlerContext ctx,
551
552
Map <String , Object > traceMap = asyncContext .getRequest ().getHeader ().toMap ();
552
553
Span span = TraceUtils .prepareServerSpan (traceMap , EventMeshTraceConstants .TRACE_UPSTREAM_EVENTMESH_SERVER_SPAN , false );
553
554
TraceUtils .finishSpanWithException (span , traceMap , EventMeshRetCode .EVENTMESH_RUNTIME_ERR .getErrMsg (), re );
554
- // EventMeshServer.getTrace().finishSpan(ctx, StatusCode.ERROR, EventMeshRetCode.OVERLOAD.getErrMsg(), re);
555
555
} catch (Exception e ) {
556
556
httpServerLogger .error ("processEventMeshRequest fail" , re );
557
557
}
@@ -574,7 +574,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
574
574
}
575
575
}
576
576
577
- Map <String , String > extractFromRequest (HttpRequest httpRequest ){
577
+ Map <String , String > extractFromRequest (HttpRequest httpRequest ) {
578
578
return null ;
579
579
}
580
580
}
0 commit comments