1. Remove the “apm-trace” module, isolate the trace structure between agent and collector for considering performance.
2. Change the head name. 3. Provide potienal mechanism for ignore trace with certain suffix.
This commit is contained in:
parent
b8e1bd32c9
commit
f0e626ff2c
|
|
@ -5,7 +5,7 @@ import org.apache.log4j.spi.LoggingEvent;
|
|||
|
||||
/**
|
||||
* Default implementation outputs "TID: N/A".
|
||||
* But, if in sky-walking agent active mode, output will become the real TraceId.
|
||||
* But, if in sky-walking agent active mode, output will become the real ids.
|
||||
* <p>
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,10 +18,5 @@
|
|||
<artifactId>apm-collector-cluster</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-trace</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ import org.skywalking.apm.collector.worker.Const;
|
|||
import org.skywalking.apm.collector.worker.segment.SegmentIndex;
|
||||
import org.skywalking.apm.collector.worker.segment.mock.SegmentMock;
|
||||
import org.skywalking.apm.collector.worker.storage.GetResponseFromEs;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>apm-commons</artifactId>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<version>3.1-2017</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>apm-trace</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>kr.motd.maven</groupId>
|
||||
<artifactId>os-maven-plugin</artifactId>
|
||||
<version>1.5.0.Final</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.xolstice.maven.plugins</groupId>
|
||||
<artifactId>protobuf-maven-plugin</artifactId>
|
||||
<version>0.5.0</version>
|
||||
<configuration>
|
||||
<protocArtifact>com.google.protobuf:protoc:3.0.0:exe:${os.detected.classifier}
|
||||
</protocArtifact>
|
||||
<pluginId>grpc-java</pluginId>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.2:exe:${os.detected.classifier}
|
||||
</pluginArtifact>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>compile-custom</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class BooleanTagReader {
|
||||
public static Boolean get(Span span, BooleanTag tag) {
|
||||
List<BooleanTagItem> tagsWithBoolList = null;
|
||||
try {
|
||||
Field tagsWithBool = Span.class.getDeclaredField("tagsWithBool");
|
||||
tagsWithBool.setAccessible(true);
|
||||
tagsWithBoolList = (List<BooleanTagItem>)tagsWithBool.get(span);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (tagsWithBoolList != null) {
|
||||
for (BooleanTagItem item : tagsWithBoolList) {
|
||||
if (tag.key().equals(item.getKey())) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return tag.defaultValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class IntTagReader {
|
||||
public static Integer get(Span span, IntTag tag) {
|
||||
List<IntTagItem> tagsWithIntList = null;
|
||||
try {
|
||||
Field tagsWithInt = Span.class.getDeclaredField("tagsWithInt");
|
||||
tagsWithInt.setAccessible(true);
|
||||
tagsWithIntList = (List<IntTagItem>)tagsWithInt.get(span);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (tagsWithIntList != null) {
|
||||
for (IntTagItem item : tagsWithIntList) {
|
||||
if (tag.key().equals(item.getKey())) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class StringTagReader {
|
||||
public static String get(Span span, StringTag tag) {
|
||||
List<StringTagItem> tagsWithStrList = null;
|
||||
try {
|
||||
Field tagsWithStr = Span.class.getDeclaredField("tagsWithStr");
|
||||
tagsWithStr.setAccessible(true);
|
||||
tagsWithStrList = (List<StringTagItem>)tagsWithStr.get(span);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (StringTagItem item : tagsWithStrList) {
|
||||
if (tag.key().equals(item.getKey())) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class TagsTest {
|
||||
@Test
|
||||
public void testLayer() {
|
||||
Span span = new Span(1, "/test");
|
||||
Tags.SPAN_LAYER.asDB(span);
|
||||
Assert.assertEquals("db", StringTagReader.get(span, Tags.SPAN_LAYER.SPAN_LAYER_TAG));
|
||||
|
||||
span = new Span(1, "/test");
|
||||
Tags.SPAN_LAYER.asRPCFramework(span);
|
||||
Assert.assertEquals("rpc", StringTagReader.get(span, Tags.SPAN_LAYER.SPAN_LAYER_TAG));
|
||||
|
||||
span = new Span(1, "/test");
|
||||
Tags.SPAN_LAYER.asHttp(span);
|
||||
Assert.assertEquals("http", StringTagReader.get(span, Tags.SPAN_LAYER.SPAN_LAYER_TAG));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBooleanTag() {
|
||||
BooleanTag tag = new BooleanTag("test.key", false);
|
||||
Span span = new Span(1, "/test");
|
||||
Assert.assertFalse(BooleanTagReader.get(span, tag));
|
||||
|
||||
span = new Span(1, "/test");
|
||||
tag.set(span, true);
|
||||
Assert.assertTrue(BooleanTagReader.get(span, tag));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntTag() {
|
||||
IntTag tag = new IntTag("test.key");
|
||||
Span span = new Span(1, "/test");
|
||||
Assert.assertNull(IntTagReader.get(span, tag));
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>apm-trace</module>
|
||||
<module>apm-util</module>
|
||||
<module>apm-logging-api</module>
|
||||
<module>apm-logging-log4j2</module>
|
||||
|
|
|
|||
|
|
@ -29,11 +29,6 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-trace</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-logging-api</artifactId>
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.trace.SegmentsMessage;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.queue.TraceSegmentProcessQueue;
|
||||
import org.skywalking.apm.logging.ILog;
|
||||
import org.skywalking.apm.logging.LogManager;
|
||||
import org.skywalking.apm.trace.SegmentsMessage;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package org.skywalking.apm.agent.core.client;
|
||||
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.queue.TraceSegmentProcessQueue;
|
||||
import org.skywalking.apm.agent.core.boot.StatusBootService;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* The <code>CollectorClientService</code> is responsible for start {@link CollectorClient}.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.skywalking.apm.agent.core.conf;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.logging.LogLevel;
|
||||
import org.skywalking.apm.agent.core.logging.WriterFactory;
|
||||
|
||||
|
|
@ -20,11 +21,16 @@ public class Config {
|
|||
public static String APPLICATION_CODE = "";
|
||||
|
||||
/**
|
||||
* One, means sampling OFF.
|
||||
* Greater than one, select one trace in every N traces.
|
||||
* Zero and negative number are illegal.
|
||||
* Negative or zero means off, by default.
|
||||
* {@link #SAMPLE_N_PER_10_SECS} means sampling N {@link TraceSegment} in 10 seconds tops.
|
||||
*/
|
||||
public static int SAMPLING_CYCLE = 1;
|
||||
public static int SAMPLE_N_PER_10_SECS = -1;
|
||||
|
||||
/**
|
||||
* If the operation name of the first span is included in this set,
|
||||
* this segment should be ignored.
|
||||
*/
|
||||
public static String IGNORE_SUFFIX = ".jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html";
|
||||
}
|
||||
|
||||
public static class Collector {
|
||||
|
|
@ -103,12 +109,12 @@ public class Config {
|
|||
public static boolean TRACE_PARAM = false;
|
||||
}
|
||||
|
||||
public static class Http {
|
||||
public static class Propagation {
|
||||
|
||||
/**
|
||||
* The header name of context data.
|
||||
* The header name of cross process propagation data.
|
||||
*/
|
||||
public static String HEADER_NAME_OF_CONTEXT_DATA = "SWTraceContext";
|
||||
public static String HEADER_NAME = "sw3";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
|
||||
/**
|
||||
* The <code>AbstractTracerContext</code> represents the tracer context manager.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public interface AbstractTracerContext {
|
||||
void inject(ContextCarrier carrier);
|
||||
|
||||
void extract(ContextCarrier carrier);
|
||||
|
||||
String getGlobalTraceId();
|
||||
|
||||
Span createSpan(String operationName, boolean isLeaf);
|
||||
|
||||
Span createSpan(String operationName, long startTime, boolean isLeaf);
|
||||
|
||||
Span activeSpan();
|
||||
|
||||
void stopSpan(Span span);
|
||||
|
||||
void stopSpan(Span span, Long endTime);
|
||||
}
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceId.DistributedTraceId;
|
||||
import org.skywalking.apm.trace.TraceId.PropagatedTraceId;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.ids.DistributedTraceId;
|
||||
import org.skywalking.apm.agent.core.context.ids.PropagatedTraceId;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
|
||||
/**
|
||||
* {@link ContextCarrier} is a data carrier of {@link TracerContext}.
|
||||
|
|
@ -34,7 +32,8 @@ public class ContextCarrier implements Serializable {
|
|||
private String applicationCode;
|
||||
|
||||
/**
|
||||
* {@link Tags#PEER_HOST}
|
||||
* Either {@link Span#peerHost} + {@link Span#port} or {@link Span#peers},
|
||||
* depend on which one of them is valid.
|
||||
*/
|
||||
private String peerHost;
|
||||
|
||||
|
|
@ -43,11 +42,6 @@ public class ContextCarrier implements Serializable {
|
|||
*/
|
||||
private List<DistributedTraceId> distributedTraceIds;
|
||||
|
||||
/**
|
||||
* {@link TraceSegment#sampled}
|
||||
*/
|
||||
private boolean sampled;
|
||||
|
||||
/**
|
||||
* Serialize this {@link ContextCarrier} to a {@link String},
|
||||
* with '|' split.
|
||||
|
|
@ -60,8 +54,7 @@ public class ContextCarrier implements Serializable {
|
|||
this.getSpanId() + "",
|
||||
this.getApplicationCode(),
|
||||
this.getPeerHost(),
|
||||
this.serializeDistributedTraceIds(),
|
||||
this.isSampled() ? "1" : "0");
|
||||
this.serializeDistributedTraceIds());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,14 +65,13 @@ public class ContextCarrier implements Serializable {
|
|||
public ContextCarrier deserialize(String text) {
|
||||
if (text != null) {
|
||||
String[] parts = text.split("\\|", 6);
|
||||
if (parts.length == 6) {
|
||||
if (parts.length == 5) {
|
||||
try {
|
||||
setSpanId(Integer.parseInt(parts[1]));
|
||||
setTraceSegmentId(parts[0]);
|
||||
setApplicationCode(parts[2]);
|
||||
setPeerHost(parts[3]);
|
||||
setDistributedTraceIds(deserializeDistributedTraceIds(parts[4]));
|
||||
setSampled("1".equals(parts[5]));
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
|
|
@ -137,14 +129,6 @@ public class ContextCarrier implements Serializable {
|
|||
return distributedTraceIds;
|
||||
}
|
||||
|
||||
public boolean isSampled() {
|
||||
return sampled;
|
||||
}
|
||||
|
||||
public void setSampled(boolean sampled) {
|
||||
this.sampled = sampled;
|
||||
}
|
||||
|
||||
public void setDistributedTraceIds(List<DistributedTraceId> distributedTraceIds) {
|
||||
this.distributedTraceIds = distributedTraceIds;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,27 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
|
||||
import org.skywalking.apm.agent.core.boot.BootService;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* {@link TracerContext} controls the whole context of {@link TraceSegment}. Any {@link TraceSegment} relates to
|
||||
* single-thread, so this context use {@link ThreadLocal} to maintain the context, and make sure, since a {@link
|
||||
* TraceSegment} starts, all ChildOf spans are in the same context.
|
||||
* <p> What is 'ChildOf'? {@see
|
||||
* https://github.com/opentracing/specification/blob/master/specification.md#references-between-spans}
|
||||
* <p> Also, {@link
|
||||
* ContextManager} delegates to all {@link TracerContext}'s major methods: {@link TracerContext#createSpan(String,
|
||||
* boolean)}, {@link TracerContext#activeSpan()}, {@link TracerContext#stopSpan(Span)}
|
||||
* <p>
|
||||
* What is 'ChildOf'? {@see https://github.com/opentracing/specification/blob/master/specification.md#references-between-spans}
|
||||
* <p>
|
||||
* Also, {@link ContextManager} delegates to all {@link TracerContext}'s major methods: {@link
|
||||
* TracerContext#createSpan(String)}, {@link TracerContext#activeSpan()}, {@link TracerContext#stopSpan(Span)}
|
||||
* <p>
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class ContextManager implements TracerContextListener, BootService {
|
||||
private static ThreadLocal<TracerContext> CONTEXT = new ThreadLocal<TracerContext>();
|
||||
private static ThreadLocal<AbstractTracerContext> CONTEXT = new ThreadLocal<AbstractTracerContext>();
|
||||
|
||||
private static TracerContext get() {
|
||||
TracerContext segment = CONTEXT.get();
|
||||
private static AbstractTracerContext get() {
|
||||
AbstractTracerContext segment = CONTEXT.get();
|
||||
if (segment == null) {
|
||||
segment = new TracerContext();
|
||||
CONTEXT.set(segment);
|
||||
|
|
@ -46,7 +47,7 @@ public class ContextManager implements TracerContextListener, BootService {
|
|||
* @return the first global trace id if exist. Otherwise, "N/A".
|
||||
*/
|
||||
public static String getGlobalTraceId() {
|
||||
TracerContext segment = CONTEXT.get();
|
||||
AbstractTracerContext segment = CONTEXT.get();
|
||||
if (segment == null) {
|
||||
return "N/A";
|
||||
} else {
|
||||
|
|
@ -95,4 +96,15 @@ public class ContextManager implements TracerContextListener, BootService {
|
|||
public void afterFinished(TraceSegment traceSegment) {
|
||||
CONTEXT.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ContextSwitcher</code> gives the chance to switch {@link AbstractTracerContext} in {@link #CONTEXT}.
|
||||
*/
|
||||
enum ContextSwitcher {
|
||||
INSTANCE;
|
||||
|
||||
void toNew(AbstractTracerContext context) {
|
||||
CONTEXT.set(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@ package org.skywalking.apm.agent.core.context;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.sampling.SamplingService;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.context.trace.LeafSpan;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
|
||||
/**
|
||||
* {@link TracerContext} maintains the context.
|
||||
|
|
@ -15,7 +14,7 @@ import org.skywalking.apm.trace.TraceSegmentRef;
|
|||
* <p>
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public final class TracerContext {
|
||||
public final class TracerContext implements AbstractTracerContext {
|
||||
private TraceSegment segment;
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +33,6 @@ public final class TracerContext {
|
|||
*/
|
||||
TracerContext() {
|
||||
this.segment = new TraceSegment(Config.Agent.APPLICATION_CODE);
|
||||
ServiceManager.INSTANCE.findService(SamplingService.class).trySampling(this.segment);
|
||||
this.spanIdGenerator = 0;
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +102,7 @@ public final class TracerContext {
|
|||
/**
|
||||
* @return the current trace id.
|
||||
*/
|
||||
String getGlobalTraceId() {
|
||||
public String getGlobalTraceId() {
|
||||
return segment.getRelatedGlobalTraces().get(0).get();
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +152,6 @@ public final class TracerContext {
|
|||
carrier.setPeerHost(span.getPeers());
|
||||
}
|
||||
carrier.setDistributedTraceIds(this.segment.getRelatedGlobalTraces());
|
||||
carrier.setSampled(this.segment.isSampled());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -166,7 +163,6 @@ public final class TracerContext {
|
|||
public void extract(ContextCarrier carrier) {
|
||||
if (carrier.isValid()) {
|
||||
this.segment.ref(getRef(carrier));
|
||||
ServiceManager.INSTANCE.findService(SamplingService.class).setSampleWhenExtract(this.segment, carrier);
|
||||
this.segment.relatedGlobalTraces(carrier.getDistributedTraceIds());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* {@link TracerContextListener} is a status change listener of {@link TracerContext}.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package org.skywalking.apm.trace.TraceId;
|
||||
package org.skywalking.apm.agent.core.context.ids;
|
||||
|
||||
/**
|
||||
* The <code>DistributedTraceId</code> presents a distributed call chain.
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
package org.skywalking.apm.trace.TraceId;
|
||||
package org.skywalking.apm.agent.core.context.ids;
|
||||
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
package org.skywalking.apm.trace;
|
||||
|
||||
import org.skywalking.apm.util.MachineInfo;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
package org.skywalking.apm.agent.core.context.ids;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.skywalking.apm.util.MachineInfo;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
|
||||
public final class GlobalIdGenerator {
|
||||
private static final ThreadLocal<Integer> THREAD_ID_SEQUENCE = new ThreadLocal<Integer>() {
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
package org.skywalking.apm.trace.TraceId;
|
||||
|
||||
import org.skywalking.apm.trace.GlobalIdGenerator;
|
||||
package org.skywalking.apm.agent.core.context.ids;
|
||||
|
||||
/**
|
||||
* The <code>NewDistributedTraceId</code> is a {@link DistributedTraceId} with a new generated id.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.skywalking.apm.trace.TraceId;
|
||||
package org.skywalking.apm.agent.core.context.ids;
|
||||
|
||||
/**
|
||||
* The <code>PropagatedTraceId</code> represents a {@link DistributedTraceId}, which is propagated from the peer.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
|
||||
/**
|
||||
* This is the abstract tag.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
|
||||
/**
|
||||
* Do the same thing as {@link StringTag}, just with a {@link Boolean} value.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
/**
|
||||
* The tag item with String key and Boolean value.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
|
||||
/**
|
||||
* Do the same thing as {@link StringTag}, just with a {@link Integer} value.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
/**
|
||||
* The tag item with String key and Int value.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
|
||||
/**
|
||||
* A subclass of {@link AbstractTag},
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
/**
|
||||
* The tag item with String key and String value.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.trace.tag;
|
||||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
|
||||
/**
|
||||
* The span tags are supported by sky-walking engine.
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* LeafSpan is a special type of {@link Span}
|
||||
|
|
@ -41,15 +39,15 @@ public class LeafSpan extends Span {
|
|||
super(spanId, parentSpan.getSpanId(), operationName, startTime);
|
||||
}
|
||||
|
||||
void push() {
|
||||
public void push() {
|
||||
stackDepth++;
|
||||
}
|
||||
|
||||
void pop() {
|
||||
public void pop() {
|
||||
stackDepth--;
|
||||
}
|
||||
|
||||
boolean isFinished() {
|
||||
public boolean isFinished() {
|
||||
return stackDepth == 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
package org.skywalking.apm.trace;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.skywalking.apm.trace;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import java.util.Collections;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.skywalking.apm.trace;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
|
@ -13,10 +13,11 @@ import java.util.HashMap;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.skywalking.apm.trace.tag.BooleanTagItem;
|
||||
import org.skywalking.apm.trace.tag.IntTagItem;
|
||||
import org.skywalking.apm.trace.tag.StringTagItem;
|
||||
import org.skywalking.apm.trace.util.ThrowableTransformer;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTagItem;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTagItem;
|
||||
import org.skywalking.apm.agent.core.context.tag.StringTagItem;
|
||||
import org.skywalking.apm.agent.core.context.util.ThrowableTransformer;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
|
||||
/**
|
||||
|
|
@ -194,6 +195,14 @@ public class Span {
|
|||
*/
|
||||
public Span setOperationName(String operationName) {
|
||||
this.operationName = operationName;
|
||||
if (this.spanId == 0) {
|
||||
if (operationName != null) {
|
||||
int suffixIdx = operationName.lastIndexOf(".");
|
||||
if (suffixIdx > -1 && Config.Agent.IGNORE_SUFFIX.contains(operationName.substring(suffixIdx))) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package org.skywalking.apm.trace;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.skywalking.apm.trace.TraceId.DistributedTraceId;
|
||||
import org.skywalking.apm.trace.TraceId.DistributedTraceIds;
|
||||
import org.skywalking.apm.trace.TraceId.NewDistributedTraceId;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.ids.GlobalIdGenerator;
|
||||
import org.skywalking.apm.agent.core.context.ids.DistributedTraceId;
|
||||
import org.skywalking.apm.agent.core.context.ids.DistributedTraceIds;
|
||||
import org.skywalking.apm.agent.core.context.ids.NewDistributedTraceId;
|
||||
|
||||
/**
|
||||
* {@link TraceSegment} is a segment or fragment of the distributed trace.
|
||||
|
|
@ -90,16 +90,6 @@ public class TraceSegment {
|
|||
@SerializedName(value = "gt")
|
||||
private DistributedTraceIds relatedGlobalTraces;
|
||||
|
||||
/**
|
||||
* The <code>sampled</code> is a flag, which represent, when this {@link TraceSegment} finished, it need to be send
|
||||
* to Collector.
|
||||
* <p>
|
||||
* Its value depends on SamplingService. True, by default.
|
||||
* <p>
|
||||
* This value is not serialized.
|
||||
*/
|
||||
private boolean sampled;
|
||||
|
||||
/**
|
||||
* Create a trace segment, by the given applicationCode.
|
||||
*/
|
||||
|
|
@ -119,7 +109,6 @@ public class TraceSegment {
|
|||
this.spans = new LinkedList<Span>();
|
||||
this.relatedGlobalTraces = new DistributedTraceIds();
|
||||
this.relatedGlobalTraces.append(new NewDistributedTraceId());
|
||||
this.sampled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -201,14 +190,6 @@ public class TraceSegment {
|
|||
return applicationCode;
|
||||
}
|
||||
|
||||
public boolean isSampled() {
|
||||
return sampled;
|
||||
}
|
||||
|
||||
public void setSampled(boolean sampled) {
|
||||
this.sampled = sampled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TraceSegment{" +
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package org.skywalking.apm.trace;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* {@link TraceSegmentRef} is like a pointer, which ref to another {@link TraceSegment},
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.skywalking.apm.trace.util;
|
||||
package org.skywalking.apm.agent.core.context.util;
|
||||
|
||||
/**
|
||||
* {@link ThrowableTransformer} is responsible for transferring stack trace of throwable.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package org.skywalking.apm.agent.core.queue;
|
||||
|
||||
import com.lmax.disruptor.EventFactory;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* Just a holder of {@link TraceSegment} instance.
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ import com.lmax.disruptor.EventHandler;
|
|||
import com.lmax.disruptor.RingBuffer;
|
||||
import com.lmax.disruptor.dsl.Disruptor;
|
||||
import com.lmax.disruptor.util.DaemonThreadFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.boot.StatusBootService;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.context.TracerContextListener;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.logging.ILog;
|
||||
import org.skywalking.apm.logging.LogManager;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link TraceSegmentProcessQueue} is a proxy of {@link Disruptor}, High Performance Inter-Thread MQ.
|
||||
|
|
@ -51,7 +51,7 @@ public class TraceSegmentProcessQueue extends StatusBootService implements Trace
|
|||
*/
|
||||
@Override
|
||||
public void afterFinished(TraceSegment traceSegment) {
|
||||
if (isStarted() && traceSegment.isSampled()) {
|
||||
if (isStarted()) {
|
||||
long sequence = this.buffer.next(); // Grab the next sequence
|
||||
try {
|
||||
TraceSegmentHolder data = this.buffer.get(sequence);
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@ package org.skywalking.apm.agent.core.sampling;
|
|||
import org.skywalking.apm.agent.core.boot.BootService;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.logging.ILog;
|
||||
import org.skywalking.apm.logging.LogManager;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* The <code>SamplingService</code> take charge of how to sample the {@link TraceSegment}. Every {@link TraceSegment}s
|
||||
* have been traced, but, considering CPU cost of serialization/deserialization, and network bandwidth, the agent do NOT
|
||||
* send all of them to collector, if SAMPLING is on.
|
||||
* <p>
|
||||
* By default, SAMPLING is off, and {@link Config.Agent#SAMPLING_CYCLE} == 1.
|
||||
* By default, SAMPLING is on, and {@see {@link Config.Agent#SAMPLE_N_PER_10_SECS}}
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
|
|
@ -24,27 +24,12 @@ public class SamplingService implements BootService {
|
|||
|
||||
@Override
|
||||
public void bootUp() throws Throwable {
|
||||
if (Config.Agent.SAMPLING_CYCLE == 1) {
|
||||
this.on = false;
|
||||
return;
|
||||
if (Config.Agent.SAMPLE_N_PER_10_SECS > 0) {
|
||||
on = true;
|
||||
}
|
||||
if (Config.Agent.SAMPLING_CYCLE < 1) {
|
||||
throw new IllegalSamplingRateException("sampling cycle must greater than 0.");
|
||||
}
|
||||
this.on = true;
|
||||
|
||||
logger.debug("The trace sampling is on, and the sampling cycle is: {}", Config.Agent.SAMPLING_CYCLE);
|
||||
}
|
||||
|
||||
public void trySampling(TraceSegment segment) {
|
||||
if (on) {
|
||||
if (rollingSeed % Config.Agent.SAMPLING_CYCLE != 0) {
|
||||
segment.setSampled(false);
|
||||
rollingSeed++;
|
||||
} else {
|
||||
this.rollingSeed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -58,12 +43,6 @@ public class SamplingService implements BootService {
|
|||
* @param carrier
|
||||
*/
|
||||
public void setSampleWhenExtract(TraceSegment segment, ContextCarrier carrier) {
|
||||
if (on) {
|
||||
if (!segment.isSampled() && carrier.isSampled()) {
|
||||
segment.setSampled(true);
|
||||
this.rollingSeed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package org.skywalking.apm.agent.core.context;
|
|||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.trace.TraceId.DistributedTraceId;
|
||||
import org.skywalking.apm.trace.TraceId.PropagatedTraceId;
|
||||
import org.skywalking.apm.agent.core.context.ids.DistributedTraceId;
|
||||
import org.skywalking.apm.agent.core.context.ids.PropagatedTraceId;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
|
@ -19,18 +19,17 @@ public class ContextCarrierTestCase {
|
|||
carrier.setSpanId(100);
|
||||
carrier.setApplicationCode("REMOTE_APP");
|
||||
carrier.setPeerHost("10.2.3.16:8080");
|
||||
carrier.setSampled(true);
|
||||
List<DistributedTraceId> ids = new LinkedList<DistributedTraceId>();
|
||||
ids.add(new PropagatedTraceId("Trace.global.id.123"));
|
||||
carrier.setDistributedTraceIds(ids);
|
||||
|
||||
Assert.assertEquals("trace_id_A|100|REMOTE_APP|10.2.3.16:8080|Trace.global.id.123|1", carrier.serialize());
|
||||
Assert.assertEquals("trace_id_A|100|REMOTE_APP|10.2.3.16:8080|Trace.global.id.123", carrier.serialize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeserialize() {
|
||||
ContextCarrier carrier = new ContextCarrier();
|
||||
carrier.deserialize("trace_id_A|100|REMOTE_APP|10.2.3.16:8080|Trace.global.id.123,Trace.global.id.222|1");
|
||||
carrier.deserialize("trace_id_A|100|REMOTE_APP|10.2.3.16:8080|Trace.global.id.123,Trace.global.id.222");
|
||||
|
||||
Assert.assertEquals("trace_id_A", carrier.getTraceSegmentId());
|
||||
Assert.assertEquals(100, carrier.getSpanId());
|
||||
|
|
@ -38,7 +37,6 @@ public class ContextCarrierTestCase {
|
|||
Assert.assertEquals("10.2.3.16:8080", carrier.getPeerHost());
|
||||
Assert.assertEquals("Trace.global.id.123", carrier.getDistributedTraceIds().get(0).get());
|
||||
Assert.assertEquals("Trace.global.id.222", carrier.getDistributedTraceIds().get(1).get());
|
||||
Assert.assertEquals(true, carrier.isSampled());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -65,10 +63,10 @@ public class ContextCarrierTestCase {
|
|||
|
||||
carrier = new ContextCarrier();
|
||||
carrier.deserialize("trace_id|100|REMOTE_APP|10.2.3.16:8080|Trace.global.id.123,Trace.global.id.222");
|
||||
Assert.assertFalse(carrier.isValid());
|
||||
Assert.assertTrue(carrier.isValid());
|
||||
|
||||
carrier = new ContextCarrier();
|
||||
carrier.deserialize("trace_id|100|REMOTE_APP|10.2.3.16:8080|Trace.global.id.123,Trace.global.id.222|0");
|
||||
Assert.assertTrue(carrier.isValid());
|
||||
Assert.assertFalse(carrier.isValid());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import org.junit.Assert;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/19.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/19.
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@ package org.skywalking.apm.agent.core.context;
|
|||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceId.DistributedTraceId;
|
||||
import org.skywalking.apm.trace.TraceId.PropagatedTraceId;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.ids.DistributedTraceId;
|
||||
import org.skywalking.apm.agent.core.context.ids.PropagatedTraceId;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.agent.core.context.trace.LeafSpan;
|
||||
import org.skywalking.apm.agent.core.tags.BooleanTagReader;
|
||||
import org.skywalking.apm.agent.core.tags.IntTagReader;
|
||||
import org.skywalking.apm.agent.core.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.tag.BooleanTag;
|
||||
import org.skywalking.apm.trace.tag.IntTag;
|
||||
import org.skywalking.apm.trace.tag.StringTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.StringTag;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
package org.skywalking.apm.trace;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/18.
|
||||
|
|
@ -1,13 +1,15 @@
|
|||
package org.skywalking.apm.trace;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.trace.tag.BooleanTagReader;
|
||||
import org.skywalking.apm.trace.tag.StringTagReader;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.tags.BooleanTagReader;
|
||||
import org.skywalking.apm.agent.core.tags.StringTagReader;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/18.
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
package org.skywalking.apm.trace;
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.trace.tag.StringTagReader;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.tags.StringTagReader;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/18.
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.sampling;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class SamplingServiceTest {
|
||||
@Test
|
||||
public void test50Percent() {
|
||||
Config.Agent.SAMPLING_CYCLE = 2;
|
||||
ServiceManager.INSTANCE.boot();
|
||||
|
||||
TraceSegment segment = new TraceSegment();
|
||||
Assert.assertTrue(segment.isSampled());
|
||||
|
||||
SamplingService service = ServiceManager.INSTANCE.findService(SamplingService.class);
|
||||
service.trySampling(segment);
|
||||
Assert.assertFalse(segment.isSampled());
|
||||
|
||||
segment = new TraceSegment();
|
||||
service.trySampling(segment);
|
||||
Assert.assertTrue(segment.isSampled());
|
||||
|
||||
segment = new TraceSegment();
|
||||
service.trySampling(segment);
|
||||
Assert.assertFalse(segment.isSampled());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clear() {
|
||||
Config.Agent.SAMPLING_CYCLE = 1;
|
||||
ServiceManager.INSTANCE.boot();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@ package org.skywalking.apm.agent.core.tags;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.BooleanTag;
|
||||
import org.skywalking.apm.trace.tag.BooleanTagItem;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package org.skywalking.apm.agent.core.tags;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.IntTag;
|
||||
import org.skywalking.apm.trace.tag.IntTagItem;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package org.skywalking.apm.agent.core.tags;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.StringTag;
|
||||
import org.skywalking.apm.trace.tag.StringTagItem;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.StringTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.StringTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.alibaba.dubbo.rpc.Invocation;
|
|||
import com.alibaba.dubbo.rpc.Invoker;
|
||||
import com.alibaba.dubbo.rpc.Result;
|
||||
import com.alibaba.dubbo.rpc.RpcContext;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
|
|
@ -13,8 +14,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsA
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.plugin.dubbox.BugFixActive;
|
||||
import org.skywalking.apm.plugin.dubbox.SWBaseBean;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* {@link DubboInterceptor} define how to enhance class {@link com.alibaba.dubbo.monitor.support.MonitorFilter#invoke(Invoker,
|
||||
|
|
@ -28,7 +29,6 @@ import org.skywalking.apm.trace.tag.Tags;
|
|||
*/
|
||||
public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
public static final String ATTACHMENT_NAME_OF_CONTEXT_DATA = "SWTraceContext";
|
||||
public static final String DUBBO_COMPONENT = "Dubbo";
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +64,7 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
if (!BugFixActive.isActive()) {
|
||||
//invocation.getAttachments().put("contextData", contextDataStr);
|
||||
//@see https://github.com/alibaba/dubbo/blob/dubbo-2.5.3/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java#L154-L161
|
||||
rpcContext.getAttachments().put(ATTACHMENT_NAME_OF_CONTEXT_DATA, contextCarrier.serialize());
|
||||
rpcContext.getAttachments().put(Config.Plugin.Propagation.HEADER_NAME, contextCarrier.serialize());
|
||||
} else {
|
||||
fix283SendNoAttachmentIssue(invocation, contextCarrier);
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
|
||||
ContextCarrier contextCarrier;
|
||||
if (!BugFixActive.isActive()) {
|
||||
contextCarrier = new ContextCarrier().deserialize(rpcContext.getAttachment(ATTACHMENT_NAME_OF_CONTEXT_DATA));
|
||||
contextCarrier = new ContextCarrier().deserialize(rpcContext.getAttachment(Config.Plugin.Propagation.HEADER_NAME));
|
||||
} else {
|
||||
contextCarrier = fix283RecvNoAttachmentIssue(invocation);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import com.alibaba.dubbo.rpc.Invocation;
|
|||
import com.alibaba.dubbo.rpc.Invoker;
|
||||
import com.alibaba.dubbo.rpc.Result;
|
||||
import com.alibaba.dubbo.rpc.RpcContext;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
|
@ -29,11 +27,11 @@ import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
|||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
|
@ -156,7 +154,7 @@ public class DubboInterceptorTest {
|
|||
@Test
|
||||
public void testProviderWithAttachment() {
|
||||
when(rpcContext.isConsumerSide()).thenReturn(false);
|
||||
when(rpcContext.getAttachment(DubboInterceptor.ATTACHMENT_NAME_OF_CONTEXT_DATA)).thenReturn("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123|1");
|
||||
when(rpcContext.getAttachment(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123");
|
||||
|
||||
dubboInterceptor.beforeMethod(classInstanceContext, methodInvokeContext, methodInterceptResult);
|
||||
dubboInterceptor.afterMethod(classInstanceContext, methodInvokeContext, result);
|
||||
|
|
@ -168,7 +166,7 @@ public class DubboInterceptorTest {
|
|||
when(rpcContext.isConsumerSide()).thenReturn(false);
|
||||
when(BugFixActive.isActive()).thenReturn(true);
|
||||
|
||||
testParam.setTraceContext("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123|1");
|
||||
testParam.setTraceContext("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123");
|
||||
|
||||
dubboInterceptor.beforeMethod(classInstanceContext, methodInvokeContext, methodInterceptResult);
|
||||
dubboInterceptor.afterMethod(classInstanceContext, methodInvokeContext, result);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceCon
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* {@link DefaultHttpClientInterceptor} intercept the default implementation of http calls by the Feign.
|
||||
|
|
@ -68,7 +68,7 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc
|
|||
|
||||
headersField.setAccessible(true);
|
||||
Map<String, Collection<String>> headers = new LinkedHashMap<String, Collection<String>>();
|
||||
headers.put(Config.Plugin.Http.HEADER_NAME_OF_CONTEXT_DATA, contextCollection);
|
||||
headers.put(Config.Plugin.Propagation.HEADER_NAME, contextCollection);
|
||||
headers.putAll(request.headers());
|
||||
|
||||
headersField.set(request, Collections.unmodifiableMap(headers));
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
|||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.BooleanTagReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
package org.skywalking.apm.plugin.httpClient.v4;
|
||||
|
||||
import org.apache.http.*;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
|
@ -20,19 +21,18 @@ import java.net.URL;
|
|||
* @author zhangxin
|
||||
*/
|
||||
public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
public static final String HEADER_NAME_OF_CONTEXT_DATA = "SWTraceContext";
|
||||
private static final String COMPONENT_NAME = "HttpClient";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context,
|
||||
InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
Object[] allArguments = interceptorContext.allArguments();
|
||||
if (allArguments[0] == null || allArguments[1] == null) {
|
||||
// illegal args, can't trace. ignore.
|
||||
return;
|
||||
}
|
||||
HttpHost httpHost = (HttpHost) allArguments[0];
|
||||
HttpRequest httpRequest = (HttpRequest) allArguments[1];
|
||||
HttpHost httpHost = (HttpHost)allArguments[0];
|
||||
HttpRequest httpRequest = (HttpRequest)allArguments[1];
|
||||
Span span = createSpan(httpRequest);
|
||||
span.setPeerHost(httpHost.getHostName());
|
||||
span.setPort(httpHost.getPort());
|
||||
|
|
@ -43,7 +43,7 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
|
|||
|
||||
ContextCarrier contextCarrier = new ContextCarrier();
|
||||
ContextManager.inject(contextCarrier);
|
||||
httpRequest.setHeader(HEADER_NAME_OF_CONTEXT_DATA, contextCarrier.serialize());
|
||||
httpRequest.setHeader(Config.Plugin.Propagation.HEADER_NAME, contextCarrier.serialize());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -71,13 +71,13 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
|
|||
|
||||
@Override
|
||||
public Object afterMethod(EnhancedClassInstanceContext context,
|
||||
InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
Object[] allArguments = interceptorContext.allArguments();
|
||||
if (allArguments[0] == null || allArguments[1] == null) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
HttpResponse response = (HttpResponse) ret;
|
||||
HttpResponse response = (HttpResponse)ret;
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
Span span = ContextManager.activeSpan();
|
||||
if (statusCode != 200) {
|
||||
|
|
@ -91,7 +91,7 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
|
|||
|
||||
@Override
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context,
|
||||
InstanceMethodInvokeContext interceptorContext) {
|
||||
InstanceMethodInvokeContext interceptorContext) {
|
||||
Tags.ERROR.set(ContextManager.activeSpan(), true);
|
||||
ContextManager.activeSpan().log(t);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
|||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.BooleanTagReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package org.skywalking.apm.plugin.jdbc;
|
|||
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package org.skywalking.apm.plugin.jdbc;
|
|||
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package org.skywalking.apm.plugin.jdbc;
|
|||
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package org.skywalking.apm.plugin.jdbc;
|
|||
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import java.util.List;
|
|||
import org.hamcrest.CoreMatchers;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ import org.skywalking.apm.agent.core.boot.ServiceManager;
|
|||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import org.skywalking.apm.agent.core.boot.ServiceManager;
|
|||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ import org.skywalking.apm.agent.core.boot.ServiceManager;
|
|||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.sql.Connection;
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ import org.skywalking.apm.agent.core.boot.ServiceManager;
|
|||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.assist.NoConcurrencyAcce
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
|||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.BooleanTagReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.*;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceCon
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
|||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.*;
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
|||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.skywalking.apm.plugin.motan;
|
|||
import com.weibo.api.motan.rpc.Request;
|
||||
import com.weibo.api.motan.rpc.Response;
|
||||
import com.weibo.api.motan.rpc.URL;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
|
|
@ -11,8 +12,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstruc
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* {@link MotanProviderInterceptor} create span by fetch request url from
|
||||
|
|
@ -28,10 +29,6 @@ public class MotanConsumerInterceptor implements InstanceConstructorInterceptor,
|
|||
*/
|
||||
private static final String KEY_NAME_OF_REQUEST_URL = "REQUEST_URL";
|
||||
|
||||
/**
|
||||
* The {@link Request#getAttachments()} key. It maps to the serialized {@link ContextCarrier}.
|
||||
*/
|
||||
private static final String ATTACHMENT_KEY_OF_CONTEXT_DATA = "SWTraceContext";
|
||||
/**
|
||||
* Motan component
|
||||
*/
|
||||
|
|
@ -58,7 +55,7 @@ public class MotanConsumerInterceptor implements InstanceConstructorInterceptor,
|
|||
|
||||
ContextCarrier contextCarrier = new ContextCarrier();
|
||||
ContextManager.inject(contextCarrier);
|
||||
request.setAttachment(ATTACHMENT_KEY_OF_CONTEXT_DATA, contextCarrier.serialize());
|
||||
request.setAttachment(Config.Plugin.Propagation.HEADER_NAME, contextCarrier.serialize());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.skywalking.apm.plugin.motan;
|
|||
|
||||
import com.weibo.api.motan.rpc.Request;
|
||||
import com.weibo.api.motan.rpc.Response;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
|
|
@ -9,8 +10,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodIn
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* Current trace segment will ref the trace segment if the serialized trace context that fetch from {@link
|
||||
|
|
@ -22,12 +23,6 @@ import org.skywalking.apm.trace.tag.Tags;
|
|||
* @author zhangxin
|
||||
*/
|
||||
public class MotanProviderInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
/**
|
||||
* Attachment key of the serialized context data.
|
||||
*/
|
||||
private static final String ATTACHMENT_KEY_OF_CONTEXT_DATA = "SWTraceContext";
|
||||
|
||||
/**
|
||||
* Motan component
|
||||
*/
|
||||
|
|
@ -42,7 +37,7 @@ public class MotanProviderInterceptor implements InstanceMethodsAroundIntercepto
|
|||
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER);
|
||||
Tags.SPAN_LAYER.asRPCFramework(span);
|
||||
|
||||
String serializedContextData = request.getAttachments().get(ATTACHMENT_KEY_OF_CONTEXT_DATA);
|
||||
String serializedContextData = request.getAttachments().get(Config.Plugin.Propagation.HEADER_NAME);
|
||||
if (!StringUtil.isEmpty(serializedContextData)) {
|
||||
ContextManager.extract(new ContextCarrier().deserialize(serializedContextData));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
|||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.*;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
|
|
@ -20,11 +21,11 @@ import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
|||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
|
@ -89,7 +90,7 @@ public class MotanProviderInterceptorTest {
|
|||
@Test
|
||||
public void testInvokerWithRefSegment() {
|
||||
HashMap attachments = new HashMap();
|
||||
attachments.put("SWTraceContext", "302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123|1");
|
||||
attachments.put(Config.Plugin.Propagation.HEADER_NAME, "302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123");
|
||||
when(request.getAttachments()).thenReturn(attachments);
|
||||
|
||||
invokeInterceptor.beforeMethod(instanceContext, interceptorContext, null);
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstruc
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* {@link RealCallInterceptor} intercept the synchronous http calls by the client of okhttp.
|
||||
|
|
@ -75,7 +75,7 @@ public class RealCallInterceptor implements InstanceMethodsAroundInterceptor, In
|
|||
modifiersField.setInt(headersField, headersField.getModifiers() & ~Modifier.FINAL);
|
||||
|
||||
headersField.setAccessible(true);
|
||||
Headers headers = request.headers().newBuilder().add(Config.Plugin.Http.HEADER_NAME_OF_CONTEXT_DATA, contextCarrier.serialize()).build();
|
||||
Headers headers = request.headers().newBuilder().add(Config.Plugin.Propagation.HEADER_NAME, contextCarrier.serialize()).build();
|
||||
headersField.set(request, headers);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
|||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.BooleanTagReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
package org.skywalking.apm.plugin.resin.v3;
|
||||
|
||||
import com.caucho.server.connection.CauchoRequest;
|
||||
import com.caucho.server.http.HttpRequest;
|
||||
import com.caucho.server.http.HttpResponse;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
|
||||
/**
|
||||
|
|
@ -20,11 +20,6 @@ import org.skywalking.apm.util.StringUtil;
|
|||
* @author baiyang
|
||||
*/
|
||||
public class ResinV3Interceptor implements InstanceMethodsAroundInterceptor {
|
||||
/**
|
||||
* Header name that the serialized context data stored in
|
||||
* {@link HttpRequest#getHeader(String)}.
|
||||
*/
|
||||
public static final String HEADER_NAME_OF_CONTEXT_DATA = "SWTraceContext";
|
||||
/**
|
||||
* Resin component.
|
||||
*/
|
||||
|
|
@ -43,7 +38,7 @@ public class ResinV3Interceptor implements InstanceMethodsAroundInterceptor {
|
|||
Tags.URL.set(span, appendRequestURL(request));
|
||||
Tags.SPAN_LAYER.asHttp(span);
|
||||
|
||||
String tracingHeaderValue = request.getHeader(HEADER_NAME_OF_CONTEXT_DATA);
|
||||
String tracingHeaderValue = request.getHeader(Config.Plugin.Propagation.HEADER_NAME);
|
||||
if (!StringUtil.isEmpty(tracingHeaderValue)) {
|
||||
ContextManager.extract(new ContextCarrier().deserialize(tracingHeaderValue));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
@ -19,11 +20,11 @@ import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
|||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.IntTagReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
|
@ -89,7 +90,7 @@ public class ResinV3InterceptorTest {
|
|||
|
||||
@Test
|
||||
public void testWithSerializedContextData() {
|
||||
when(request.getHeader(ResinV3Interceptor.HEADER_NAME_OF_CONTEXT_DATA)).thenReturn("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123|1");
|
||||
when(request.getHeader(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123");
|
||||
|
||||
interceptor.beforeMethod(classInstanceContext, methodInvokeContext, methodInterceptResult);
|
||||
interceptor.afterMethod(classInstanceContext, methodInvokeContext, null);
|
||||
|
|
|
|||
|
|
@ -1,27 +1,22 @@
|
|||
package org.skywalking.apm.plugin.resin.v4;
|
||||
|
||||
import com.caucho.server.http.CauchoRequest;
|
||||
import com.caucho.server.http.HttpRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
|
||||
/**
|
||||
* Created by Baiyang on 2017/5/2.
|
||||
*/
|
||||
public class ResinV4Interceptor implements InstanceMethodsAroundInterceptor {
|
||||
/**
|
||||
* Header name that the serialized context data stored in
|
||||
* {@link HttpRequest#getHeader(String)}.
|
||||
*/
|
||||
public static final String HEADER_NAME_OF_CONTEXT_DATA = "SWTraceContext";
|
||||
/**
|
||||
* Resin component.
|
||||
*/
|
||||
|
|
@ -40,7 +35,7 @@ public class ResinV4Interceptor implements InstanceMethodsAroundInterceptor {
|
|||
Tags.URL.set(span, appendRequestURL(request));
|
||||
Tags.SPAN_LAYER.asHttp(span);
|
||||
|
||||
String tracingHeaderValue = request.getHeader(HEADER_NAME_OF_CONTEXT_DATA);
|
||||
String tracingHeaderValue = request.getHeader(Config.Plugin.Propagation.HEADER_NAME);
|
||||
if (!StringUtil.isEmpty(tracingHeaderValue)) {
|
||||
ContextManager.extract(new ContextCarrier().deserialize(tracingHeaderValue));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
@ -19,11 +20,11 @@ import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
|||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.IntTagReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
|
@ -88,7 +89,7 @@ public class ResinV4InterceptorTest {
|
|||
|
||||
@Test
|
||||
public void testWithSerializedContextData() {
|
||||
when(request.getHeader(ResinV4Interceptor.HEADER_NAME_OF_CONTEXT_DATA)).thenReturn("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123|1");
|
||||
when(request.getHeader(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123");
|
||||
|
||||
interceptor.beforeMethod(classInstanceContext, methodInvokeContext, methodInterceptResult);
|
||||
interceptor.afterMethod(classInstanceContext, methodInvokeContext, null);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.skywalking.apm.plugin.tomcat78x;
|
||||
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
|
|
@ -7,9 +8,9 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodIn
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.util.StringUtil;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
@ -20,10 +21,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
* segment id of the previous level if the serialized context is not null.
|
||||
*/
|
||||
public class TomcatInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
/**
|
||||
* Header name that the serialized context data stored in {@link HttpServletRequest#getHeader(String)}.
|
||||
*/
|
||||
public static final String HEADER_NAME_OF_CONTEXT_DATA = "SWTraceContext";
|
||||
/**
|
||||
* Tomcat component.
|
||||
*/
|
||||
|
|
@ -51,7 +48,7 @@ public class TomcatInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
Tags.URL.set(span, request.getRequestURL().toString());
|
||||
Tags.SPAN_LAYER.asHttp(span);
|
||||
|
||||
String tracingHeaderValue = request.getHeader(HEADER_NAME_OF_CONTEXT_DATA);
|
||||
String tracingHeaderValue = request.getHeader(Config.Plugin.Propagation.HEADER_NAME);
|
||||
if (!StringUtil.isEmpty(tracingHeaderValue)) {
|
||||
ContextManager.extract(new ContextCarrier().deserialize(tracingHeaderValue));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
@ -19,11 +20,11 @@ import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
|||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.IntTagReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
|
@ -81,7 +82,7 @@ public class TomcatInterceptorTest {
|
|||
|
||||
@Test
|
||||
public void testWithSerializedContextData() {
|
||||
when(request.getHeader(TomcatInterceptor.HEADER_NAME_OF_CONTEXT_DATA)).thenReturn("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123|1");
|
||||
when(request.getHeader(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1|Trace.globalId.123");
|
||||
|
||||
tomcatInterceptor.beforeMethod(classInstanceContext, methodInvokeContext, methodInterceptResult);
|
||||
tomcatInterceptor.afterMethod(classInstanceContext, methodInvokeContext, null);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.skywalking.apm.sniffer.mock.context;
|
|||
import org.junit.Assert;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.context.TracerContextListener;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.sniffer.mock.context;
|
||||
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* The <code>SegmentAssert</code> interface should be implemented by any
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package org.skywalking.apm.sniffer.mock.trace;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.trace.LogData;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.trace.LogData;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace;
|
||||
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/20.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.skywalking.apm.sniffer.mock.trace;
|
|||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.trace.*;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* The <code>TraceSegmentBuilderFactory</code> contains all {@link TraceSegmentBuilder} implementations. All the
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace.builders.span;
|
||||
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* The <code>DubboSpanGenerator</code> generates all possible spans, by tracing Dubbo rpc.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace.builders.span;
|
||||
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* The <code>MySQLGenerator</code> generates all possible spans, by tracing mysql client access.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace.builders.span;
|
||||
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
/**
|
||||
* The <code>TomcatSpanGenerator</code> generate all possible spans, by tracing Tomcat.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
|||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.DubboSpanGenerator;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.MySQLGenerator;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.skywalking.apm.sniffer.mock.trace.builders.trace;
|
|||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.TomcatSpanGenerator;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* A Trace contains only one span, which represent a tomcat server side span.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.skywalking.apm.sniffer.mock.trace.builders.trace;
|
|||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.TomcatSpanGenerator;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* A Trace contains only one span, which represent a tomcat server side span.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.skywalking.apm.sniffer.mock.trace.builders.trace;
|
|||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.TomcatSpanGenerator;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* A Trace contains only one span, which represent a tomcat server side span.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
|||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.DubboSpanGenerator;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.TomcatSpanGenerator;
|
||||
import org.skywalking.apm.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* A Trace segment contains two spans with ChildOf relations,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package org.skywalking.apm.sniffer.mock.trace.tags;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.BooleanTag;
|
||||
import org.skywalking.apm.trace.tag.BooleanTagItem;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package org.skywalking.apm.sniffer.mock.trace.tags;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.trace.Span;
|
||||
import org.skywalking.apm.trace.tag.IntTag;
|
||||
import org.skywalking.apm.trace.tag.IntTagItem;
|
||||
import org.skywalking.apm.agent.core.context.trace.Span;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue