Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>tracer-all-parent</artifactId>
<version>3.1.9</version>
<version>3.1.10</version>
<packaging>pom</packaging>
<name>tracer-all-parent</name>
<description>Alipay SOFATracer Log Implemented by OpenTracing</description>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-datasource-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-dubbo-2.6.x-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-dubbo-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-flexible-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-httpclient-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-kafkamq-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-mongodb-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-okhttp-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-redis-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-resttmplate-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-rocketmq-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-springmvc-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-zipkin-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
4 changes: 2 additions & 2 deletions tracer-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>tracer-all</artifactId>
<version>3.1.9</version>
<version>3.1.10</version>
<packaging>jar</packaging>

<name>SOFATracer in one without SOFABoot starter</name>
Expand Down
2 changes: 1 addition & 1 deletion tracer-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.9</version>
<version>3.1.10</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@
import io.opentracing.Tracer;
import io.opentracing.propagation.Format;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

import static com.alipay.common.tracer.core.constants.SofaTracerConstant.SPACE_ID;
Expand Down Expand Up @@ -76,6 +72,10 @@ public class SofaTracer implements Tracer {
*/
private final Reporter serverReporter;

private final Reporter clientEventReporter;

private final Reporter serverEventReporter;

/**
* Cache some information related to the tracer globally
*/
Expand All @@ -91,6 +91,8 @@ protected SofaTracer(String tracerType, Reporter clientReporter, Reporter server
this.tracerType = tracerType;
this.clientReporter = clientReporter;
this.serverReporter = serverReporter;
this.clientEventReporter = null;
this.serverEventReporter = null;
this.sampler = sampler;
if (tracerTags != null && tracerTags.size() > 0) {
this.tracerTags.putAll(tracerTags);
Expand All @@ -101,9 +103,25 @@ protected SofaTracer(String tracerType, Sampler sampler) {
this.tracerType = tracerType;
this.clientReporter = null;
this.serverReporter = null;
this.clientEventReporter = null;
this.serverEventReporter = null;
this.sampler = sampler;
}

protected SofaTracer(String tracerType, Reporter clientReporter, Reporter serverReporter,
Reporter clientEventReporter, Reporter serverEventReporter,
Sampler sampler, Map<String, Object> tracerTags) {
this.tracerType = tracerType;
this.clientReporter = clientReporter;
this.serverReporter = serverReporter;
this.clientEventReporter = clientEventReporter;
this.serverEventReporter = serverEventReporter;
this.sampler = sampler;
if (tracerTags != null && tracerTags.size() > 0) {
this.tracerTags.putAll(tracerTags);
}
}

@Override
public SpanBuilder buildSpan(String operationName) {
return new SofaTracerSpanBuilder(operationName);
Expand Down Expand Up @@ -153,6 +171,31 @@ public void reportSpan(SofaTracerSpan span) {
}
}

public void reportEvent(SofaTracerSpan span) {
if (span == null) {
return;
}
// //sampler is support & current span is root span
if (sampler != null && (span.isClient() && span.getParentSofaTracerSpan() == null)) {
span.getSofaTracerSpanContext().setSampled(sampler.sample(span).isSampled());
}
//invoke listener
this.invokeReportListeners(span);
if (span.isClient()
|| this.getTracerType().equalsIgnoreCase(ComponentNameConstants.FLEXIBLE)) {
if (this.clientEventReporter != null) {
this.clientEventReporter.report(span);
}
} else if (span.isServer()) {
if (this.serverEventReporter != null) {
this.serverEventReporter.report(span);
}
} else {
//ignore ,do not statical
SelfLog.warn("Span reported neither client nor server.Ignore!");
}
}

/**
* Shuts down the {@link Reporter} and {@link Sampler}
*/
Expand All @@ -164,6 +207,14 @@ public void close() {
this.serverReporter.close();
}

if (this.clientEventReporter != null) {
this.clientEventReporter.close();
}

if (this.serverEventReporter != null) {
this.serverEventReporter.close();
}

if (sampler != null) {
this.sampler.close();
}
Expand All @@ -181,6 +232,14 @@ public Reporter getServerReporter() {
return serverReporter;
}

public Reporter getClientEventReporter() {
return clientEventReporter;
}

public Reporter getServerEventReporter() {
return serverEventReporter;
}

public Sampler getSampler() {
return sampler;
}
Expand Down Expand Up @@ -400,6 +459,10 @@ public static final class Builder {

private Reporter serverReporter;

private Reporter clientEventReporter;

private Reporter serverEventReporter;

private Map<String, Object> tracerTags = new HashMap<String, Object>();

private Sampler sampler;
Expand All @@ -419,6 +482,16 @@ public Builder withServerReporter(Reporter serverReporter) {
return this;
}

public Builder withClientEventReporter(Reporter clientEventReporter) {
this.clientEventReporter = clientEventReporter;
return this;
}

public Builder withServerEventReporter(Reporter serverEventReporter) {
this.serverEventReporter = serverEventReporter;
return this;
}

public Builder withSampler(Sampler sampler) {
this.sampler = sampler;
return this;
Expand Down Expand Up @@ -473,7 +546,7 @@ public SofaTracer build() {
SelfLog.error(LogCode2Description.convert(SPACE_ID, "01-00002"));
}
return new SofaTracer(this.tracerType, this.clientReporter, this.serverReporter,
this.sampler, this.tracerTags);
this.clientEventReporter, this.serverEventReporter, this.sampler, this.tracerTags);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,9 @@ public class SofaTracerConstant {
public static final String STAT_FLAG_FAILS = DIGEST_FLAG_FAILS;

public static final String SPACE_ID = "sofa-tracer";

/**
* The constant MAX_SPAN_EVENT_NUM.
*/
public static final int MAX_SPAN_EVENT_NUM = 100;
}
Loading