private ObjectNode getStreamSerializeObjectNode() { ObjectNode obj = (ObjectNode) mapper.valueToTree(this); obj.put("type", "subsegment"); obj.put("parent_id", getParent().getId()); obj.put("trace_id", parentSegment.getTraceId().toString()); return obj; }
private ObjectNode getStreamSerializeObjectNode() { ObjectNode obj = (ObjectNode) mapper.valueToTree(this); obj.put("type", "subsegment"); obj.put("parent_id", getParent().getId()); obj.put("trace_id", parentSegment.getTraceId().toString()); return obj; }
public static void addRequestInformation(Subsegment subsegment, HttpRequest request, String url) { subsegment.setNamespace(Namespace.REMOTE.toString()); Segment parentSegment = subsegment.getParentSegment(); TraceHeader header = new TraceHeader(parentSegment.getTraceId(), parentSegment.isSampled() ? subsegment.getId() : null, parentSegment.isSampled() ? SampleDecision.SAMPLED : SampleDecision.NOT_SAMPLED); request.addHeader(TraceHeader.HEADER_KEY, header.toString()); Map<String, Object> requestInformation = new HashMap<>(); requestInformation.put("url", url); requestInformation.put("method", request.getRequestLine().getMethod()); subsegment.putHttp("request", requestInformation); }
public static void addRequestInformation(Subsegment subsegment, HttpRequest request, String url) { subsegment.setNamespace(Namespace.REMOTE.toString()); Segment parentSegment = subsegment.getParentSegment(); TraceHeader header = new TraceHeader(parentSegment.getTraceId(), parentSegment.isSampled() ? subsegment.getId() : null, parentSegment.isSampled() ? SampleDecision.SAMPLED : SampleDecision.NOT_SAMPLED); request.addHeader(TraceHeader.HEADER_KEY, header.toString()); Map<String, Object> requestInformation = new HashMap<>(); requestInformation.put("url", url); requestInformation.put("method", request.getRequestLine().getMethod()); subsegment.putHttp("request", requestInformation); }
/** * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment or subsegment is currently in progress * @return the trace ID of the {@code Segment} currently in progress, or {@code null} if {@code contextMissingStrategy} suppresses exceptions and no segment or subsegment is currently in progress */ public TraceID currentTraceId() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current = context.getTraceEntity(); if (null != current) { return current.getParentSegment().getTraceId(); } else { contextMissingStrategy.contextMissing("Failed to get current trace ID: segment cannot be found.", SegmentNotFoundException.class); return null; } }
/** * * @throws SegmentNotFoundException * if {@code contextMissingStrategy} throws exceptions and no segment or subsegment is currently in progress * @return the trace ID of the {@code Segment} currently in progress, or {@code null} if {@code contextMissingStrategy} suppresses exceptions and no segment or subsegment is currently in progress */ public TraceID currentTraceId() { SegmentContext context = getSegmentContext(); if (null == context) { return null; } Entity current = context.getTraceEntity(); if (null != current) { return current.getParentSegment().getTraceId(); } else { contextMissingStrategy.contextMissing("Failed to get current trace ID: segment cannot be found.", SegmentNotFoundException.class); return null; } }
if (incomingHeader.isPresent()) { responseHeader = new TraceHeader(created.getTraceId()); if (SampleDecision.REQUESTED == incomingHeader.get().getSampled()) { responseHeader.setSampled(created.isSampled() ? SampleDecision.SAMPLED : SampleDecision.NOT_SAMPLED); responseHeader = new TraceHeader(created.getTraceId());
if (incomingHeader.isPresent()) { responseHeader = new TraceHeader(created.getTraceId()); if (SampleDecision.REQUESTED == incomingHeader.get().getSampled()) { responseHeader.setSampled(created.isSampled() ? SampleDecision.SAMPLED : SampleDecision.NOT_SAMPLED); responseHeader = new TraceHeader(created.getTraceId());
@Override public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) { SdkHttpRequest httpRequest = context.httpRequest(); Subsegment subsegment = executionAttributes.getAttribute(entityKey); if (subsegment == null) { return httpRequest; } boolean isSampled = subsegment.getParentSegment().isSampled(); TraceHeader header = new TraceHeader( subsegment.getParentSegment().getTraceId(), isSampled ? subsegment.getId() : null, isSampled ? TraceHeader.SampleDecision.SAMPLED : TraceHeader.SampleDecision.NOT_SAMPLED ); return httpRequest.toBuilder().appendHeader(TraceHeader.HEADER_KEY, header.toString()).build(); }
TraceHeader header = new TraceHeader(recorder.getCurrentSegment().getTraceId(), recorder.getCurrentSegment().isSampled() ? currentSubsegment.getId() : null, recorder.getCurrentSegment().isSampled() ? SampleDecision.SAMPLED : SampleDecision.NOT_SAMPLED);
@Override public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) { SdkHttpRequest httpRequest = context.httpRequest(); Subsegment subsegment = executionAttributes.getAttribute(entityKey); if (subsegment == null) { return httpRequest; } boolean isSampled = subsegment.getParentSegment().isSampled(); TraceHeader header = new TraceHeader( subsegment.getParentSegment().getTraceId(), isSampled ? subsegment.getId() : null, isSampled ? TraceHeader.SampleDecision.SAMPLED : TraceHeader.SampleDecision.NOT_SAMPLED ); return httpRequest.toBuilder().appendHeader(TraceHeader.HEADER_KEY, header.toString()).build(); }
if (null != environmentRootTraceId && !environmentRootTraceId.equals(parentSubsegment.getParentSegment().getTraceId())) { clearTraceEntity(); return beginSubsegment(recorder, name);
if (null != environmentRootTraceId && !environmentRootTraceId.equals(parentSubsegment.getParentSegment().getTraceId())) { clearTraceEntity(); return beginSubsegment(recorder, name);