Search in sources :

Example 1 with DistributedTraceId

use of org.apache.skywalking.apm.agent.core.context.ids.DistributedTraceId in project incubator-skywalking by apache.

the class TraceSegment method transform.

/**
 * This is a high CPU cost method, only called when sending to collector or test cases.
 *
 * @return the segment as GRPC service parameter
 */
public UpstreamSegment transform() {
    UpstreamSegment.Builder upstreamBuilder = UpstreamSegment.newBuilder();
    for (DistributedTraceId distributedTraceId : getRelatedGlobalTraces()) {
        upstreamBuilder = upstreamBuilder.addGlobalTraceIds(distributedTraceId.toUniqueId());
    }
    TraceSegmentObject.Builder traceSegmentBuilder = TraceSegmentObject.newBuilder();
    /**
     * Trace Segment
     */
    traceSegmentBuilder.setTraceSegmentId(this.traceSegmentId.transform());
    // SpanObject
    for (AbstractTracingSpan span : this.spans) {
        traceSegmentBuilder.addSpans(span.transform());
    }
    traceSegmentBuilder.setApplicationId(RemoteDownstreamConfig.Agent.APPLICATION_ID);
    traceSegmentBuilder.setApplicationInstanceId(RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID);
    traceSegmentBuilder.setIsSizeLimited(this.isSizeLimited);
    upstreamBuilder.setSegment(traceSegmentBuilder.build().toByteString());
    return upstreamBuilder.build();
}
Also used : DistributedTraceId(org.apache.skywalking.apm.agent.core.context.ids.DistributedTraceId) NewDistributedTraceId(org.apache.skywalking.apm.agent.core.context.ids.NewDistributedTraceId) UpstreamSegment(org.apache.skywalking.apm.network.proto.UpstreamSegment) TraceSegmentObject(org.apache.skywalking.apm.network.proto.TraceSegmentObject)

Aggregations

DistributedTraceId (org.apache.skywalking.apm.agent.core.context.ids.DistributedTraceId)1 NewDistributedTraceId (org.apache.skywalking.apm.agent.core.context.ids.NewDistributedTraceId)1 TraceSegmentObject (org.apache.skywalking.apm.network.proto.TraceSegmentObject)1 UpstreamSegment (org.apache.skywalking.apm.network.proto.UpstreamSegment)1