Trace-Data-Protocol.md 6.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# Trace Data Protocol 
Trace Data Protocol describes the data format between SkyWalking agent/sniffer and backend. 

## Abstract
This protocol includes the downstream and upstream data format. Other languages agents/SDKs can use this protocol to 
uplink data to the SkyWalking backend.

- Other services, includes Register, Trace, etc., provided by HTTP/JSON and gRPC both. 

### Version
wu-sheng's avatar
wu-sheng 已提交
11
v2.0
12 13

#### gRPC proto files
wu-sheng's avatar
wu-sheng 已提交
14
[gRPC proto files](https://github.com/apache/incubator-skywalking-data-collect-protocol/tree/v2.0)
15 16 17


## Trace Segment Service
wu-sheng's avatar
wu-sheng 已提交
18
[gRPC service define](https://github.com/apache/incubator-skywalking-data-collect-protocol/blob/v2.0/TraceSegmentService.proto)
19 20

- UniqueId represents segmentId and globalTraceId. It have 3 parts(Longs), 1) applicationInstanceId, 2) ThreadId, 3) Timestamp + 10000 + seq(seq is in [0, 100000) )
wu-sheng's avatar
wu-sheng 已提交
21
- Span data please refs to [Plugin Development Guide](../setup/service-agent/java-agent/Plugin-Development-Guide.md)
22 23 24 25 26 27
- Id and name both exist, please use id if possible.
  - operationNameId/operationName 
  - networkAddress/networkAddressId
  - entryServiceName/entryServiceId
  - parentServiceName/parentServiceId
  - peerId/peer
wu-sheng's avatar
wu-sheng 已提交
28
- componentIds are defined in backend, [here](../../../apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java)
29

wu-sheng's avatar
wu-sheng 已提交
30
HTTP format:
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

Input:
```
[
  {
    "gt": [[230150, 185809, 24040000]], 
    "sg": { //TraceSegmentObject 
      "ts": [137150, 185809, 48780000], 
      "ai": 2, //applicationId
      "ii": 3, //applicationInstanceId
      "ss": [ //SpanObject
        {
          "si": 0, //spanId
          "tv": 0, //SpanType
          "lv": 2, //SpanLayer
          "ps": -1, //parentSpanId
          "st": 1501858094726, //startTime
          "et": 1501858096804, //endTime
          "ci": 3, //componentId
          "cn": "", //component
          "oi": 0, //operationNameId
          "on": "org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()", //operationName
          "pi": 0, //peerId
          "pn": "", //peer
          "ie": false, //isError
          "rs": [ //TraceSegmentReference
            {
              "pts": [230150, 185809, 24040000], //parentTraceSegmentId
              "pii": 2, //parentApplicationInstanceId
              "psp": 1, //parentSpanId
              "psi": 0, //parentServiceId
              "psn": "/dubbox-case/case/dubbox-rest", //parentServiceName
              "ni": 0,  //networkAddressId
              "nn": "172.25.0.4:20880", //networkAddress
              "eii": 2, //entryApplicationInstanceId
              "esi": 0, //entryServiceId
              "esn": "/dubbox-case/case/dubbox-rest", //entryServiceName
68
              "rv": 0 //RefTypeValue
69 70 71 72 73 74 75 76 77 78 79 80
            }
          ],
          "to": [ //KeyWithStringValue
            {
              "k": "url", //key
              "v": "rest://172.25.0.4:20880/org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()" //value
            },
            {
              "k": "http.method",
              "v": "GET"
            }
          ],
81 82 83 84 85 86 87
          "lo": [{
                "ti": 1501858094726,
                "ld": [{ 
                        "k": "NullPointException",
                        "v": "Error Stack"
                    }]
           }]
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
        },
        {
          "si": 1,
          "tv": 1,
          "lv": 1,
          "ps": 0,
          "st": 1501858094726,
          "et": 1501858095804,
          "ci": 9,
          "cn": "",
          "oi": 0,
          "on": "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]",
          "pi": 0,
          "pn": "localhost:27017",
          "ie": false,
          "to": [],
          "lo": []
        }
      ]
    }
  }
]
```
wu-sheng's avatar
wu-sheng 已提交
111 112 113


## Deprecated services
wu-sheng's avatar
wu-sheng 已提交
114 115 116
**Deprecated service**(s) are the gRPC services SkyWalking used before. In SkyWalking v6, in order to match the common 
concepts in CloudNative world, these services are deprecated. 
Although there services are still supported at this moment, but it will be removed after 6 months later(Feb. 2019).
wu-sheng's avatar
wu-sheng 已提交
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213

## ~~Application Register Service~~
**Deprecated service** 

### Abstract
Register Application Code to the backend, and receive an integer represents the application.

[gRPC service define](https://github.com/apache/incubator-skywalking-data-collect-protocol/blob/v2.0/ApplicationRegisterService.proto)

- applicationCode is the config in your `agent.config`.
- The return id is **ApplicationId** as the value in `KeyWithIntegerValue`, which will be used in further data uplink.

## ~~Discovery Services~~
**Deprecated services** 

### ~~Register Instance Service~~
[gRPC service define](https://github.com/apache/incubator-skywalking-data-collect-protocol/blob/v2.0/DiscoveryService.proto#L29)

- agentUUID generated by agent, should be unique. Stay same before reboot, at least.
- **ApplicationInstanceId** will be used in further data uplink.

HTTP format http://ip:port/instance/register(default: localhost:12800) 

Input:
```
{
    ai: x, #applicationId
    au: "", #agentUUID
    rt: x, #registerTime
    oi: "", #osinfo
}
```

Output:
```
{
    ai: x, #applicationId
    ii: x, #applicationInstanceId
}
```

### ~~Heart beat service~~
[gRPC service define](https://github.com/apache/incubator-skywalking-data-collect-protocol/blob/v2.0/DiscoveryService.proto#L32)

- Recommend to report heart beat every 20-60 seconds.
- Java agent don't use this, because JVM metrics upstream replace the capabilities of this. 

HTTP format http://ip:port/instance/heartbeat(default: localhost:12800) 

Input:
```
{
    "ii": x, #applicationInstanceId
    "ht": x #heartbeatTime, java timestamp format
}
```

## ~~Service Name Discovery Service~~
**Deprecated services**
### Abstract
Replace the literal String service(operation) name by an id(integer)

[gRPC service define](.https://github.com/apache/incubator-skywalking-data-collect-protocol/blob/v2.0/DiscoveryService.proto#L70)

- Optional service, reduce the network cost but use more memory as a buffer mapping.

HTTP format http://ip:port/servicename/discovery(default: localhost:12800) 

Input:
```
{
    ai: x, #applicationId
    sn: "", #serviceName
    st: x, #srcSpanType
}
```

Output:
```
{
    si: x, #osinfo
    el: { #element
        ai: x, #applicationId
        sn: "", #serviceName
        st: x, #srcSpanType
    }
}
```

## ~~Network Address Register Service~~
### Abstract
Network Address includes all remove service address, includes ip, port, hostname, etc., which used in RPC framework, MQ, DB, etc.

[gRPC service define](https://github.com/apache/incubator-skywalking-data-collect-protocol/blob/v2.0/NetworkAddressRegisterService.proto)

- Optional service, reduce the network cost but use more memory as a buffer mapping.