Search in sources :

Example 1 with SegmentDecorator

use of org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SegmentDecorator in project incubator-skywalking by apache.

the class SegmentParse method parse.

@GraphComputingMetric(name = "/segment/parse")
public boolean parse(UpstreamSegment segment, ISegmentParseService.Source source) {
    createSpanListeners();
    try {
        List<UniqueId> traceIds = segment.getGlobalTraceIdsList();
        TraceSegmentObject segmentObject = TraceSegmentObject.parseFrom(segment.getSegment());
        SegmentDecorator segmentDecorator = new SegmentDecorator(segmentObject);
        if (!preBuild(traceIds, segmentDecorator)) {
            logger.debug("This segment id exchange not success, write to buffer file, id: {}", segmentId);
            if (source.equals(ISegmentParseService.Source.Agent)) {
                writeToBufferFile(segmentId, segment);
            }
            return false;
        } else {
            logger.debug("This segment id exchange success, id: {}", segmentId);
            notifyListenerToBuild();
            buildSegment(segmentId, segmentDecorator.toByteArray());
            return true;
        }
    } catch (InvalidProtocolBufferException e) {
        logger.error(e.getMessage(), e);
    }
    return false;
}
Also used : UniqueId(org.apache.skywalking.apm.network.proto.UniqueId) SegmentDecorator(org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SegmentDecorator) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) TraceSegmentObject(org.apache.skywalking.apm.network.proto.TraceSegmentObject) GraphComputingMetric(org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric)

Aggregations

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 SegmentDecorator (org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SegmentDecorator)1 GraphComputingMetric (org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric)1 TraceSegmentObject (org.apache.skywalking.apm.network.proto.TraceSegmentObject)1 UniqueId (org.apache.skywalking.apm.network.proto.UniqueId)1