use of org.ballerinalang.util.tracer.Tracer in project ballerina by ballerina-lang.
the class BallerinaHTTPConnectorListener method extractPropertiesAndStartResourceExecution.
protected void extractPropertiesAndStartResourceExecution(HTTPCarbonMessage httpCarbonMessage, HttpResource httpResource) {
boolean isTransactionInfectable = httpResource.isTransactionInfectable();
Map<String, Object> properties = collectRequestProperties(httpCarbonMessage, isTransactionInfectable);
properties.put(HttpConstants.REMOTE_ADDRESS, httpCarbonMessage.getProperty(HttpConstants.REMOTE_ADDRESS));
properties.put(HttpConstants.ORIGIN_HOST, httpCarbonMessage.getHeader(HttpConstants.ORIGIN_HOST));
BValue[] signatureParams = HttpDispatcher.getSignatureParameters(httpResource, httpCarbonMessage);
// invoke the request path filters
invokeRequestFilters(httpCarbonMessage, signatureParams[1], getRequestFilterContext(httpResource));
Tracer tracer = TraceManagerWrapper.newTracer(null, false);
httpCarbonMessage.getHeaders().entries().stream().filter(c -> c.getKey().startsWith(TraceConstants.TRACE_PREFIX)).forEach(e -> tracer.addProperty(e.getKey(), e.getValue()));
Map<String, String> tags = new HashMap<>();
tags.put("http.method", (String) httpCarbonMessage.getProperty("HTTP_METHOD"));
tags.put("http.url", (String) httpCarbonMessage.getProperty("REQUEST_URL"));
tracer.addTags(tags);
CallableUnitCallback callback = new HttpCallableUnitCallback(httpCarbonMessage);
// TODO handle BallerinaConnectorException
Executor.submit(httpResource.getBalResource(), callback, properties, tracer, signatureParams);
}
use of org.ballerinalang.util.tracer.Tracer in project ballerina by ballerina-lang.
the class BLangVMUtils method initClientConnectorTrace.
public static void initClientConnectorTrace(WorkerExecutionContext ctx, String connectorName, String actionName) {
Tracer root = TraceUtil.getParentTracer(ctx);
Tracer active = TraceManagerWrapper.newTracer(ctx, true);
TraceUtil.setTracer(ctx, active);
if (root.getInvocationID() == null) {
active.generateInvocationID();
} else {
active.setInvocationID(root.getInvocationID());
}
active.setConnectorName(connectorName);
active.setActionName(actionName);
active.startSpan();
}
Aggregations