存入tracer信息

@param requestContext ClientRequestContext
173188
public static void storeTracerInfo(ClientRequestContext requestContext) {

        // tracer信息放入request 发到服务端
        SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext();
        SofaTracerSpan clientSpan = sofaTraceContext.getCurrentSpan();
        RpcInternalContext context = RpcInternalContext.getContext();
        if (clientSpan != null) {
            requestContext.getHeaders().add(RemotingConstants.NEW_RPC_TRACE_NAME,
                clientSpan.getSofaTracerSpanContext().serializeSpanContext());
        }
        // 客户端发送自己的应用名
        String appName = (String) context.getAttachment(INTERNAL_KEY_APP_NAME);
        if (appName != null) {
            requestContext.getHeaders().add(RemotingConstants.HEAD_APP_NAME, appName);
        }
    }
770635
@Override
	public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext responseContext) {
		if (backend.getConfiguration().shouldProcessContext(OutgoingResponse)) {
			final Map<String, String> filtered = backend.getConfiguration().filterDeniedParams(backend.copyToMap(), OutgoingResponse);
			responseContext.getHeaders().putSingle(TraceeConstants.TPIC_HEADER, transportSerialization.render(filtered));
		}

		backend.clear();
	}
437484
protected void recordSerializeRequest(RequestCommand requestCommand, InvokeContext invokeContext) {
        if (!RpcInternalContext.isAttachmentEnable()) {
            return;
        }
        RpcInternalContext context = null;
        if (invokeContext != null) {
            // 客户端异步调用的情况下，上下文会放在InvokeContext中传递
            context = invokeContext.get(RemotingConstants.INVOKE_CTX_RPC_CTX);
        }
        if (context == null) {
            context = RpcInternalContext.getContext();
        }
        int cost = context.getStopWatch().tick().read();
        int requestSize = RpcProtocol.getRequestHeaderLength()
            + requestCommand.getClazzLength()
            + requestCommand.getContentLength()
            + requestCommand.getHeaderLength();
        // 记录请求序列化大小和请求序列化耗时
        context.setAttachment(RpcConstants.INTERNAL_KEY_REQ_SIZE, requestSize);
        context.setAttachment(RpcConstants.INTERNAL_KEY_REQ_SERIALIZE_TIME, cost);
    }
900796
public static GeoLocationRequest getHttpServletRequestGeoLocationFromRequestContext(final RequestContext context) {
        val servletRequest = getHttpServletRequestFromExternalWebflowContext(context);
        return getHttpServletRequestGeoLocation(servletRequest);
    }
1092521
@InternalApi
  public ReadRowsRequest toProto(RequestContext requestContext) {
    String tableName =
        NameUtil.formatTableName(
            requestContext.getProjectId(), requestContext.getInstanceId(), tableId);

    return builder
        .setTableName(tableName)
        .setAppProfileId(requestContext.getAppProfileId())
        .build();
  }
883416
public void setResourceAdaptorContext(javax.slee.resource.ResourceAdaptorContext raContext) {
		this.raContext = raContext; 
		this.tracer = raContext.getTracer("XCAPClientResourceAdaptor");
		sbbInterface = new XCAPClientResourceAdaptorSbbInterfaceImpl(this);
        this.sleeEndpoint = raContext.getSleeEndpoint();
        this.eventLookupFacility = raContext.getEventLookupFacility();

        try {
        	this.getResponseEvent = eventLookupFacility.getFireableEventType(new EventTypeID("GetResponseEvent", "org.restcomm", "2.0"));
        	this.putResponseEvent = eventLookupFacility.getFireableEventType(new EventTypeID("PutResponseEvent", "org.restcomm", "2.0"));
        	this.deleteResponseEvent = eventLookupFacility.getFireableEventType(new EventTypeID("DeleteResponseEvent", "org.restcomm", "2.0"));
        }
        catch(Exception e) {
        	if(tracer.isWarningEnabled())
        		tracer.warning("Could not look up Response Event",e);
        }	
	}
871331
public void handleTrace(HttpRequest request,
                            HttpResponse response)
        throws IOException
    {
        boolean trace=getHttpContext().getHttpServer().getTrace();
        
        // Handle TRACE by returning request header
        response.setField(HttpFields.__ContentType,
                          HttpFields.__MessageHttp);
        if (trace)
        {
            OutputStream out = response.getOutputStream();
            ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer();
            writer.write(request.toString());
            writer.flush();
            response.setIntField(HttpFields.__ContentLength,writer.size());
            writer.writeTo(out);
            out.flush();
        }
        request.setHandled(true);
    }
482070
def trace_integration(tracer=None):
    """"""
    log.info('Integrated module: {}'.format(MODULE_NAME))

    if tracer is not None:
        # The execution_context tracer should never be None - if it has not
        # been set it returns a no-op tracer. Most code in this library does
        # not handle None being used in the execution context.
        execution_context.set_opencensus_tracer(tracer)

    # Wrap the requests functions
    for func in REQUESTS_WRAP_METHODS:
        requests_func = getattr(requests, func)
        wrapped = wrap_requests(requests_func)
        setattr(requests, requests_func.__name__, wrapped)

    # Wrap Session class
    wrapt.wrap_function_wrapper(
        MODULE_NAME, 'Session.request', wrap_session_request)
1025820
public static WebApplicationService getService(final List<ArgumentExtractor> argumentExtractors, final RequestContext context) {
        val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
        return HttpRequestUtils.getService(argumentExtractors, request);
    }
56518
public static WebApplicationService getService(final RequestContext context) {
        return context != null ? (WebApplicationService) context.getFlowScope().get(PARAMETER_SERVICE) : null;
    }
1320601
public static void clientBeforeSend(SofaRequest request) {
        if (openTrace) {
            try {
                tracer.clientBeforeSend(request);
            } catch (Exception e) {
                if (LOGGER.isWarnEnabled()) {
                    LOGGER.warn(e.getMessage(), e);
                }
            }
        }
    }
42392
public static void clientAsyncReceivedPrepare() {
        if (openTrace) {
            try {
                tracer.clientAsyncReceivedPrepare();
            } catch (Exception e) {
                if (LOGGER.isWarnEnabled()) {
                    LOGGER.warn(e.getMessage(), e);
                }
            }
        }
    }
12075
@SuppressWarnings("unchecked")
  private void handleRequest(long requestId, Object request) {
    HandlerHolder holder = handlers.get(request.getClass());
    if (holder == null) {
      connection.handleResponseError(requestId, new ConnectException("no handler registered"));
      return;
    }

    Function<Object, CompletableFuture<Object>> handler = (Function<Object, CompletableFuture<Object>>) holder.handler;

    try {
      holder.context.executor().execute(() -> {
        if (open && connection.open) {
          CompletableFuture<Object> responseFuture = handler.apply(request);
          if (responseFuture != null) {
            responseFuture.whenComplete((response, error) -> {
              if (!open || !connection.open) {
                connection.handleResponseError(requestId, new ConnectException("connection closed"));
              } else if (error == null) {
                connection.handleResponseOk(requestId, response);
              } else {
                connection.handleResponseError(requestId, error);
              }
            });
          }
        } else {
          connection.handleResponseError(requestId, new ConnectException("connection closed"));
        }
      });
    } catch (RejectedExecutionException e) {
      connection.handleResponseError(requestId, new ConnectException("connection closed"));
    }
  }
159304
public void processRequest(RequestEvent req) {
		
		if (tracer.isInfoEnabled()) {
			tracer.info("Received Request:\n"+req.getRequest());
		}

		// Restcomm Statistics
		final String method = req.getRequest().getMethod();
		if (Request.INVITE.equalsIgnoreCase(method)) {
			this.defaultUsageParameters.incrementCalls(1);
		}
		if (Request.MESSAGE.equalsIgnoreCase(method)) {
			this.defaultUsageParameters.incrementMessages(1);
		}

		// get dialog wrapper
		final Dialog d = req.getDialog();
		final DialogWrapper dw = getDialogWrapper(d);
		if (dw != null && req.getServerTransaction() == null) {
			if (tracer.isInfoEnabled()) {
				tracer.info("No server tx found, for in dialog request, assuming it as retransmission and dropping...");
			}
			return;
		}
		
		if (req.getRequest().getMethod().equals(Request.CANCEL)) {
			processCancelRequest(req,dw);
		} else {
			processNotCancelRequest(req,dw);
		}
	}
1355344
public void notifyObserversOfRequestProcessed(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) {
        RequestProcessingContext requestProcessingContext = new RequestProcessingContext();
        requestProcessingContext.setExecutionThread(Thread.currentThread());
        requestProcessingContext.setRequestListeners(requestListeners);
        post(new RequestProcessedNotifier(request, spiceServiceListenerList, requestProcessingContext));
    }
1049810
public void notifyObserversOfRequestProgress(CachedSpiceRequest<?> request, RequestProgress requestProgress) {
        RequestProcessingContext requestProcessingContext = new RequestProcessingContext();
        requestProcessingContext.setExecutionThread(Thread.currentThread());
        requestProcessingContext.setRequestProgress(requestProgress);
        post(new RequestProgressNotifier(request, spiceServiceListenerList, requestProcessingContext));
    }
1171424
public void initCurrentTracingContext() {
//    if (this.debugConfigMap.containsKey(Thread.currentThread().getName())) {
//      DebugConfig debugConfig = this.debugConfigMap.get(Thread.currentThread().getName());
//      this.debugConfigMap.remove(Thread.currentThread().getName());
//
//      System.out.println(formatContextInfo(debugConfig.getLevel(), debugConfig.isOnline()));
//
//      TracingContext tracingContext = new TracingContext(debugConfig);
//      this.threadMap.setCurrentTracingContext(tracingContext);
//    }
    
    TracingContext tracingContext = this.threadMap.getCurrentTracingContext();
    if (tracingContext == null) {
      if (this.debugConfigMap.containsKey(Thread.currentThread().getName())) {
        DebugConfig debugConfig = this.debugConfigMap.get(Thread.currentThread().getName());
        System.out.println(formatContextInfo(debugConfig.getLevel(), debugConfig.isOnline()));
        tracingContext = new TracingContext(debugConfig);
        this.threadMap.setCurrentTracingContext(tracingContext);
      }
    }
  }