同步操作将从 SkyWalking/skywalking 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
这篇文章主要介绍3.2版本的Collector对外提供的服务协议。一般情况下,使用者和开发者都无需了解此协议细节。但是在庞大的开源生态中,我们已经收到过多次有公司或个人的使用案例,使用自己的非Java探针(PHP,GO等)探针,接入我们的Collector进行数据分析和监控。
Collector从3.2开始,对外同时提供gRPC和HTTP RESTFul两种类型的协议。从效率上,我们推荐使用gRPC
本章节,描述官方java探针使用的网络协议
**Collector服务发现协议是探针启动时,第一个调用的服务。**通过服务,查找对应的gRPC服务地址与端口列表,并在由客户端选择其中任意一个作为服务端。此服务需周期性调用,确保探针本地的服务端口列表是准确有效的。
HTTP GET
请求
GET操作:http://collectorIp:port/agentstream/grpc 。 其中/agentstream/grpc
是默认值,如需修改,需要参考collector相关配置。
返回 JSON数组,数组的每个元素,为一个有效的gRPC服务地址。
["ip address1:port1","ip address2:port2","ip address3:port3"]
应用注册服务,是将手动设计的applicationCode,以及ip:port沟通的服务地址,转换成数字的服务。此服务会在后续的传输过程中,有效降低网络带宽需求。
gRPC服务
syntax = "proto3";
option java_multiple_files = true;
option java_package = "org.skywalking.apm.network.proto";
import "KeyWithIntegerValue.proto";
//register service for ApplicationCode, this service is called when service starts.
service ApplicationRegisterService {
rpc register (Application) returns (ApplicationMapping) {
}
}
message Application {
repeated string applicationCode = 1;
}
message ApplicationMapping {
repeated KeyWithIntegerValue application = 1;
}
ip:port
地址列表应用实例发现服务存在三个子服务,分别是实例注册服务,实例心跳服务,实例注册重连服务。这三个服务负责获取和保持应用实例在线的功能。
gRPC服务
service InstanceDiscoveryService {
rpc register (ApplicationInstance) returns (ApplicationInstanceMapping) {
}
}
message ApplicationInstance {
int32 applicationId = 1;
string agentUUID = 2;
int64 registerTime = 3;
OSInfo osinfo = 4;
}
message OSInfo {
string osName = 1;
string hostname = 2;
int32 processNo = 3;
repeated string ipv4s = 4;
}
message ApplicationInstanceMapping {
int32 applicationId = 1;
int32 applicationInstanceId = 2;
}
service InstanceDiscoveryService {
rpc heartbeat (ApplicationInstanceHeartbeat) returns (Downstream) {
}
}
message ApplicationInstanceHeartbeat {
int32 applicationInstanceId = 1;
int64 heartbeatTime = 2;
}
service InstanceDiscoveryService {
rpc registerRecover (ApplicationInstanceRecover) returns (Downstream) {
}
}
message ApplicationInstanceRecover {
int32 applicationId = 1;
int32 applicationInstanceId = 2;
int64 registerTime = 3;
OSInfo osinfo = 4;
}
服务名注册发现服务,是将应用内的服务名(operationName)替换为id的服务。
gRPC服务
//discovery service for ServiceName by Network address or application code
service ServiceNameDiscoveryService {
rpc discovery (ServiceNameCollection) returns (ServiceNameMappingCollection) {
}
}
message ServiceNameCollection {
repeated ServiceNameElement elements = 1;
}
message ServiceNameMappingCollection {
repeated ServiceNameMappingElement elements = 1;
}
message ServiceNameMappingElement {
int32 serviceId = 1;
ServiceNameElement element = 2;
}
message ServiceNameElement {
string serviceName = 1;
int32 applicationId = 2;
}
上报当前实例的JVM信息,每秒上报一次。
gRPC服务
syntax = "proto3";
option java_multiple_files = true;
option java_package = "org.skywalking.apm.network.proto";
import "Downstream.proto";
service JVMMetricsService {
rpc collect (JVMMetrics) returns (Downstream) {
}
}
message JVMMetrics {
repeated JVMMetric metrics = 1;
int64 applicationInstanceId = 2;
}
message JVMMetric {
int64 time = 1;
CPU cpu = 2;
repeated Memory memory = 3;
repeated MemoryPool memoryPool = 4;
repeated GC gc = 5;
}
message CPU {
double usagePercent = 2;
}
message Memory {
bool isHeap = 1;
int64 init = 2;
int64 max = 3;
int64 used = 4;
int64 committed = 5;
}
message MemoryPool {
PoolType type = 1;
bool isHeap = 2;
int64 init = 3;
int64 max = 4;
int64 used = 5;
int64 commited = 6;
}
enum PoolType {
CODE_CACHE_USAGE = 0;
NEWGEN_USAGE = 1;
OLDGEN_USAGE = 2;
SURVIVOR_USAGE = 3;
PERMGEN_USAGE = 4;
METASPACE_USAGE = 5;
}
message GC {
GCPhrase phrase = 1;
int64 count = 2;
int64 time = 3;
}
enum GCPhrase {
NEW = 0;
OLD = 1;
}
上报调用链信息
gRPC服务
syntax = "proto3";
option java_multiple_files = true;
option java_package = "org.skywalking.apm.network.proto";
import "Downstream.proto";
import "KeyWithStringValue.proto";
service TraceSegmentService {
rpc collect (stream UpstreamSegment) returns (Downstream) {
}
}
message UpstreamSegment {
repeated UniqueId globalTraceIds = 1;
bytes segment = 2; // the byte array of TraceSegmentObject
}
message UniqueId {
repeated int64 idParts = 1;
}
message TraceSegmentObject {
UniqueId traceSegmentId = 1;
repeated TraceSegmentReference refs = 2;
repeated SpanObject spans = 3;
int32 applicationId = 4;
int32 applicationInstanceId = 5;
}
message TraceSegmentReference {
RefType refType = 1;
UniqueId parentTraceSegmentId = 2;
int32 parentSpanId = 3;
int32 parentApplicationInstanceId = 4;
string networkAddress = 5;
int32 networkAddressId = 6;
string entryServiceName = 7;
int32 entryServiceId = 8;
string parentServiceName = 9;
int32 parentServiceId = 10;
}
message SpanObject {
int32 spanId = 1;
int32 parentSpanId = 2;
int64 startTime = 3;
int64 endTime = 4;
int32 operationNameId = 5;
string operationName = 6;
int32 peerId = 7;
string peer = 8;
SpanType spanType = 9;
SpanLayer spanLayer = 10;
int32 componentId = 11;
string component = 12;
bool isError = 13;
repeated KeyWithStringValue tags = 14;
repeated LogMessage logs = 15;
}
enum RefType {
CrossProcess = 0;
CrossThread = 1;
}
enum SpanType {
Entry = 0;
Exit = 1;
Local = 2;
}
enum SpanLayer {
Database = 0;
RPCFramework = 1;
Http = 2;
MQ = 3;
}
message LogMessage {
int64 time = 1;
repeated KeyWithStringValue data = 2;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。