9 3.0 Collector TraceSegment in JSON format
吴晟 Wu Sheng edited this page 2017-03-21 19:55:09 +08:00

When v3.0 comes. Sky-walking also provide rest-service for collector trace data, as we had already done in v2.x. But this time, even sky-walking agent will use this service to uplink data.

Here is a simple sample about TraceSegment in JSON format. This format will be used in Collector REST-Service POST /segments. In this service, trace segments are send in batch mode, so the Message is like this

(ref source class: com.a.eye.skywalking.trace.SegmentsMessage)

[
    {
        "ts": "Segment.1490097253214.-866187727.57515.1.1",
        "st": 1490097253198,
        "et": 0,
        "rs": [
            {
                "ts": "parent_trace_0",
                "si": 1,
                "ac": "REMOTE_APP",
                "ph": "10.2.3.16:8080"
            },
            {
                "ts": "parent_trace_1",
                "si": 5,
                "ac": "REMOTE_APP",
                "ph": "10.2.3.16:8080"
            },
            {
                "ts": "parent_trace_2",
                "si": 5,
                "ac": "REMOTE_APP",
                "ph": "10.2.3.16:8080"
            }
        ],
        "ss": [
            {
                "si": 1,
                "ps": -1,
                "st": 1490097253228,
                "et": 0,
                "on": "/serviceA",
                "ts": {
                    "span.layer": "http"
                },
                "tb": {},
                "ti": {},
                "lo": []
            },
            {
                "si": 2,
                "ps": 1,
                "st": 1490097253230,
                "et": 0,
                "on": "/db/sql",
                "ts": {
                    "span.layer": "db"
                },
                "tb": {},
                "ti": {},
                "lo": [
                    {
                        "tm": 1490097253234,
                        "fi": {
                            "stack": "java.lang.NullPointerException\n\tat com.a.eye.skywalking.trace.TraceSegmentTestCase.testSerialize(TraceSegmentTestCase.java:102)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:483)\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:363)\n\tat org.junit.runner.JUnitCore.run(JUnitCore.java:137)\n\tat com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)\n\tat com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)\n\tat com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)\n\tat com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:483)\n\tat com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)\n",
                            "error.kind": "java.lang.NullPointerException",
                            "event": "error"
                        }
                    }
                ]
            }
        ],
        "ac": "billing_app",
        "gt": [
            "Trace.1490097253227.-866187727.57515.1.2"
        ]
    }
]
  • Abbreviation tables

As you can see from the ^^^ sample, we use many abbreviations, here is the table to show their meanings.

ClassName FieldName Type Abbreviation
TraceSegment traceSegmentId String ts
startTime long st
endTime long et
refs List of TraceSegmentRef rs
spans List of Span ss
applicationCode String ac
relatedGlobalTraces List of DistributedTraceId gt
TraceSegmentRef traceSegmentId String ts
spanId int si
applicationCode String ac
peerHost String ph
Span spanId int si
parentSpanId int ps
startTime long st
endTime long et
operationName String on
tagsWithStr Map<String, String> ts
tagsWithBool Map<String, Boolean> tb
tagsWithInt Map<String, Integer> ti
logs List of LogData lo
LogData time long tm
fields Map<String, String> fi
DistributedTraceId id String (as element of gt array)