given TraceServiceStub.
775013
static OcAgentTraceServiceConfigRpcHandler create(
      TraceServiceStub stub, TraceConfig traceConfig) {
    OcAgentTraceServiceConfigRpcHandler configRpcHandler =
        new OcAgentTraceServiceConfigRpcHandler(traceConfig);
    UpdatedLibraryConfigObserver updatedLibraryConfigObserver =
        new UpdatedLibraryConfigObserver(traceConfig, configRpcHandler);
    try {
      StreamObserver<CurrentLibraryConfig> currentConfigObserver =
          stub.config(updatedLibraryConfigObserver);
      configRpcHandler.setCurrentConfigObserver(currentConfigObserver);
    } catch (StatusRuntimeException e) {
      configRpcHandler.onComplete(e);
    }
    return configRpcHandler;
  }
1018151
def trace(trace_obj):
    
    if pyhdb.tracing:
        t = TraceLogger()
        tr = t.trace(trace_obj)
        print(tr)
        return tr
743354
def trace_on (full=False):
    """"""
    if full:
        sys.settrace(_trace_full)
    else:
        sys.settrace(_trace)
1309756
public static Function<Client<HttpRequest, HttpResponse>, HttpTracingClient> newDecorator(Tracing tracing) {
        return newDecorator(tracing, null);
    }
493045
public function trace()
    {
        foreach ($this->files as $file) {
            ($this->debug === true) ? $this->addTrace($file) : $this->removeTrace($file);
        }
    }
347860
def run(self):
        """"""
        # Catch all possible exceptions raised by the running thread
        # and let parent process know about it.
        try:
            self._run()
        except Exception:  # pylint: disable=broad-except
            self.action.put(
                ServiceCheckDiedError(self.name, traceback.format_exc())
            )
819651
function TraceSpan(name, spanId, parentSpanId) {
  this.name = name;
  this.parentSpanId = parentSpanId;
  this.spanId = spanId;
  this.kind = 'RPC_CLIENT';
  this.labels = {};
  this.startTime = (new Date()).toISOString();
  this.endTime = '';
}
1313852
private Service getServiceInstance(TransientWebServiceRefInfo tInfo, WebServiceRefInfo wsrInfo) throws Exception {
        Class<?> svcSubClass = null;
        Service instance = null;
        if (tInfo.getServiceRefTypeClass() != null && Service.class.getName().equals(tInfo.getServiceRefTypeClassName())) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating service instance using generic Service.create(QName)");
            }
            return Service.create(tInfo.getServiceQName());
        }

        if (tInfo.getServiceRefTypeClass() != null && Service.class.isAssignableFrom(tInfo.getServiceRefTypeClass())) {
            svcSubClass = tInfo.getServiceRefTypeClass();
        } else {
            svcSubClass = tInfo.getServiceInterfaceClass();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Attempting to create instance of service sub-class: " + svcSubClass.getName());
        }
        final Class<?> finalSvcSubClass = svcSubClass;
        Constructor<?> constructor = null;

        // first we get the constructor for the service subclass, we will always use
        // the URL, QName constructor because this constructor allow for null arguments
        try {
            final Constructor<?> finalConstructor = (Constructor<?>) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                @Override
                public Object run() throws NoSuchMethodException {
                    return finalSvcSubClass.getDeclaredConstructor(new Class[] { URL.class, QName.class });
                }
            });
            constructor = finalConstructor;
        } catch (PrivilegedActionException e) {
            if (e.getException() != null) {
                throw e.getException();
            } else {
                throw e;
            }
        }

        // now we will create the service instance with the constructor that was
        // previously created, it's okay if the URL we try to obtain turns out
        // to be null, a service instance will be created without the use of
        // the WSDL document we supplied
        final URL url = tInfo.getWsdlURL();

        //jsr-109:
//        For co-located clients (where the client and the server are in the same Java EE application unit) with
//        generated Service class, the location of the final WSDL document is resolved by comparing the Service name
//        on the @WebServiceClient annotation on the the generated Service to the Service names of all the deployed
//        port components in the Java EE application unit

        // Future plan need to consider:
//        if it is a co-located clients, need to verify the defined wsdlLocation and make it use the dynamic one
//        if there is no wsdlLocation defined, need to use the dynamic one
//        need to consider in the ear level
//        need to consider virtual host

        if (url == null)
        {
            JaxWsModuleMetaData jaxwsModuleMetaData = tInfo.getClientMetaData().getModuleMetaData();
            String applicationName = jaxwsModuleMetaData.getJ2EEName().getApplication();
            String contextRoot = jaxwsModuleMetaData.getContextRoot();
            Map<String, String> appNameURLMap = jaxwsModuleMetaData.getAppNameURLMap();
            Container moduleContainer = jaxwsModuleMetaData.getModuleContainer();
            NonPersistentCache overlayCache;
            try {
                overlayCache = moduleContainer.adapt(NonPersistentCache.class);
                JaxWsModuleInfo jaxWsModuleInfo = (JaxWsModuleInfo) overlayCache.getFromCache(JaxWsModuleInfo.class);
                if (jaxWsModuleInfo != null) {
                    for (EndpointInfo endpointInfo : jaxWsModuleInfo.getEndpointInfos()) {
                        String address = endpointInfo.getAddress(0).substring(1);
                        String serviceName = wsrInfo.getServiceQName().getLocalPart();
                        if (serviceName.equals(address))
                        {
                            String wsdlLocation = null;
                            if ((appNameURLMap != null) && (!appNameURLMap.isEmpty())) {
                                String applicationURL = appNameURLMap.get(applicationName);
                                wsdlLocation = applicationURL + "/" + address + "?wsdl";
                            } else {
                                wsdlLocation = getWsdlUrl() + contextRoot + "/" + address + "?wsdl";
                            }

                            final URL newURl = new URL(wsdlLocation);
                            wsrInfo.setWsdlLocation(wsdlLocation);

                            try {
                                final Constructor<?> finalConstructor = constructor;
                                final QName serviceQName = tInfo.getServiceQName();
                                instance = (Service) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                                    @Override
                                    public Object run() throws InstantiationException, IllegalAccessException, InvocationTargetException {
                                        finalConstructor.setAccessible(true);
                                        return finalConstructor.newInstance(new Object[] { newURl, serviceQName });
                                    }
                                });
                            } catch (PrivilegedActionException e) {
                                if (e.getException() != null) {
                                    throw e.getException();
                                } else {
                                    throw e;
                                }
                            }
                            break;

                        }

                    }
                }
            } catch (UnableToAdaptException e) {

            }
        }
        if (instance != null)
        {
            return instance;
        }

        if (url != null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Creating Service with WSDL URL: " + url + " and QName: " + tInfo.getServiceQName() + " for class: " + svcSubClass.getName());
            }
        }
        try {
            final Constructor<?> finalConstructor = constructor;
            final QName serviceQName = tInfo.getServiceQName();
            instance = (Service) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                @Override
                public Object run() throws InstantiationException, IllegalAccessException, InvocationTargetException {
                    finalConstructor.setAccessible(true);
                    return finalConstructor.newInstance(new Object[] { url, serviceQName });
                }
            });
        } catch (PrivilegedActionException e) {
            if (e.getException() != null) {
                throw e.getException();
            } else {
                throw e;
            }
        }

        return instance;
    }
869482
public void setTraces(Trace... traces) {
        this.traces.clear();
        for (Trace trace : traces) {
            if (!trace.addReplacements(this.traces)) {
                this.traces.add(trace);
            }
        }
    }
123192
public static void ensureScopeUsesRequestContext(Tracing tracing) {
        final PingPongExtra extra = new PingPongExtra();
        // trace contexts are not recorded until Tracer.toSpan, so this won't end up as junk data
        final TraceContext dummyContext = TraceContext.newBuilder().traceId(1).spanId(1)
                                                      .extra(Collections.singletonList(extra)).build();
        final boolean scopeUsesRequestContext;
        try (Scope scope = tracing.currentTraceContext().newScope(dummyContext)) {
            scopeUsesRequestContext = extra.isPong();
        }
        if (!scopeUsesRequestContext) {
            throw new IllegalStateException(
                    "Tracing.currentTraceContext is not a " + RequestContextCurrentTraceContext.class
                            .getSimpleName() + " scope. " +
                    "Please call Tracing.Builder.currentTraceContext(" + RequestContextCurrentTraceContext.class
                            .getSimpleName() + ".INSTANCE).");
        }
    }
133983
public void traceOn(OutputStream traceStream) {
    if (traceStream == null) {
      throw new NullPointerException();
    } else {
      this.traceStream = new PrintWriter(new OutputStreamWriter(traceStream, StandardCharsets.UTF_8), true);
    }
  }
185840
public static Function<Service<HttpRequest, HttpResponse>, HttpTracingService>
    newDecorator(Tracing tracing) {
        ensureScopeUsesRequestContext(tracing);
        return service -> new HttpTracingService(service, tracing);
    }
157883
private void traceJndiBegin(String methodname, Object... objs) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            String providerURL = "UNKNOWN";
            try {
                providerURL = (String) getEnvironment().get(Context.PROVIDER_URL);
            } catch (NamingException ne) {
                /* Ignore. */
            }
            Tr.debug(tc, JNDI_CALL + methodname + " [" + providerURL + "]", objs);
        }
    }
337655
@Override
    public void visitEnd() {
        if (isInstrumentableClass()) {
            // Add a field to hold the trace state if needed
            if (isTraceObjectFieldDefinitionRequired()) {
                int access = (Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC);
                String name = getTraceObjectFieldName();
                String desc = getTraceObjectFieldType().getDescriptor();
                visitField(access, name, desc, null, null);
            }

            // Add a static initializer to setup trace if needed
            if (isStaticInitializerRequired() && !isStaticInitDefined()) {
                staticInitializerGenerated = true;

                MethodVisitor mv = visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null);
                Label lineNumberLabel = new Label();
                mv.visitCode();
                mv.visitLabel(lineNumberLabel);
                mv.visitLineNumber(65535, lineNumberLabel);
                mv.visitInsn(Opcodes.RETURN);
                mv.visitMaxs(1, 0);
                mv.visitEnd();
            }
        }
        super.visitEnd();
    }
67165
private void printServiceInstance(ServiceInstance instance) {
        print("\nServiceInstance\n-------------------------");
        if (instance == null) {
            print("null");
            return;
        }
        print("serviceName:  " + instance.getServiceName());
        print("status:  " + instance.getStatus());
        print("uri:  " + instance.getUri());
        print("address:  " + instance.getAddress());
        print("monitorEnabled:  " + instance.isMonitorEnabled());
        print("metadata:");
        Map<String, String> meta = instance.getMetadata();
        for (Entry<String, String> entry : meta.entrySet()) {
            print("  " + entry.getKey() + "  =>  " + entry.getValue());
        }
    }
605537
def run(self):
        """"""
        self.log.debug("Entered main loop")
        while not self.shutdown:
            # If no service is running slow down the main loop
            if not self._pipe_service:
                time.sleep(0.3)
            self.update_status()
            # While a service is running, check for incoming messages from that service
            if self._pipe_service and self._pipe_service.poll(1):
                try:
                    message = self._pipe_service.recv()
                    if isinstance(message, dict) and "band" in message:
                        # only dictionaries with 'band' entry are valid messages
                        try:
                            handler = getattr(self, "parse_band_" + message["band"])
                        except AttributeError:
                            handler = None
                            self.log.warning("Unknown band %s", str(message["band"]))
                        if handler:
                            #              try:
                            handler(message)
                    #              except Exception:
                    #                print('Uh oh. What to do.')
                    else:
                        self.log.warning("Invalid message received %s", str(message))
                except EOFError:
                    # Service has gone away
                    error_message = False
                    if self._service_status == CommonService.SERVICE_STATUS_END:
                        self.log.info("Service terminated")
                    elif self._service_status == CommonService.SERVICE_STATUS_ERROR:
                        error_message = "Service terminated with error code"
                    elif self._service_status in (
                        CommonService.SERVICE_STATUS_NONE,
                        CommonService.SERVICE_STATUS_NEW,
                        CommonService.SERVICE_STATUS_STARTING,
                    ):
                        error_message = (
                            "Service may have died unexpectedly in "
                            + "initialization (last known status: %s)"
                            % CommonService.human_readable_state.get(
                                self._service_status, self._service_status
                            )
                        )
                    else:
                        error_message = (
                            "Service may have died unexpectedly"
                            " (last known status: %s)"
                            % CommonService.human_readable_state.get(
                                self._service_status, self._service_status
                            )
                        )
                    if error_message:
                        self.log.error(error_message)
                    self._terminate_service()
                    if self.restart_service:
                        self.exponential_backoff()
                    else:
                        self.shutdown = True
                        if error_message:
                            raise workflows.Error(error_message)

            with self.__lock:
                if (
                    self._service is None
                    and self.restart_service
                    and self._service_factory
                ):
                    self.update_status(status_code=CommonService.SERVICE_STATUS_NEW)
                    self.switch_service()

            # Check that the transport is alive
            if not self._transport.is_connected():
                self._terminate_service()
                raise workflows.Error("Lost transport layer connection")
        self.log.debug("Left main loop")
        self.update_status(status_code=CommonService.SERVICE_STATUS_TEARDOWN)
        self._terminate_service()
        self.log.debug("Terminating.")
1156207
public void setTraces(java.util.Collection<Trace> traces) {
        if (traces == null) {
            this.traces = null;
            return;
        }

        this.traces = new java.util.ArrayList<Trace>(traces);
    }