Tracing.proto 10.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

syntax = "proto3";

option java_multiple_files = true;
wu-sheng's avatar
wu-sheng 已提交
22
option java_package = "org.apache.skywalking.apm.network.language.agent.v3";
L
liuhaoyang 已提交
23
option csharp_namespace = "SkyWalking.NetworkProtocol.V3";
何延龙 已提交
24
option go_package = "skywalking/network/language/agent/v3";
25

wu-sheng's avatar
wu-sheng 已提交
26 27
import "common/Common.proto";

wu-sheng's avatar
wu-sheng 已提交
28 29
// Define a trace segment report service.
// All language agents or any trace collecting component, could use this service to send span collection to the SkyWalking OAP backend.
wu-sheng's avatar
wu-sheng 已提交
30 31 32 33 34
service TraceSegmentReportService {
    rpc collect (stream SegmentObject) returns (Commands) {
    }
}

wu-sheng's avatar
wu-sheng 已提交
35 36 37 38 39
// The segment is a collection of spans. It includes all collected spans in a simple one request context, such as a HTTP request process.
//
// We recommend the agent/SDK report all tracked data of one request once for all, such as, 
// typically, such as in Java, one segment represent all tracked operations(spans) of one request context in the same thread.
// At the same time, in some language there is not a clear concept like golang, it could represent all tracked operations of one request context.
wu-sheng's avatar
wu-sheng 已提交
40
message SegmentObject {
wu-sheng's avatar
wu-sheng 已提交
41
    // A string id represents the whole trace.
wu-sheng's avatar
wu-sheng 已提交
42
    string traceId = 1;
wu-sheng's avatar
wu-sheng 已提交
43
    // A unique id represents this segment. Other segments could use this id to reference as a child segment.
wu-sheng's avatar
wu-sheng 已提交
44
    string traceSegmentId = 2;
wu-sheng's avatar
wu-sheng 已提交
45
    // Span collections included in this segment.
wu-sheng's avatar
wu-sheng 已提交
46
    repeated SpanObject spans = 3;
wu-sheng's avatar
wu-sheng 已提交
47 48 49 50
    // **Service**. Represents a set/group of workloads which provide the same behaviours for incoming requests.
    // 
    // The logic name represents the service. This would show as a separate node in the topology.
    // The metrics analyzed from the spans, would be aggregated for this entity as the service level.
wu-sheng's avatar
wu-sheng 已提交
51
    string service = 4;
wu-sheng's avatar
wu-sheng 已提交
52 53 54 55 56
    // **Service Instance**. Each individual workload in the Service group is known as an instance. Like `pods` in Kubernetes, it 
    // doesn't need to be a single OS process, however, if you are using instrument agents, an instance is actually a real OS process.
    //
    // The logic name represents the service instance. This would show as a separate node in the instance relationship.
    // The metrics analyzed from the spans, would be aggregated for this entity as the service instance level.
wu-sheng's avatar
wu-sheng 已提交
57
    string serviceInstance = 5;
wu-sheng's avatar
wu-sheng 已提交
58 59 60 61
    // Whether the segment includes all tracked spans.
    // In the production environment tracked, some tasks could include too many spans for one request context, such as a batch update for a cache, or an async job.
    // The agent/SDK could optimize or ignore some tracked spans for better performance. 
    // In this case, the value should be flagged as TRUE.
wu-sheng's avatar
wu-sheng 已提交
62 63 64
    bool isSizeLimited = 6;
}

wu-sheng's avatar
wu-sheng 已提交
65
// Segment reference represents the link between two existing segment.
wu-sheng's avatar
wu-sheng 已提交
66
message SegmentReference {
wu-sheng's avatar
wu-sheng 已提交
67 68 69
    // Represent the reference type. It could be across thread or across process.
    // Across process means there is a downstream RPC call for this.
    // Typically, refType == CrossProcess means SpanObject#spanType = entry.
wu-sheng's avatar
wu-sheng 已提交
70
    RefType refType = 1;
wu-sheng's avatar
wu-sheng 已提交
71
    // A string id represents the whole trace.
wu-sheng's avatar
wu-sheng 已提交
72
    string traceId = 2;
wu-sheng's avatar
wu-sheng 已提交
73
    // Another segment id as the parent.
wu-sheng's avatar
wu-sheng 已提交
74
    string parentTraceSegmentId = 3;
wu-sheng's avatar
wu-sheng 已提交
75
    // The span id in the parent trace segment.
wu-sheng's avatar
wu-sheng 已提交
76
    int32 parentSpanId = 4;
wu-sheng's avatar
wu-sheng 已提交
77 78
    // The service logic name of the parent segment. 
    // If refType == CrossThread, this name is as same as the trace segment.
wu-sheng's avatar
wu-sheng 已提交
79
    string parentService = 5;
wu-sheng's avatar
wu-sheng 已提交
80 81
    // The service logic name instance of the parent segment. 
    // If refType == CrossThread, this name is as same as the trace segment.
wu-sheng's avatar
wu-sheng 已提交
82
    string parentServiceInstance = 6;
wu-sheng's avatar
wu-sheng 已提交
83 84 85
    // The endpoint name of the parent segment.
    // **Endpoint**. A path in a service for incoming requests, such as an HTTP URI path or a gRPC service class + method signature.
    // In a trace segment, the endpoint name is the name of first entry span.
wu-sheng's avatar
wu-sheng 已提交
86
    string parentEndpoint = 7;
wu-sheng's avatar
wu-sheng 已提交
87 88 89 90 91
    // The network address, including ip/hostname and port, which is used in the client side.
    // Such as Client --> use 127.0.11.8:913 -> Server
    // then, in the reference of entry span reported by Server, the value of this field is 127.0.11.8:913.
    // This plays the important role in the SkyWalking STAM(Streaming Topology Analysis Method)
    // For more details, read https://wu-sheng.github.io/STAM/
wu-sheng's avatar
wu-sheng 已提交
92 93 94
    string networkAddressUsedAtPeer = 8;
}

wu-sheng's avatar
wu-sheng 已提交
95 96 97 98
// Span represents a execution unit in the system, with duration and many other attributes.
// Span could be a method, a RPC, MQ message produce or consume.
// In the practice, the span should be added when it is really necessary, to avoid payload overhead.
// We recommend to creating spans in across process(client/server of RPC/MQ) and across thread cases only.
wu-sheng's avatar
wu-sheng 已提交
99
message SpanObject {
wu-sheng's avatar
wu-sheng 已提交
100 101
    // The number id of the span. Should be unique in the whole segment.
    // Starting at 0.
wu-sheng's avatar
wu-sheng 已提交
102
    int32 spanId = 1;
wu-sheng's avatar
wu-sheng 已提交
103 104 105
    // The number id of the parent span in the whole segment.
    // -1 represents no parent span.
    // Also, be known as the root/first span of the segment.
wu-sheng's avatar
wu-sheng 已提交
106
    int32 parentSpanId = 2;
wu-sheng's avatar
wu-sheng 已提交
107 108
    // Start timestamp in milliseconds of this span,
    // measured between the current time and midnight, January 1, 1970 UTC.
wu-sheng's avatar
wu-sheng 已提交
109
    int64 startTime = 3;
wu-sheng's avatar
wu-sheng 已提交
110 111
    // End timestamp in milliseconds of this span,
    // measured between the current time and midnight, January 1, 1970 UTC.
wu-sheng's avatar
wu-sheng 已提交
112
    int64 endTime = 4;
wu-sheng's avatar
wu-sheng 已提交
113 114 115
    // <Optional> 
    // In the across thread and across process, these references targeting the parent segments.
    // The references usually have only one element, but in batch consumer case, such as in MQ or async batch process, it could be multiple.
wu-sheng's avatar
wu-sheng 已提交
116
    repeated SegmentReference refs = 5;
wu-sheng's avatar
wu-sheng 已提交
117 118 119 120 121 122 123
    // A logic name represents this span.
    //
    // We don't recommend to include the parameter, such as HTTP request parameters, as a part of the operation, especially this is the name of the entry span.
    // All statistic for the endpoints are aggregated base on this name. Those parameters should be added in the tags if necessary.
    // If in some cases, it have to be a part of the operation name,
    // users should use the Group Parameterized Endpoints capability at the backend to get the meaningful metrics. 
    // Read https://github.com/apache/skywalking/blob/master/docs/en/setup/backend/endpoint-grouping-rules.md
wu-sheng's avatar
wu-sheng 已提交
124
    string operationName = 6;
wu-sheng's avatar
wu-sheng 已提交
125 126 127
    // Remote address of the peer in RPC/MQ case.
    // This is required when spanType = Exit, as it is a part of the SkyWalking STAM(Streaming Topology Analysis Method).
    // For more details, read https://wu-sheng.github.io/STAM/
wu-sheng's avatar
wu-sheng 已提交
128
    string peer = 7;
wu-sheng's avatar
wu-sheng 已提交
129
    // Span type represents the role in the RPC context.
wu-sheng's avatar
wu-sheng 已提交
130
    SpanType spanType = 8;
wu-sheng's avatar
wu-sheng 已提交
131
    // Span layer represent the component tech stack, related to the network tech.
wu-sheng's avatar
wu-sheng 已提交
132
    SpanLayer spanLayer = 9;
wu-sheng's avatar
wu-sheng 已提交
133 134 135 136 137 138
    // Component id is a predefinited number id in the SkyWalking.
    // It represents the framework, tech stack used by this tracked span, such as Spring.
    // All IDs are defined in the https://github.com/apache/skywalking/blob/master/oap-server/server-bootstrap/src/main/resources/component-libraries.yml
    // Send a pull request if you want to add languages, components or mapping defintions,
    // all public components could be accepted.
    // Follow this doc for more details, https://github.com/apache/skywalking/blob/master/docs/en/guides/Component-library-settings.md
wu-sheng's avatar
wu-sheng 已提交
139
    int32 componentId = 10;
wu-sheng's avatar
wu-sheng 已提交
140 141 142
    // The status of the span. False means the tracked execution ends in the unexpected status.
    // This affects the successful rate statistic in the backend.
    // Exception or error code happened in the tracked process doesn't mean isError == true, the implementations of agent plugin and tracing SDK make the final decision.
wu-sheng's avatar
wu-sheng 已提交
143
    bool isError = 11;
wu-sheng's avatar
wu-sheng 已提交
144 145
    // String key, String value pair.
    // Tags provides more informance, includes parameters.
wu-sheng's avatar
wu-sheng 已提交
146
    repeated KeyStringValuePair tags = 12;
wu-sheng's avatar
wu-sheng 已提交
147 148
    // String key, String value pair with an accurate timestamp.
    // Logging some events happening in the context of the span duration.
wu-sheng's avatar
wu-sheng 已提交
149
    repeated Log logs = 13;
wu-sheng's avatar
wu-sheng 已提交
150 151 152 153
    // Force the backend don't do analysis, if the value is TRUE.
    // The backend has its own configurations to follow or override this.
    // 
    // Use this mostly because the agent/SDK could know more context of the service role.
wu-sheng's avatar
wu-sheng 已提交
154
    bool skipAnalysis = 14;
wu-sheng's avatar
wu-sheng 已提交
155 156 157
}

message Log {
wu-sheng's avatar
wu-sheng 已提交
158 159
    // The timestamp in milliseconds of this event.,
    // measured between the current time and midnight, January 1, 1970 UTC.
wu-sheng's avatar
wu-sheng 已提交
160
    int64 time = 1;
wu-sheng's avatar
wu-sheng 已提交
161
    // String key, String value pair.
wu-sheng's avatar
wu-sheng 已提交
162
    repeated KeyStringValuePair data = 2;
163 164
}

wu-sheng's avatar
wu-sheng 已提交
165
// Map to the type of span
wu-sheng's avatar
wu-sheng 已提交
166
enum SpanType {
wu-sheng's avatar
wu-sheng 已提交
167
    // Server side of RPC. Consumer side of MQ.
wu-sheng's avatar
wu-sheng 已提交
168
    Entry = 0;
wu-sheng's avatar
wu-sheng 已提交
169
    // Client side of RPC. Producer side of MQ.
wu-sheng's avatar
wu-sheng 已提交
170
    Exit = 1;
wu-sheng's avatar
wu-sheng 已提交
171
    // A common local code execution.
wu-sheng's avatar
wu-sheng 已提交
172 173 174
    Local = 2;
}

wu-sheng's avatar
wu-sheng 已提交
175
// A ID could be represented by multiple string sections.
wu-sheng's avatar
wu-sheng 已提交
176 177
message ID {
    repeated string id = 1;
178 179
}

wu-sheng's avatar
wu-sheng 已提交
180
// Type of the reference
181
enum RefType {
wu-sheng's avatar
wu-sheng 已提交
182
    // Map to the reference targeting the segment in another OS process.
183
    CrossProcess = 0;
wu-sheng's avatar
wu-sheng 已提交
184 185
    // Map to the reference targeting the segment in the same process of the current one, just across thread.
    // This is only used when the coding language has the thread concept. 
186 187 188
    CrossThread = 1;
}

wu-sheng's avatar
wu-sheng 已提交
189
// Map to the layer of span
190
enum SpanLayer {
wu-sheng's avatar
wu-sheng 已提交
191
    // Unknown layer. Could be anything.
192
    Unknown = 0;
wu-sheng's avatar
wu-sheng 已提交
193
    // A database layer, used in tracing the database client component.
194
    Database = 1;
wu-sheng's avatar
wu-sheng 已提交
195
    // A RPC layer, used in both client and server sides of RPC component.
196
    RPCFramework = 2;
wu-sheng's avatar
wu-sheng 已提交
197
    // HTTP is a more specific RPCFramework.
198
    Http = 3;
wu-sheng's avatar
wu-sheng 已提交
199
    // A MQ layer, used in both producer and consuer sides of the MQ component.
200
    MQ = 4;
wu-sheng's avatar
wu-sheng 已提交
201
    // A cache layer, used in tracing the cache client component.
202
    Cache = 5;
wu-sheng's avatar
wu-sheng 已提交
203
}