You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2018/11/19 06:55:17 UTC
[incubator-skywalking] branch v6-protocol updated: Support new
protocol at agent side.
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch v6-protocol
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/v6-protocol by this push:
new 239b1c7 Support new protocol at agent side.
239b1c7 is described below
commit 239b1c715b963d9218069347dec439e77639f4ee
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Mon Nov 19 14:55:08 2018 +0800
Support new protocol at agent side.
---
apm-protocol/apm-network/src/main/proto | 2 +-
.../skywalking/apm/agent/core/conf/Config.java | 4 +-
.../agent/core/conf/RemoteDownstreamConfig.java | 4 +-
.../apm/agent/core/context/ContextManager.java | 4 +-
.../apm/agent/core/context/TracingContext.java | 26 ++--
.../agent/core/context/ids/GlobalIdGenerator.java | 4 +-
.../core/context/trace/AbstractTracingSpan.java | 5 +-
.../apm/agent/core/context/trace/ExitSpan.java | 7 +-
.../agent/core/context/trace/LogDataEntity.java | 11 +-
.../core/context/trace/StackBasedTracingSpan.java | 2 +-
.../apm/agent/core/context/trace/TraceSegment.java | 11 +-
.../agent/core/context/trace/TraceSegmentRef.java | 20 +--
.../apm/agent/core/context/util/KeyValuePair.java | 6 +-
.../agent/core/dictionary/DictionaryManager.java | 6 +-
.../core/dictionary/EndpointNameDictionary.java | 159 +++++++++++++++++++++
.../core/dictionary/NetworkAddressDictionary.java | 24 ++--
.../core/dictionary/OperationNameDictionary.java | 155 --------------------
.../skywalking/apm/agent/core/jvm/JVMService.java | 40 +++---
....java => ServiceAndEndpointRegisterClient.java} | 39 +++--
.../core/remote/TraceSegmentServiceClient.java | 10 +-
...ache.skywalking.apm.agent.core.boot.BootService | 2 +-
.../apm/agent/core/context/ContextManagerTest.java | 8 +-
.../core/context/IgnoredTracerContextTest.java | 4 +-
.../core/remote/TraceSegmentServiceClientTest.java | 4 +-
.../apm/agent/test/tools/AgentServiceRule.java | 4 +-
docs/en/guides/Java-Plugin-Development-Guide.md | 8 +-
docs/en/protocols/Trace-Data-Protocol.md | 14 +-
27 files changed, 291 insertions(+), 292 deletions(-)
diff --git a/apm-protocol/apm-network/src/main/proto b/apm-protocol/apm-network/src/main/proto
index 7e0d329..005879d 160000
--- a/apm-protocol/apm-network/src/main/proto
+++ b/apm-protocol/apm-network/src/main/proto
@@ -1 +1 @@
-Subproject commit 7e0d329630af601e62bb48941902c0ae46913160
+Subproject commit 005879debb510206a9de4f3b94d4132ec8ff2179
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
index b44f40f..bd2085e 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
@@ -114,9 +114,9 @@ public class Config {
/**
* The buffer size of application codes and peer
*/
- public static int APPLICATION_CODE_BUFFER_SIZE = 10 * 10000;
+ public static int SERVICE_CODE_BUFFER_SIZE = 10 * 10000;
- public static int OPERATION_NAME_BUFFER_SIZE = 1000 * 10000;
+ public static int ENDPOINT_NAME_BUFFER_SIZE = 1000 * 10000;
}
public static class Logging {
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/RemoteDownstreamConfig.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/RemoteDownstreamConfig.java
index d236b62..d246786 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/RemoteDownstreamConfig.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/RemoteDownstreamConfig.java
@@ -29,8 +29,8 @@ import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil;
*/
public class RemoteDownstreamConfig {
public static class Agent {
- public volatile static int APPLICATION_ID = DictionaryUtil.nullValue();
+ public volatile static int SERVICE_ID = DictionaryUtil.nullValue();
- public volatile static int APPLICATION_INSTANCE_ID = DictionaryUtil.nullValue();
+ public volatile static int SERVICE_INSTANCE_ID = DictionaryUtil.nullValue();
}
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
index a2ea19a..aeaa708 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
@@ -57,8 +57,8 @@ public class ContextManager implements TracingContextListener, BootService, Igno
}
context = new IgnoredTracerContext();
} else {
- if (RemoteDownstreamConfig.Agent.APPLICATION_ID != DictionaryUtil.nullValue()
- && RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID != DictionaryUtil.nullValue()
+ if (RemoteDownstreamConfig.Agent.SERVICE_ID != DictionaryUtil.nullValue()
+ && RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID != DictionaryUtil.nullValue()
) {
context = EXTEND_SERVICE.createTraceContext(operationName, forceSampling);
} else {
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java
index c4a3bf1..170c994 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java
@@ -251,7 +251,7 @@ public class TracingContext implements AbstractTracerContext {
final AbstractSpan parentSpan = peek();
final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
if (parentSpan != null && parentSpan.isEntry()) {
- entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
+ entrySpan = (AbstractTracingSpan)DictionaryManager.findEndpointSection()
.findOnly(segment.getApplicationId(), operationName)
.doInCondition(new PossibleFound.FoundAndObtain() {
@Override public Object doProcess(int operationId) {
@@ -264,7 +264,7 @@ public class TracingContext implements AbstractTracerContext {
});
return entrySpan.start();
} else {
- entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
+ entrySpan = (AbstractTracingSpan)DictionaryManager.findEndpointSection()
.findOnly(segment.getApplicationId(), operationName)
.doInCondition(new PossibleFound.FoundAndObtain() {
@Override public Object doProcess(int operationId) {
@@ -294,19 +294,11 @@ public class TracingContext implements AbstractTracerContext {
}
AbstractSpan parentSpan = peek();
final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
- AbstractTracingSpan span = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
- .findOrPrepare4Register(segment.getApplicationId(), operationName, false, false)
- .doInCondition(new PossibleFound.FoundAndObtain() {
- @Override
- public Object doProcess(int operationId) {
- return new LocalSpan(spanIdGenerator++, parentSpanId, operationId);
- }
- }, new PossibleFound.NotFoundAndObtain() {
- @Override
- public Object doProcess() {
- return new LocalSpan(spanIdGenerator++, parentSpanId, operationName);
- }
- });
+ /**
+ * From v6.0.0-beta, local span doesn't do op name register.
+ * All op name register is related to entry and exit spans only.
+ */
+ AbstractTracingSpan span = new LocalSpan(spanIdGenerator++, parentSpanId, operationName);
span.start();
return push(span);
}
@@ -336,7 +328,7 @@ public class TracingContext implements AbstractTracerContext {
return new NoopExitSpan(peerId);
}
- return DictionaryManager.findOperationNameCodeSection()
+ return DictionaryManager.findEndpointSection()
.findOnly(segment.getApplicationId(), operationName)
.doInCondition(
new PossibleFound.FoundAndObtain() {
@@ -359,7 +351,7 @@ public class TracingContext implements AbstractTracerContext {
return new NoopExitSpan(remotePeer);
}
- return DictionaryManager.findOperationNameCodeSection()
+ return DictionaryManager.findEndpointSection()
.findOnly(segment.getApplicationId(), operationName)
.doInCondition(
new PossibleFound.FoundAndObtain() {
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ids/GlobalIdGenerator.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ids/GlobalIdGenerator.java
index b6060f7..da2f206 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ids/GlobalIdGenerator.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ids/GlobalIdGenerator.java
@@ -52,13 +52,13 @@ public final class GlobalIdGenerator {
* @return an array contains three long numbers, which represents a unique id.
*/
public static ID generate() {
- if (RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID == DictionaryUtil.nullValue()) {
+ if (RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID == DictionaryUtil.nullValue()) {
throw new IllegalStateException();
}
IDContext context = THREAD_ID_SEQUENCE.get();
return new ID(
- RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID,
+ RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID,
Thread.currentThread().getId(),
context.nextSeq()
);
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java
index b0116c1..e840b73 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java
@@ -25,6 +25,7 @@ import org.apache.skywalking.apm.agent.core.context.util.KeyValuePair;
import org.apache.skywalking.apm.agent.core.context.util.ThrowableTransformer;
import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil;
import org.apache.skywalking.apm.network.language.agent.*;
+import org.apache.skywalking.apm.network.language.agent.v2.SpanObjectV2;
import org.apache.skywalking.apm.network.trace.component.Component;
/**
@@ -244,8 +245,8 @@ public abstract class AbstractTracingSpan implements AbstractSpan {
return this;
}
- public SpanObject.Builder transform() {
- SpanObject.Builder spanBuilder = SpanObject.newBuilder();
+ public SpanObjectV2.Builder transform() {
+ SpanObjectV2.Builder spanBuilder = SpanObjectV2.newBuilder();
spanBuilder.setSpanId(this.spanId);
spanBuilder.setParentSpanId(parentSpanId);
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/ExitSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/ExitSpan.java
index aeae4a2..400e5ba 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/ExitSpan.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/ExitSpan.java
@@ -20,8 +20,7 @@
package org.apache.skywalking.apm.agent.core.context.trace;
import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil;
-import org.apache.skywalking.apm.network.language.agent.*;
-
+import org.apache.skywalking.apm.network.language.agent.v2.SpanObjectV2;
import org.apache.skywalking.apm.network.trace.component.Component;
/**
@@ -119,8 +118,8 @@ public class ExitSpan extends StackBasedTracingSpan implements WithPeerInfo {
return this;
}
- @Override public SpanObject.Builder transform() {
- SpanObject.Builder spanBuilder = super.transform();
+ @Override public SpanObjectV2.Builder transform() {
+ SpanObjectV2.Builder spanBuilder = super.transform();
if (peerId != DictionaryUtil.nullValue()) {
spanBuilder.setPeerId(peerId);
} else {
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/LogDataEntity.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/LogDataEntity.java
index 9aa7b0a..dbca6db 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/LogDataEntity.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/LogDataEntity.java
@@ -16,17 +16,16 @@
*
*/
-
package org.apache.skywalking.apm.agent.core.context.trace;
import java.util.LinkedList;
import java.util.List;
import org.apache.skywalking.apm.agent.core.context.util.KeyValuePair;
-import org.apache.skywalking.apm.network.language.agent.*;
+import org.apache.skywalking.apm.network.language.agent.v2.Log;
/**
- * The <code>LogDataEntity</code> represents a collection of {@link KeyValuePair},
- * contains several fields of a logging operation.
+ * The <code>LogDataEntity</code> represents a collection of {@link KeyValuePair}, contains several fields of a logging
+ * operation.
*
* @author wusheng
*/
@@ -62,8 +61,8 @@ public class LogDataEntity {
}
}
- public LogMessage transform() {
- LogMessage.Builder logMessageBuilder = LogMessage.newBuilder();
+ public Log transform() {
+ Log.Builder logMessageBuilder = Log.newBuilder();
for (KeyValuePair log : logs) {
logMessageBuilder.addData(log.transform());
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/StackBasedTracingSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/StackBasedTracingSpan.java
index 4ee8957..f89c30b 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/StackBasedTracingSpan.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/StackBasedTracingSpan.java
@@ -46,7 +46,7 @@ public abstract class StackBasedTracingSpan extends AbstractTracingSpan {
public boolean finish(TraceSegment owner) {
if (--stackDepth == 0) {
if (this.operationId == DictionaryUtil.nullValue()) {
- this.operationId = (Integer)DictionaryManager.findOperationNameCodeSection()
+ this.operationId = (Integer)DictionaryManager.findEndpointSection()
.findOrPrepare4Register(owner.getApplicationId(), operationName, this.isEntry(), this.isExit())
.doInCondition(
new PossibleFound.FoundAndObtain() {
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegment.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegment.java
index f5c4581..ed07423 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegment.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegment.java
@@ -28,6 +28,7 @@ import org.apache.skywalking.apm.agent.core.context.ids.GlobalIdGenerator;
import org.apache.skywalking.apm.agent.core.context.ids.ID;
import org.apache.skywalking.apm.agent.core.context.ids.NewDistributedTraceId;
import org.apache.skywalking.apm.network.language.agent.*;
+import org.apache.skywalking.apm.network.language.agent.v2.SegmentObject;
/**
* {@link TraceSegment} is a segment or fragment of the distributed trace. See https://github.com/opentracing/specification/blob/master/specification.md#the-opentracing-data-model
@@ -125,7 +126,7 @@ public class TraceSegment {
}
public int getApplicationId() {
- return RemoteDownstreamConfig.Agent.APPLICATION_ID;
+ return RemoteDownstreamConfig.Agent.SERVICE_ID;
}
public boolean hasRef() {
@@ -162,7 +163,7 @@ public class TraceSegment {
for (DistributedTraceId distributedTraceId : getRelatedGlobalTraces()) {
upstreamBuilder = upstreamBuilder.addGlobalTraceIds(distributedTraceId.toUniqueId());
}
- TraceSegmentObject.Builder traceSegmentBuilder = TraceSegmentObject.newBuilder();
+ SegmentObject.Builder traceSegmentBuilder = SegmentObject.newBuilder();
/**
* Trace Segment
*/
@@ -173,8 +174,8 @@ public class TraceSegment {
for (AbstractTracingSpan span : this.spans) {
traceSegmentBuilder.addSpans(span.transform());
}
- traceSegmentBuilder.setApplicationId(RemoteDownstreamConfig.Agent.APPLICATION_ID);
- traceSegmentBuilder.setApplicationInstanceId(RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID);
+ traceSegmentBuilder.setServiceId(RemoteDownstreamConfig.Agent.SERVICE_ID);
+ traceSegmentBuilder.setServiceInstanceId(RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID);
traceSegmentBuilder.setIsSizeLimited(this.isSizeLimited);
upstreamBuilder.setSegment(traceSegmentBuilder.build().toByteString());
@@ -192,6 +193,6 @@ public class TraceSegment {
}
public int getApplicationInstanceId() {
- return RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID;
+ return RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID;
}
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java
index ef3f287..72db198 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java
@@ -24,7 +24,7 @@ import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
import org.apache.skywalking.apm.agent.core.context.ids.ID;
import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil;
import org.apache.skywalking.apm.network.language.agent.RefType;
-import org.apache.skywalking.apm.network.language.agent.TraceSegmentReference;
+import org.apache.skywalking.apm.network.language.agent.v2.SegmentReference;
import org.apache.skywalking.apm.util.StringUtil;
/**
@@ -95,7 +95,7 @@ public class TraceSegmentRef {
this.type = SegmentRefType.CROSS_THREAD;
this.traceSegmentId = snapshot.getTraceSegmentId();
this.spanId = snapshot.getSpanId();
- this.parentApplicationInstanceId = RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID;
+ this.parentApplicationInstanceId = RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID;
this.entryApplicationInstanceId = snapshot.getEntryApplicationInstanceId();
String entryOperationName = snapshot.getEntryOperationName();
if (!StringUtil.isEmpty(entryOperationName)) {
@@ -127,8 +127,8 @@ public class TraceSegmentRef {
return entryApplicationInstanceId;
}
- public TraceSegmentReference transform() {
- TraceSegmentReference.Builder refBuilder = TraceSegmentReference.newBuilder();
+ public SegmentReference transform() {
+ SegmentReference.Builder refBuilder = SegmentReference.newBuilder();
if (SegmentRefType.CROSS_PROCESS.equals(type)) {
refBuilder.setRefType(RefType.CrossProcess);
if (peerId == DictionaryUtil.nullValue()) {
@@ -140,8 +140,8 @@ public class TraceSegmentRef {
refBuilder.setRefType(RefType.CrossThread);
}
- refBuilder.setParentApplicationInstanceId(parentApplicationInstanceId);
- refBuilder.setEntryApplicationInstanceId(entryApplicationInstanceId);
+ refBuilder.setParentServiceInstanceId(parentApplicationInstanceId);
+ refBuilder.setEntryServiceInstanceId(entryApplicationInstanceId);
refBuilder.setParentTraceSegmentId(traceSegmentId.transform());
refBuilder.setParentSpanId(spanId);
/**
@@ -151,17 +151,17 @@ public class TraceSegmentRef {
*/
if (entryOperationId == DictionaryUtil.nullValue()) {
if (!StringUtil.isEmpty(entryOperationName)) {
- refBuilder.setEntryServiceName(entryOperationName);
+ refBuilder.setEntryEndpoint(entryOperationName);
}
} else {
- refBuilder.setEntryServiceId(entryOperationId);
+ refBuilder.setEntryEndpointId(entryOperationId);
}
if (parentOperationId == DictionaryUtil.nullValue()) {
if (!StringUtil.isEmpty(parentOperationName)) {
- refBuilder.setParentServiceName(parentOperationName);
+ refBuilder.setParentEndpoint(parentOperationName);
}
} else {
- refBuilder.setParentServiceId(parentOperationId);
+ refBuilder.setParentEndpointId(parentOperationId);
}
return refBuilder.build();
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/util/KeyValuePair.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/util/KeyValuePair.java
index e9ddc64..86b4822 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/util/KeyValuePair.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/util/KeyValuePair.java
@@ -19,7 +19,7 @@
package org.apache.skywalking.apm.agent.core.context.util;
-import org.apache.skywalking.apm.network.language.agent.*;
+import org.apache.skywalking.apm.network.common.KeyStringValuePair;
/**
* The <code>KeyValuePair</code> represents a object which contains a string key and a string value.
@@ -43,8 +43,8 @@ public class KeyValuePair {
return value;
}
- public KeyWithStringValue transform() {
- KeyWithStringValue.Builder keyValueBuilder = KeyWithStringValue.newBuilder();
+ public KeyStringValuePair transform() {
+ KeyStringValuePair.Builder keyValueBuilder = KeyStringValuePair.newBuilder();
keyValueBuilder.setKey(key);
if (value != null) {
keyValueBuilder.setValue(value);
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java
index 7d35432..bd50d47 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java
@@ -31,9 +31,9 @@ public class DictionaryManager {
}
/**
- * @return {@link OperationNameDictionary} to find service id.
+ * @return {@link EndpointNameDictionary} to find service id.
*/
- public static OperationNameDictionary findOperationNameCodeSection() {
- return OperationNameDictionary.INSTANCE;
+ public static EndpointNameDictionary findEndpointSection() {
+ return EndpointNameDictionary.INSTANCE;
}
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/EndpointNameDictionary.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/EndpointNameDictionary.java
new file mode 100644
index 0000000..9b0c957
--- /dev/null
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/EndpointNameDictionary.java
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.skywalking.apm.agent.core.dictionary;
+
+import io.netty.util.internal.ConcurrentSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.skywalking.apm.network.common.DetectPoint;
+import org.apache.skywalking.apm.network.register.v2.Endpoint;
+import org.apache.skywalking.apm.network.register.v2.EndpointMapping;
+import org.apache.skywalking.apm.network.register.v2.EndpointMappingElement;
+import org.apache.skywalking.apm.network.register.v2.Enpoints;
+import org.apache.skywalking.apm.network.register.v2.RegisterGrpc;
+
+import static org.apache.skywalking.apm.agent.core.conf.Config.Dictionary.ENDPOINT_NAME_BUFFER_SIZE;
+
+/**
+ * @author wusheng
+ */
+public enum EndpointNameDictionary {
+ INSTANCE;
+ private Map<OperationNameKey, Integer> endpointDictionary = new ConcurrentHashMap<OperationNameKey, Integer>();
+ private Set<OperationNameKey> unRegisterEndpoints = new ConcurrentSet<OperationNameKey>();
+
+ public PossibleFound findOrPrepare4Register(int serviceId, String endpointName,
+ boolean isEntry, boolean isExit) {
+ return find0(serviceId, endpointName, isEntry, isExit, true);
+ }
+
+ public PossibleFound findOnly(int serviceId, String endpointName) {
+ return find0(serviceId, endpointName, false, false, false);
+ }
+
+ private PossibleFound find0(int serviceId, String endpointName,
+ boolean isEntry, boolean isExit, boolean registerWhenNotFound) {
+ if (endpointName == null || endpointName.length() == 0) {
+ return new NotFound();
+ }
+ OperationNameKey key = new OperationNameKey(serviceId, endpointName, isEntry, isExit);
+ Integer operationId = endpointDictionary.get(key);
+ if (operationId != null) {
+ return new Found(operationId);
+ } else {
+ if (registerWhenNotFound &&
+ endpointDictionary.size() + unRegisterEndpoints.size() < ENDPOINT_NAME_BUFFER_SIZE) {
+ unRegisterEndpoints.add(key);
+ }
+ return new NotFound();
+ }
+ }
+
+ public void syncRemoteDictionary(
+ RegisterGrpc.RegisterBlockingStub serviceNameDiscoveryServiceBlockingStub) {
+ if (unRegisterEndpoints.size() > 0) {
+ Enpoints.Builder builder = Enpoints.newBuilder();
+ for (OperationNameKey operationNameKey : unRegisterEndpoints) {
+ Endpoint endpoint = Endpoint.newBuilder()
+ .setServiceId(operationNameKey.getServiceId())
+ .setEndpointName(operationNameKey.getEndpointName())
+ .setFrom(operationNameKey.getSpanType())
+ .build();
+ builder.addEndpoints(endpoint);
+ }
+ EndpointMapping serviceNameMappingCollection = serviceNameDiscoveryServiceBlockingStub.doEndpointRegister(builder.build());
+ if (serviceNameMappingCollection.getElementsCount() > 0) {
+ for (EndpointMappingElement element : serviceNameMappingCollection.getElementsList()) {
+ OperationNameKey key = new OperationNameKey(
+ element.getServiceId(),
+ element.getEndpointName(),
+ DetectPoint.server.equals(element.getFrom()),
+ DetectPoint.client.equals(element.getFrom()));
+ unRegisterEndpoints.remove(key);
+ endpointDictionary.put(key, element.getServiceId());
+ }
+ }
+ }
+ }
+
+ private class OperationNameKey {
+ private int serviceId;
+ private String endpointName;
+ private boolean isEntry;
+ private boolean isExit;
+
+ public OperationNameKey(int serviceId, String endpointName, boolean isEntry, boolean isExit) {
+ this.serviceId = serviceId;
+ this.endpointName = endpointName;
+ this.isEntry = isEntry;
+ this.isExit = isExit;
+ }
+
+ public int getServiceId() {
+ return serviceId;
+ }
+
+ public String getEndpointName() {
+ return endpointName;
+ }
+
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ OperationNameKey key = (OperationNameKey)o;
+
+ boolean isApplicationMatch = false;
+ if (serviceId == key.serviceId) {
+ isApplicationMatch = true;
+ } else if (endpointName.equals(key.endpointName)) {
+ isApplicationMatch = true;
+ }
+ return isApplicationMatch && isEntry == key.isEntry
+ && isExit == key.isExit;
+ }
+
+ @Override public int hashCode() {
+ int result = serviceId;
+ result = 31 * result + endpointName.hashCode();
+ return result;
+ }
+
+ boolean isEntry() {
+ return isEntry;
+ }
+
+ boolean isExit() {
+ return isExit;
+ }
+
+ DetectPoint getSpanType() {
+ if (isEntry) {
+ return DetectPoint.server;
+ } else if (isExit) {
+ return DetectPoint.client;
+ } else {
+ return DetectPoint.UNRECOGNIZED;
+ }
+ }
+ }
+}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/NetworkAddressDictionary.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/NetworkAddressDictionary.java
index 208ba17..2e9e2aa 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/NetworkAddressDictionary.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/NetworkAddressDictionary.java
@@ -23,9 +23,13 @@ import io.netty.util.internal.ConcurrentSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import org.apache.skywalking.apm.network.common.KeyIntValuePair;
import org.apache.skywalking.apm.network.language.agent.*;
+import org.apache.skywalking.apm.network.register.v2.NetAddressMapping;
+import org.apache.skywalking.apm.network.register.v2.NetAddresses;
+import org.apache.skywalking.apm.network.register.v2.RegisterGrpc;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Dictionary.APPLICATION_CODE_BUFFER_SIZE;
+import static org.apache.skywalking.apm.agent.core.conf.Config.Dictionary.SERVICE_CODE_BUFFER_SIZE;
/**
* Map of network address id to network literal address, which is from the collector side.
@@ -35,28 +39,28 @@ import static org.apache.skywalking.apm.agent.core.conf.Config.Dictionary.APPLIC
public enum NetworkAddressDictionary {
INSTANCE;
private Map<String, Integer> applicationDictionary = new ConcurrentHashMap<String, Integer>();
- private Set<String> unRegisterApplications = new ConcurrentSet<String>();
+ private Set<String> unRegisterServices = new ConcurrentSet<String>();
public PossibleFound find(String networkAddress) {
Integer applicationId = applicationDictionary.get(networkAddress);
if (applicationId != null) {
return new Found(applicationId);
} else {
- if (applicationDictionary.size() + unRegisterApplications.size() < APPLICATION_CODE_BUFFER_SIZE) {
- unRegisterApplications.add(networkAddress);
+ if (applicationDictionary.size() + unRegisterServices.size() < SERVICE_CODE_BUFFER_SIZE) {
+ unRegisterServices.add(networkAddress);
}
return new NotFound();
}
}
public void syncRemoteDictionary(
- NetworkAddressRegisterServiceGrpc.NetworkAddressRegisterServiceBlockingStub networkAddressRegisterServiceBlockingStub) {
- if (unRegisterApplications.size() > 0) {
- NetworkAddressMappings networkAddressMappings = networkAddressRegisterServiceBlockingStub.batchRegister(
- NetworkAddresses.newBuilder().addAllAddresses(unRegisterApplications).build());
+ RegisterGrpc.RegisterBlockingStub networkAddressRegisterServiceBlockingStub) {
+ if (unRegisterServices.size() > 0) {
+ NetAddressMapping networkAddressMappings = networkAddressRegisterServiceBlockingStub.doNetworkAddressRegister(
+ NetAddresses.newBuilder().addAllAddresses(unRegisterServices).build());
if (networkAddressMappings.getAddressIdsCount() > 0) {
- for (KeyWithIntegerValue keyWithIntegerValue : networkAddressMappings.getAddressIdsList()) {
- unRegisterApplications.remove(keyWithIntegerValue.getKey());
+ for (KeyIntValuePair keyWithIntegerValue : networkAddressMappings.getAddressIdsList()) {
+ unRegisterServices.remove(keyWithIntegerValue.getKey());
applicationDictionary.put(keyWithIntegerValue.getKey(), keyWithIntegerValue.getValue());
}
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/OperationNameDictionary.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/OperationNameDictionary.java
deleted file mode 100644
index 7f743b5..0000000
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/OperationNameDictionary.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.skywalking.apm.agent.core.dictionary;
-
-import io.netty.util.internal.ConcurrentSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.skywalking.apm.network.language.agent.*;
-
-import static org.apache.skywalking.apm.agent.core.conf.Config.Dictionary.OPERATION_NAME_BUFFER_SIZE;
-
-/**
- * @author wusheng
- */
-public enum OperationNameDictionary {
- INSTANCE;
- private Map<OperationNameKey, Integer> operationNameDictionary = new ConcurrentHashMap<OperationNameKey, Integer>();
- private Set<OperationNameKey> unRegisterOperationNames = new ConcurrentSet<OperationNameKey>();
-
- public PossibleFound findOrPrepare4Register(int applicationId, String operationName,
- boolean isEntry, boolean isExit) {
- return find0(applicationId, operationName, isEntry, isExit, true);
- }
-
- public PossibleFound findOnly(int applicationId, String operationName) {
- return find0(applicationId, operationName, false, false, false);
- }
-
- private PossibleFound find0(int applicationId, String operationName,
- boolean isEntry, boolean isExit, boolean registerWhenNotFound) {
- if (operationName == null || operationName.length() == 0) {
- return new NotFound();
- }
- OperationNameKey key = new OperationNameKey(applicationId, operationName, isEntry, isExit);
- Integer operationId = operationNameDictionary.get(key);
- if (operationId != null) {
- return new Found(operationId);
- } else {
- if (registerWhenNotFound &&
- operationNameDictionary.size() + unRegisterOperationNames.size() < OPERATION_NAME_BUFFER_SIZE) {
- unRegisterOperationNames.add(key);
- }
- return new NotFound();
- }
- }
-
- public void syncRemoteDictionary(
- ServiceNameDiscoveryServiceGrpc.ServiceNameDiscoveryServiceBlockingStub serviceNameDiscoveryServiceBlockingStub) {
- if (unRegisterOperationNames.size() > 0) {
- ServiceNameCollection.Builder builder = ServiceNameCollection.newBuilder();
- for (OperationNameKey operationNameKey : unRegisterOperationNames) {
- ServiceNameElement serviceNameElement = ServiceNameElement.newBuilder()
- .setApplicationId(operationNameKey.getApplicationId())
- .setServiceName(operationNameKey.getOperationName())
- .setSrcSpanType(operationNameKey.getSpanType())
- .build();
- builder.addElements(serviceNameElement);
- }
- ServiceNameMappingCollection serviceNameMappingCollection = serviceNameDiscoveryServiceBlockingStub.discovery(builder.build());
- if (serviceNameMappingCollection.getElementsCount() > 0) {
- for (ServiceNameMappingElement serviceNameMappingElement : serviceNameMappingCollection.getElementsList()) {
- ServiceNameElement element = serviceNameMappingElement.getElement();
- OperationNameKey key = new OperationNameKey(
- element.getApplicationId(),
- element.getServiceName(),
- SpanType.Entry.equals(element.getSrcSpanType()),
- SpanType.Exit.equals(element.getSrcSpanType()));
- unRegisterOperationNames.remove(key);
- operationNameDictionary.put(key, serviceNameMappingElement.getServiceId());
- }
- }
- }
- }
-
- private class OperationNameKey {
- private int applicationId;
- private String operationName;
- private boolean isEntry;
- private boolean isExit;
-
- public OperationNameKey(int applicationId, String operationName, boolean isEntry, boolean isExit) {
- this.applicationId = applicationId;
- this.operationName = operationName;
- this.isEntry = isEntry;
- this.isExit = isExit;
- }
-
- public int getApplicationId() {
- return applicationId;
- }
-
- public String getOperationName() {
- return operationName;
- }
-
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- OperationNameKey key = (OperationNameKey)o;
-
- boolean isApplicationMatch = false;
- if (applicationId == key.applicationId) {
- isApplicationMatch = true;
- } else if (operationName.equals(key.operationName)) {
- isApplicationMatch = true;
- }
- return isApplicationMatch && isEntry == key.isEntry
- && isExit == key.isExit;
- }
-
- @Override public int hashCode() {
- int result = applicationId;
- result = 31 * result + operationName.hashCode();
- return result;
- }
-
- boolean isEntry() {
- return isEntry;
- }
-
- boolean isExit() {
- return isExit;
- }
-
- SpanType getSpanType() {
- if (isEntry) {
- return SpanType.Entry;
- } else if (isExit) {
- return SpanType.Exit;
- } else {
- return SpanType.Local;
- }
- }
- }
-}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java
index 37b9296..d5f1032 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java
@@ -19,6 +19,11 @@
package org.apache.skywalking.apm.agent.core.jvm;
import io.grpc.Channel;
+import java.util.LinkedList;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
import org.apache.skywalking.apm.agent.core.boot.BootService;
import org.apache.skywalking.apm.agent.core.boot.DefaultImplementor;
import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory;
@@ -35,19 +40,14 @@ import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.agent.core.remote.GRPCChannelListener;
import org.apache.skywalking.apm.agent.core.remote.GRPCChannelManager;
import org.apache.skywalking.apm.agent.core.remote.GRPCChannelStatus;
-import org.apache.skywalking.apm.network.language.agent.*;
+import org.apache.skywalking.apm.network.language.agent.JVMMetric;
+import org.apache.skywalking.apm.network.language.agent.v2.JVMMetricCollection;
+import org.apache.skywalking.apm.network.language.agent.v2.JVMMetricReportServiceGrpc;
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
-import java.util.LinkedList;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
/**
- * The <code>JVMService</code> represents a timer,
- * which collectors JVM cpu, memory, memorypool and gc info,
- * and send the collected info to Collector through the channel provided by {@link GRPCChannelManager}
+ * The <code>JVMService</code> represents a timer, which collectors JVM cpu, memory, memorypool and gc info, and send
+ * the collected info to Collector through the channel provided by {@link GRPCChannelManager}
*
* @author wusheng
*/
@@ -98,9 +98,9 @@ public class JVMService implements BootService, Runnable {
@Override
public void run() {
- if (RemoteDownstreamConfig.Agent.APPLICATION_ID != DictionaryUtil.nullValue()
- && RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID != DictionaryUtil.nullValue()
- ) {
+ if (RemoteDownstreamConfig.Agent.SERVICE_ID != DictionaryUtil.nullValue()
+ && RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID != DictionaryUtil.nullValue()
+ ) {
long currentTimeMillis = System.currentTimeMillis();
try {
JVMMetric.Builder jvmBuilder = JVMMetric.newBuilder();
@@ -123,21 +123,21 @@ public class JVMService implements BootService, Runnable {
private class Sender implements Runnable, GRPCChannelListener {
private volatile GRPCChannelStatus status = GRPCChannelStatus.DISCONNECT;
- private volatile JVMMetricsServiceGrpc.JVMMetricsServiceBlockingStub stub = null;
+ private volatile JVMMetricReportServiceGrpc.JVMMetricReportServiceBlockingStub stub = null;
@Override
public void run() {
- if (RemoteDownstreamConfig.Agent.APPLICATION_ID != DictionaryUtil.nullValue()
- && RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID != DictionaryUtil.nullValue()
- ) {
+ if (RemoteDownstreamConfig.Agent.SERVICE_ID != DictionaryUtil.nullValue()
+ && RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID != DictionaryUtil.nullValue()
+ ) {
if (status == GRPCChannelStatus.CONNECTED) {
try {
- JVMMetrics.Builder builder = JVMMetrics.newBuilder();
+ JVMMetricCollection.Builder builder = JVMMetricCollection.newBuilder();
LinkedList<JVMMetric> buffer = new LinkedList<JVMMetric>();
queue.drainTo(buffer);
if (buffer.size() > 0) {
builder.addAllMetrics(buffer);
- builder.setApplicationInstanceId(RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID);
+ builder.setServiceInstanceId(RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID);
stub.collect(builder.build());
}
} catch (Throwable t) {
@@ -151,7 +151,7 @@ public class JVMService implements BootService, Runnable {
public void statusChanged(GRPCChannelStatus status) {
if (GRPCChannelStatus.CONNECTED.equals(status)) {
Channel channel = ServiceManager.INSTANCE.findService(GRPCChannelManager.class).getChannel();
- stub = JVMMetricsServiceGrpc.newBlockingStub(channel);
+ stub = JVMMetricReportServiceGrpc.newBlockingStub(channel);
}
this.status = status;
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/ServiceAndEndpointRegisterClient.java
similarity index 77%
rename from apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java
rename to apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/ServiceAndEndpointRegisterClient.java
index de5c17d..1c620e1 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/ServiceAndEndpointRegisterClient.java
@@ -31,7 +31,7 @@ import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.conf.RemoteDownstreamConfig;
import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil;
import org.apache.skywalking.apm.agent.core.dictionary.NetworkAddressDictionary;
-import org.apache.skywalking.apm.agent.core.dictionary.OperationNameDictionary;
+import org.apache.skywalking.apm.agent.core.dictionary.EndpointNameDictionary;
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.agent.core.os.OSUtil;
@@ -42,23 +42,21 @@ import org.apache.skywalking.apm.network.language.agent.ApplicationInstanceMappi
import org.apache.skywalking.apm.network.language.agent.ApplicationMapping;
import org.apache.skywalking.apm.network.language.agent.ApplicationRegisterServiceGrpc;
import org.apache.skywalking.apm.network.language.agent.InstanceDiscoveryServiceGrpc;
-import org.apache.skywalking.apm.network.language.agent.NetworkAddressRegisterServiceGrpc;
-import org.apache.skywalking.apm.network.language.agent.ServiceNameDiscoveryServiceGrpc;
+import org.apache.skywalking.apm.network.register.v2.RegisterGrpc;
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
/**
* @author wusheng
*/
@DefaultImplementor
-public class AppAndServiceRegisterClient implements BootService, Runnable, GRPCChannelListener {
- private static final ILog logger = LogManager.getLogger(AppAndServiceRegisterClient.class);
+public class ServiceAndEndpointRegisterClient implements BootService, Runnable, GRPCChannelListener {
+ private static final ILog logger = LogManager.getLogger(ServiceAndEndpointRegisterClient.class);
private static final String PROCESS_UUID = UUID.randomUUID().toString().replaceAll("-", "");
private volatile GRPCChannelStatus status = GRPCChannelStatus.DISCONNECT;
private volatile ApplicationRegisterServiceGrpc.ApplicationRegisterServiceBlockingStub applicationRegisterServiceBlockingStub;
private volatile InstanceDiscoveryServiceGrpc.InstanceDiscoveryServiceBlockingStub instanceDiscoveryServiceBlockingStub;
- private volatile ServiceNameDiscoveryServiceGrpc.ServiceNameDiscoveryServiceBlockingStub serviceNameDiscoveryServiceBlockingStub;
- private volatile NetworkAddressRegisterServiceGrpc.NetworkAddressRegisterServiceBlockingStub networkAddressRegisterServiceBlockingStub;
+ private volatile RegisterGrpc.RegisterBlockingStub registerBlockingStub;
private volatile ScheduledFuture<?> applicationRegisterFuture;
@Override
@@ -67,12 +65,11 @@ public class AppAndServiceRegisterClient implements BootService, Runnable, GRPCC
Channel channel = ServiceManager.INSTANCE.findService(GRPCChannelManager.class).getChannel();
applicationRegisterServiceBlockingStub = ApplicationRegisterServiceGrpc.newBlockingStub(channel);
instanceDiscoveryServiceBlockingStub = InstanceDiscoveryServiceGrpc.newBlockingStub(channel);
- serviceNameDiscoveryServiceBlockingStub = ServiceNameDiscoveryServiceGrpc.newBlockingStub(channel);
- networkAddressRegisterServiceBlockingStub = NetworkAddressRegisterServiceGrpc.newBlockingStub(channel);
+ registerBlockingStub = RegisterGrpc.newBlockingStub(channel);
} else {
applicationRegisterServiceBlockingStub = null;
instanceDiscoveryServiceBlockingStub = null;
- serviceNameDiscoveryServiceBlockingStub = null;
+ registerBlockingStub = null;
}
this.status = status;
}
@@ -85,7 +82,7 @@ public class AppAndServiceRegisterClient implements BootService, Runnable, GRPCC
@Override
public void boot() throws Throwable {
applicationRegisterFuture = Executors
- .newSingleThreadScheduledExecutor(new DefaultNamedThreadFactory("AppAndServiceRegisterClient"))
+ .newSingleThreadScheduledExecutor(new DefaultNamedThreadFactory("ServiceAndEndpointRegisterClient"))
.scheduleAtFixedRate(new RunnableWithExceptionProtection(this, new RunnableWithExceptionProtection.CallbackWhenException() {
@Override
public void handle(Throwable t) {
@@ -105,47 +102,47 @@ public class AppAndServiceRegisterClient implements BootService, Runnable, GRPCC
@Override
public void run() {
- logger.debug("AppAndServiceRegisterClient running, status:{}.", status);
+ logger.debug("ServiceAndEndpointRegisterClient running, status:{}.", status);
boolean shouldTry = true;
while (GRPCChannelStatus.CONNECTED.equals(status) && shouldTry) {
shouldTry = false;
try {
- if (RemoteDownstreamConfig.Agent.APPLICATION_ID == DictionaryUtil.nullValue()) {
+ if (RemoteDownstreamConfig.Agent.SERVICE_ID == DictionaryUtil.nullValue()) {
if (applicationRegisterServiceBlockingStub != null) {
ApplicationMapping applicationMapping = applicationRegisterServiceBlockingStub.applicationCodeRegister(
Application.newBuilder().setApplicationCode(Config.Agent.APPLICATION_CODE).build());
if (applicationMapping != null) {
- RemoteDownstreamConfig.Agent.APPLICATION_ID = applicationMapping.getApplication().getValue();
+ RemoteDownstreamConfig.Agent.SERVICE_ID = applicationMapping.getApplication().getValue();
shouldTry = true;
}
}
} else {
if (instanceDiscoveryServiceBlockingStub != null) {
- if (RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID == DictionaryUtil.nullValue()) {
+ if (RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID == DictionaryUtil.nullValue()) {
ApplicationInstanceMapping instanceMapping = instanceDiscoveryServiceBlockingStub.registerInstance(ApplicationInstance.newBuilder()
- .setApplicationId(RemoteDownstreamConfig.Agent.APPLICATION_ID)
+ .setApplicationId(RemoteDownstreamConfig.Agent.SERVICE_ID)
.setAgentUUID(PROCESS_UUID)
.setRegisterTime(System.currentTimeMillis())
.setOsinfo(OSUtil.buildOSInfo())
.build());
if (instanceMapping.getApplicationInstanceId() != DictionaryUtil.nullValue()) {
- RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID
+ RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID
= instanceMapping.getApplicationInstanceId();
}
} else {
instanceDiscoveryServiceBlockingStub.heartbeat(ApplicationInstanceHeartbeat.newBuilder()
- .setApplicationInstanceId(RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID)
+ .setApplicationInstanceId(RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID)
.setHeartbeatTime(System.currentTimeMillis())
.build());
- NetworkAddressDictionary.INSTANCE.syncRemoteDictionary(networkAddressRegisterServiceBlockingStub);
- OperationNameDictionary.INSTANCE.syncRemoteDictionary(serviceNameDiscoveryServiceBlockingStub);
+ NetworkAddressDictionary.INSTANCE.syncRemoteDictionary(registerBlockingStub);
+ EndpointNameDictionary.INSTANCE.syncRemoteDictionary(registerBlockingStub);
}
}
}
} catch (Throwable t) {
- logger.error(t, "AppAndServiceRegisterClient execute fail.");
+ logger.error(t, "ServiceAndEndpointRegisterClient execute fail.");
ServiceManager.INSTANCE.findService(GRPCChannelManager.class).reportError(t);
}
}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/TraceSegmentServiceClient.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/TraceSegmentServiceClient.java
index 697d747..8524142 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/TraceSegmentServiceClient.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/TraceSegmentServiceClient.java
@@ -33,7 +33,9 @@ import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.commons.datacarrier.DataCarrier;
import org.apache.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
import org.apache.skywalking.apm.commons.datacarrier.consumer.IConsumer;
+import org.apache.skywalking.apm.network.common.Commands;
import org.apache.skywalking.apm.network.language.agent.*;
+import org.apache.skywalking.apm.network.language.agent.v2.TraceSegmentReportServiceGrpc;
import static org.apache.skywalking.apm.agent.core.conf.Config.Buffer.BUFFER_SIZE;
import static org.apache.skywalking.apm.agent.core.conf.Config.Buffer.CHANNEL_SIZE;
@@ -51,7 +53,7 @@ public class TraceSegmentServiceClient implements BootService, IConsumer<TraceSe
private long segmentUplinkedCounter;
private long segmentAbandonedCounter;
private volatile DataCarrier<TraceSegment> carrier;
- private volatile TraceSegmentServiceGrpc.TraceSegmentServiceStub serviceStub;
+ private volatile TraceSegmentReportServiceGrpc.TraceSegmentReportServiceStub serviceStub;
private volatile GRPCChannelStatus status = GRPCChannelStatus.DISCONNECT;
@Override
@@ -88,9 +90,9 @@ public class TraceSegmentServiceClient implements BootService, IConsumer<TraceSe
public void consume(List<TraceSegment> data) {
if (CONNECTED.equals(status)) {
final GRPCStreamServiceStatus status = new GRPCStreamServiceStatus(false);
- StreamObserver<UpstreamSegment> upstreamSegmentStreamObserver = serviceStub.collect(new StreamObserver<Downstream>() {
+ StreamObserver<UpstreamSegment> upstreamSegmentStreamObserver = serviceStub.collect(new StreamObserver<Commands>() {
@Override
- public void onNext(Downstream downstream) {
+ public void onNext(Commands commands) {
}
@@ -169,7 +171,7 @@ public class TraceSegmentServiceClient implements BootService, IConsumer<TraceSe
public void statusChanged(GRPCChannelStatus status) {
if (CONNECTED.equals(status)) {
Channel channel = ServiceManager.INSTANCE.findService(GRPCChannelManager.class).getChannel();
- serviceStub = TraceSegmentServiceGrpc.newStub(channel);
+ serviceStub = TraceSegmentReportServiceGrpc.newStub(channel);
}
this.status = status;
}
diff --git a/apm-sniffer/apm-agent-core/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.BootService b/apm-sniffer/apm-agent-core/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.BootService
index 9beec08..273d1dd 100644
--- a/apm-sniffer/apm-agent-core/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.BootService
+++ b/apm-sniffer/apm-agent-core/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.BootService
@@ -21,5 +21,5 @@ org.apache.skywalking.apm.agent.core.context.ContextManager
org.apache.skywalking.apm.agent.core.sampling.SamplingService
org.apache.skywalking.apm.agent.core.remote.GRPCChannelManager
org.apache.skywalking.apm.agent.core.jvm.JVMService
-org.apache.skywalking.apm.agent.core.remote.AppAndServiceRegisterClient
+org.apache.skywalking.apm.agent.core.remote.ServiceAndEndpointRegisterClient
org.apache.skywalking.apm.agent.core.context.ContextManagerExtendService
diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextManagerTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextManagerTest.java
index 9da466a..7ff58d4 100644
--- a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextManagerTest.java
+++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextManagerTest.java
@@ -68,8 +68,8 @@ public class ContextManagerTest {
@Before
public void setUp() throws Exception {
- RemoteDownstreamConfig.Agent.APPLICATION_ID = 1;
- RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID = 1;
+ RemoteDownstreamConfig.Agent.SERVICE_ID = 1;
+ RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID = 1;
}
@AfterClass
@@ -221,8 +221,8 @@ public class ContextManagerTest {
@After
public void tearDown() throws Exception {
- RemoteDownstreamConfig.Agent.APPLICATION_ID = DictionaryUtil.nullValue();
- RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID = DictionaryUtil.nullValue();
+ RemoteDownstreamConfig.Agent.SERVICE_ID = DictionaryUtil.nullValue();
+ RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID = DictionaryUtil.nullValue();
}
@Test
diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/IgnoredTracerContextTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/IgnoredTracerContextTest.java
index fb195b0..67e4123 100644
--- a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/IgnoredTracerContextTest.java
+++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/IgnoredTracerContextTest.java
@@ -48,8 +48,8 @@ public class IgnoredTracerContextTest {
@Before
public void setUp() throws Exception {
- RemoteDownstreamConfig.Agent.APPLICATION_ID = 1;
- RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID = 1;
+ RemoteDownstreamConfig.Agent.SERVICE_ID = 1;
+ RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID = 1;
}
@AfterClass
diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/remote/TraceSegmentServiceClientTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/remote/TraceSegmentServiceClientTest.java
index 56cba0f..bb71788 100644
--- a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/remote/TraceSegmentServiceClientTest.java
+++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/remote/TraceSegmentServiceClientTest.java
@@ -90,8 +90,8 @@ public class TraceSegmentServiceClientTest {
@BeforeClass
public static void setUpBeforeClass() {
- RemoteDownstreamConfig.Agent.APPLICATION_ID = 1;
- RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID = 1;
+ RemoteDownstreamConfig.Agent.SERVICE_ID = 1;
+ RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID = 1;
}
@AfterClass
diff --git a/apm-sniffer/apm-test-tools/src/main/java/org/apache/skywalking/apm/agent/test/tools/AgentServiceRule.java b/apm-sniffer/apm-test-tools/src/main/java/org/apache/skywalking/apm/agent/test/tools/AgentServiceRule.java
index cf5007f..30c21a9 100644
--- a/apm-sniffer/apm-test-tools/src/main/java/org/apache/skywalking/apm/agent/test/tools/AgentServiceRule.java
+++ b/apm-sniffer/apm-test-tools/src/main/java/org/apache/skywalking/apm/agent/test/tools/AgentServiceRule.java
@@ -53,7 +53,7 @@ public class AgentServiceRule extends ExternalResource {
AgentClassLoader.initDefaultLoader();
Config.Logging.LEVEL = LogLevel.OFF;
ServiceManager.INSTANCE.boot();
- RemoteDownstreamConfig.Agent.APPLICATION_ID = 1;
- RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID = 1;
+ RemoteDownstreamConfig.Agent.SERVICE_ID = 1;
+ RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID = 1;
}
}
diff --git a/docs/en/guides/Java-Plugin-Development-Guide.md b/docs/en/guides/Java-Plugin-Development-Guide.md
index 37c1472..7de1317 100644
--- a/docs/en/guides/Java-Plugin-Development-Guide.md
+++ b/docs/en/guides/Java-Plugin-Development-Guide.md
@@ -76,19 +76,19 @@ ContextManager provides all major and primary APIs.
1. Create EntrySpan
```java
-public static AbstractSpan createEntrySpan(String operationName, ContextCarrier carrier)
+public static AbstractSpan createEntrySpan(String endpointName, ContextCarrier carrier)
```
Create EntrySpan by operation name(e.g. service name, uri) and **ContextCarrier**.
2. Create LocalSpan
```java
-public static AbstractSpan createLocalSpan(String operationName)
+public static AbstractSpan createLocalSpan(String endpointName)
```
Create LocalSpan by operation name(e.g. full method signature)
3. Create ExitSpan
```java
-public static AbstractSpan createExitSpan(String operationName, ContextCarrier carrier, String remotePeer)
+public static AbstractSpan createExitSpan(String endpointName, ContextCarrier carrier, String remotePeer)
```
Create ExitSpan by operation name(e.g. service name, uri) and new **ContextCarrier** and peer address
(e.g. ip+port, hostname+port)
@@ -145,7 +145,7 @@ Create ExitSpan by operation name(e.g. service name, uri) and new **ContextCarri
*
* @return this Span instance, for chaining
*/
- AbstractSpan setOperationName(String operationName);
+ AbstractSpan setOperationName(String endpointName);
```
Besides set operation name, tags and logs, two attributes shoule be set, which are component and layer,
especially for EntrySpan and ExitSpan
diff --git a/docs/en/protocols/Trace-Data-Protocol.md b/docs/en/protocols/Trace-Data-Protocol.md
index 870acd1..7c2eaac 100644
--- a/docs/en/protocols/Trace-Data-Protocol.md
+++ b/docs/en/protocols/Trace-Data-Protocol.md
@@ -20,7 +20,7 @@ v2.0
- UniqueId represents segmentId and globalTraceId. It have 3 parts(Longs), 1) applicationInstanceId, 2) ThreadId, 3) Timestamp + 10000 + seq(seq is in [0, 100000) )
- Span data please refs to [Plugin Development Guide](../guides/Java-Plugin-Development-Guide.md)
- Id and name both exist, please use id if possible.
- - operationNameId/operationName
+ - operationNameId/endpointName
- networkAddress/networkAddressId
- entryServiceName/entryServiceId
- parentServiceName/parentServiceId
@@ -36,7 +36,7 @@ Input:
"gt": [[230150, 185809, 24040000]],
"sg": { //TraceSegmentObject
"ts": [137150, 185809, 48780000],
- "ai": 2, //applicationId
+ "ai": 2, //serviceId
"ii": 3, //applicationInstanceId
"ss": [ //SpanObject
{
@@ -49,7 +49,7 @@ Input:
"ci": 3, //componentId
"cn": "", //component
"oi": 0, //operationNameId
- "on": "org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()", //operationName
+ "on": "org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()", //endpointName
"pi": 0, //peerId
"pn": "", //peer
"ie": false, //isError
@@ -140,7 +140,7 @@ HTTP format http://ip:port/instance/register(default: localhost:12800)
Input:
```
{
- ai: x, #applicationId
+ ai: x, #serviceId
au: "", #agentUUID
rt: x, #registerTime
oi: "", #osinfo
@@ -150,7 +150,7 @@ Input:
Output:
```
{
- ai: x, #applicationId
+ ai: x, #serviceId
ii: x, #applicationInstanceId
}
```
@@ -185,7 +185,7 @@ HTTP format http://ip:port/servicename/discovery(default: localhost:12800)
Input:
```
{
- ai: x, #applicationId
+ ai: x, #serviceId
sn: "", #serviceName
st: x, #srcSpanType
}
@@ -196,7 +196,7 @@ Output:
{
si: x, #osinfo
el: { #element
- ai: x, #applicationId
+ ai: x, #serviceId
sn: "", #serviceName
st: x, #srcSpanType
}