Coder Social home page Coder Social logo

sofastack / sofa-tracer Goto Github PK

View Code? Open in Web Editor NEW
1.1K 76.0 371.0 1.84 MB

SOFATracer is a component for the distributed system call trace. And through a unified traceId logging the logs of various network calls in the invoking link. These logs can be used for quick discovery of faults, service governance, etc.

License: Apache License 2.0

Shell 0.01% Java 99.99%
sofastack opentracing tracer sofa-tracer sofa-boot-starter

sofa-tracer's Issues

zipkin 模型兼容 SOFARPC

Describe the bug

SOFATracer 上报数据到 zipkin 时,在v2模型中,zipkin 会通过广度优先遍历来构建依赖树,实际上在展示services 或者 dependencies时,zipkin ui中的展示会依赖endpiont中的serviceName。

  • 当前SOFATracer 上报 SOFARpc 的数据时,存在一个问题,SOFARpc 的 span有两个(client&server),但是这两个span具有相同的spanId和parentId,区别在于span.kind 不同。
  • 当前zipkin在构建依赖树时,因为依赖于endpiont中的serviceName。该 servieName 依赖于 idToNode(Node.TreeBuilder 中的属性,Map 结构,映射关系为 spanId -> span)。
 Node<V> previous = idToNode.put(id, node);
 if (previous != null) 
	node.setValue(mergeFunction.merge(previous.value, node.value));

这里当前node为rpc server 类型时,previous 返回结果不为null,会执行merge操作,该merge操作的核心就是设置当前rpc node的remoteEndpoint,值为 rpc client 的 localEndpoint。

这样会有一个问题,因为SOFARpc上报的 span 数据,client 和 server 除了span.kind 之外是相同的。所以最终得到的idToNode中只会包含kind为server的span ,client 被 merge了。这样就会导致 server -> server 的情况,与zipkin的client -> server 链路模型有冲突。

  • 通过构建 httpclient->mvc->rpc->h2 的链路进行测试,结果表明:在没有做SOFARpc数据上报适配时 ,dependencies中链路展示有问题,实际构建出来的链路是:httpclient->mvc ,rpc->h2 ,链路被分段。

Expected behavior

在使用SOFARpc组件时,SOFATracer可以构建完整的调用链路。 httpclient->mvc->rpc->h2
E.g

Steps to reproduce

基于当前版本并且使用SOFARpc来构建链路

Use CAS operation to eliminate synchronized block in Sample Implementation

Describe

Use CAS operation to eliminate synchronized block in Sample Implementation com.alipay.common.tracer.core.samplers.SofaTracerPercentageBasedSampler

Expected behavior

Sampler don't need synchronized lock and we can use spin lock instead to avoid performance loss.

Actual behavior

We use synchronized to lock the Sampler.

Better HttpClientBuilder API code

Sync HttpClientBuilder and Aysnc HttpClientBuilder can all through com.alipay.sofa.tracer.plugins.httpclient.SofaTracerHttpClientBuilder#clientBuilder construct and through HttpAsyncClientBuilder or HttpClientBuilder param can distinguish

连续请求情况下某些span会缺少duration属性

  • 服务端
    sofa-tracer-sample-with-zipkin : sofa-tracer samples中的Demo
  • 测试场景
    连续使用curl发送请求:
for i in {1..100}
do
    curl -v 127.0.0.1:8080/zipkin?name="forkme"
done
  • 错误现象
    1.zipkin接收端的SkyWalking日志报错,因为在取duration属性时取到了空指针;
    2.使用工具截取网络包,发现某些span少掉了duration属性。
    下面是格式化后的局部报文内容,第二个span少了duration属性(应该是第二个trace吧):
 {
    "traceId": "003660b9d81d1dba",
    "id": "af63ad4c86019caf",
    "name": "http://127.0.0.1:8080/zipkin",
    "timestamp": 1530600005337000,
    "duration": 1000,
    "annotations": [
      {
        "timestamp": 1530600005337000,
        "value": "sr",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "timestamp": 1530600005338000,
        "value": "ss",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      }
    ],
    "binaryAnnotations": [
      {
        "key": "current.thread.name",
        "value": "http-nio-8080-exec-3",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "local.app",
        "value": "SOFATracerReportZipkin",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "method",
        "value": "GET",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "req.size.bytes",
        "value": "-1",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "request.url",
        "value": "http://127.0.0.1:8080/zipkin",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "resp.size.bytes",
        "value": "52",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "result.code",
        "value": "200",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "span.kind",
        "value": "server",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      }
    ]
  },
  {
    "traceId": "003660b9d820ee4b",
    "id": "af63ad4c86019caf",
    "name": "http://127.0.0.1:8080/zipkin",
    "timestamp": 1530600005362000,
    "annotations": [
      {
        "timestamp": 1530600005362000,
        "value": "sr",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "timestamp": 1530600005362000,
        "value": "ss",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      }
    ],
    "binaryAnnotations": [
      {
        "key": "current.thread.name",
        "value": "http-nio-8080-exec-5",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "local.app",
        "value": "SOFATracerReportZipkin",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "method",
        "value": "GET",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "req.size.bytes",
        "value": "-1",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "request.url",
        "value": "http://127.0.0.1:8080/zipkin",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "resp.size.bytes",
        "value": "52",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "result.code",
        "value": "200",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      },
      {
        "key": "span.kind",
        "value": "server",
        "endpoint": {
          "serviceName": "http://127.0.0.1:8080/zipkin",
          "ipv4": "127.0.1.1"
        }
      }
    ]
  },

SOFATracer Support Zipkin version 2.X.X

Describe

SOFATracer report to Zipkin version is 1.19.2 by default

Expected behavior

SOFATracer report Zipkin client support 2.X.X version

Actual behavior

Only verify Zipkin version 1.19.X

Hash 算法的优化

使用 MurmurHash2 64-bit 算法替代目前的 FNV64
MurmurHash 算法维基百科:https://en.wikipedia.org/wiki/MurmurHash

MurmurHash 算法是08年提出的 hash 算法,比较新。高效率、低碰撞,像redis的底层字典实现都是使用该方法。目前最新版本是 MurmurHash3, 32bit 和 128bit.
本次改进使用 MurmurHash2 64bit,对比之前的 FNV64 效率更高。

源代码很多配置类注解上很多@ComponentScan导致默认的配置无法去除,无法自定义配置

Describe the bug

根据自己业务需要在配置zipkin时需要使用自定义的配置类,但是源码中很多@componentscan导致使用了一个默认的配置后就将其他符合条件的配置全激活了,即使我使用springboot技术将源码的自动化配置去掉还是无用
A clear and concise description of what the bug is.

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

@configuration
@EnableConfigurationProperties(SofaTracerProperties.class)
@componentscan(value = { "com.alipay.sofa.tracer.boot" })
public class SofaTracerAutoConfiguration {
-----------省略
}

Environment

  • SOFATracer version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

支持更丰富的采样器

目前只提供了一个基于概率的采样器, 对于正常请求来说应该够了, 但是对于生产系统来说, 更重要的是记录和监控异常请求, 因此一个很强的需求就是要让开发者自定义采样规则, 比如只要任意一个span包含了error=true的tag, 整个trace应该被收集采样.
另外还需要支持已采样的trace里面可以让用户定义规则来删掉某些span, 比如跨度时间小于某个值, 这种很小的span通常对跟踪分析没多大作用, 但是数量又很多影响整个trace的可看性.

这两个需求我在jaegertracing里面提了, 请参考
jaegertracing/jaeger-client-java#465
jaegertracing/jaeger-client-java#471

调用链路问题

我本地启动两个sofa项目A和B,http接口调用A项目之后调用rpc调用B项目,两个项目都开启上报数据到zipkin。但是在zipkin中查看调用链路,发现只有刚才的http接口链路,没有之后的rpc链路。zipkin中的traceId和spanId和sofa项目里面的traceId和spanId也不一样,请问是我没有配置好,还是项目还不支持rpc的调用链路?

netty+resteasy rest接口未打印trace日志

Your question

sofarpc启动netty+resteasy的rest接口,并没有记录trace日志
bolt接口和spring mvc格式的有记录

Your scenes

server.port=8080
com.alipay.sofa.rpc.restPort=18080
com.alipay.sofa.rpc.restContextPath=/demo
com.alipay.sofa.rpc.boltPort=28080
按这个配置,调用8080和28080的接口都有trace日志,分别在rpc-client-digest.log和spring-mvc-digest.log中,但未找到18080的日志,接口可以正常响应

Your advice

Environment

  • SOFATracer version:2.1.4
  • JVM version (e.g. java -version):1.8

SOFATracer Report to Zipkin enable true when Zipkin dependency is on classpath

Describe

Now,if we want to report data to Zipkin,we shoule add Zipkin dependency and configure Zipkin enabled.

# enable Zipkin
com.alipay.sofa.tracer.zipkin.enabled=true
# Zipkin server url ,such as http://zipkin-cloud.host.net:9411
com.alipay.sofa.tracer.zipkin.baseUrl=http://zipkin-cloud.host.net:9411

Expected

After we add Zipkin dependency,we only configure com.alipay.sofa.tracer.zipkin.baseUrl. It's not need configure com.alipay.sofa.tracer.zipkin.enabled=true

Actual

Now,we must configure com.alipay.sofa.tracer.zipkin.enabled=true

Providing manual report

It provides manual reporting of data to Zipkin, for example, what does a timer need to report data?

建议不用spring boot也可以使用sofa-tracer并且上报zipkin

现在的zipkin集成是在tracer-sofa-boot-starter项目中的,我们现在的项目没有使用spring boot,如果想集成的话会很麻烦。建议用plugin的方式做成单独的组件,starter只是简化配置,保证不用boot的项目也可以正常使用

Tracer-TimedAppender thread should set daemon

sofastack/sofa-rpc-boot-projects#69

from the issue, I tested on the local machine

 SofaTracerStatisticReporterManager(final long cycleTime) {
        this.cycleTime = cycleTime;
        this.executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {

            public Thread newThread(Runnable r) {
                final Thread thread = new Thread(r, "Tracer-TimedAppender-"
                                                    + THREAD_NUMBER.incrementAndGet() + "-"
                                                    + cycleTime);
                thread.setDaemon(true);
                return thread;
            }
        });
        start();
    }

this code should modify like this

ZipkinSofaTracerAutoConfiguration.class自动配置无效

Describe the bug

按照gitub上报Zipkin文档操作
tracer-sofa-boot-starter源码中的ZipkinSofaTracerAutoConfiguration自动配置类中
配置此自动配置生效的条件@ConditionalOnClass中的(zipkin.Span.class, zipkin.reporter.AsyncReporter.class)是找不到的,在文档中也没有提示这是什么类,
导致自动配置不生效,经过检查发现是GitHub上文档提示的引入jar包依赖不对,
找不到的类文件在
io.zipkin.java
zipkin
1.19.2

中找到。希望能够在源码和文档上进行改正,谢谢
A clear and concise description of what the bug is.
ZipkinSofaTracerAutoConfiguration自动配置不生效

Expected behavior

希望改造GitHub文档和源码

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

@ConditionalOnClass({ zipkin.Span.class, zipkin.reporter.AsyncReporter.class })
public class ZipkinSofaTracerAutoConfiguration {
-------------------------------------------------省略
}

Environment

  • SOFATracer version:2.1.4
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

使用异步servlet的时候,会报错

		<dependency>
			<groupId>com.alipay.sofa</groupId>
			<artifactId>tracer-sofa-boot-starter</artifactId>
			<version>2.1.1</version>
		</dependency>

		<dependency>
			<groupId>io.zipkin.java</groupId>
			<artifactId>zipkin</artifactId>
			<version>1.19.2</version>
		</dependency>

		<dependency>
			<groupId>io.zipkin.reporter</groupId>
			<artifactId>zipkin-reporter</artifactId>
			<version>0.6.12</version>
		</dependency>

上面使用依赖包,使用异步servlet的时候,会报错:
java.lang.IllegalStateException: getOutputStream() has already been called for this response。
能紧急更新吗?我们已经发布线上,目前紧急回退了

非http请求线程的TraceId和SpaceId

如果不是http产生的请求,而是自己产生的线程,有生成相应的TraceId 和 SpaceId的方法吗?
我这边手动往MDC里塞值,在rpc调用的时候会被冲掉;有什么不被冲掉的方法吗?

SOFATracer support HttpClient plugin

SOFATracer support HttpClient plugin ,when we use Apache httpclient such as

dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.2</version>
</dependency>

We can print SOFATracer httpclient log and also can report to Zipkin. We suggest that httpclient version more than 4.5.0.

高并发下面, TracerId生成优化.

可以看到,很多线程会在这里耗时.建议缓存 PID

"SofaBizProcessor-12200-2-T12" #30 prio=5 os_prio=0 tid=0x00007fe3aca8f000 nid=0x19259 runnable [0x00007fe354149000]
   java.lang.Thread.State: RUNNABLE
	at java.net.Inet4AddressImpl.getLocalHostName(Native Method)
	at java.net.InetAddress.getLocalHost(InetAddress.java:1474)
	at sun.management.VMManagementImpl.getVmId(VMManagementImpl.java:140)
	at sun.management.RuntimeImpl.getName(RuntimeImpl.java:59)
	at com.alipay.common.tracer.core.utils.TracerUtils.getPID(TracerUtils.java:129)
	at com.alipay.common.tracer.core.generator.TraceIdGenerator.getTraceId(TraceIdGenerator.java:47)
	at com.alipay.common.tracer.core.generator.TraceIdGenerator.generate(TraceIdGenerator.java:52)
	at com.alipay.common.tracer.core.context.span.SofaTracerSpanContext.rootStart(SofaTracerSpanContext.java:307)
	at com.alipay.common.tracer.core.context.span.SofaTracerSpanContext.rootStart(SofaTracerSpanContext.java:302)
	at com.alipay.sofa.rpc.tracer.SofaTracer.serverReceived(SofaTracer.java:396)
	at com.alipay.sofa.rpc.tracer.Tracers.serverReceived(Tracers.java:136)
	at com.alipay.sofa.rpc.event.SofaTracerSubscriber.onEvent(SofaTracerSubscriber.java:77)

Reduce test time of some test case execution.

Some test case’s execution time is too long, which make CI failed. The error message like:

The job exceeded the maximum time limit for jobs, and has been terminated.

Optimize some test case, such as:

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 109.534 sec - in com.alipay.common.tracer.core.appender.manager.ConcurrentDiscardTest
Running com.alipay.common.tracer.core.appender.manager.ConsumerExceptionHandlerTest

Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 36.03 sec - in com.alipay.common.tracer.core.appender.self.SelfLogTest
Running com.alipay.common.tracer.core.appender.self.SynchronizingSelfLogTest

[疑似bug] 获取 sequence 可能存在数据溢出

public long tryNext(int n) throws InsufficientCapacityException {
        if (n < 1) {
            throw new IllegalArgumentException("n must be > 0");
        } else {
            long current;
            long next;
            do {
                current = this.cursor.get();
                next = current + (long)n;
                if (!this.hasAvailableCapacity(this.gatingSequences, n, current)) {
                    throw InsufficientCapacityException.INSTANCE;
                }
            } while(!this.cursor.compareAndSet(current, next));

            return next;
        }
    }

以上代码不断叠加,不考虑 long 的最大值问题。当值超过最大值以后会出现溢出问题。
如图所示:
image

虽然在在 具体定位元素位置是 对 sequence 有做处理, 与 1023 相& 。 最后得到的结果是正确的:

 protected final E elementAt(long sequence) {
        return UNSAFE.getObject(this.entries, REF_ARRAY_BASE + ((sequence & this.indexMask) << REF_ELEMENT_SHIFT));
    }

但不知道 sequence 的设计之初就是为了通过 后面公式来补救这种溢出问题,还是可能是漏写了?

某一处可能会因为Long数据溢出报错:

 private boolean hasAvailableCapacity(Sequence[] gatingSequences, int requiredCapacity, long cursorValue) {
        long wrapPoint = cursorValue + (long)requiredCapacity - (long)this.bufferSize;
        long cachedGatingSequence = this.gatingSequenceCache.get();
        if (wrapPoint > cachedGatingSequence || cachedGatingSequence > cursorValue) {
           //  只要一旦 cursorValue 溢出了,下面就会导致 返回的结果一直是 false
            long minSequence = Util.getMinimumSequence(gatingSequences, cursorValue);
            this.gatingSequenceCache.set(minSequence);
            if (wrapPoint > minSequence) {
                return false;
            }
        }

        return true;
    }

读代码时的一点疑惑,仅供参考。

DataSourceBeanFactoryPostProcessor抛出异常

Describe the bug

升级sofa-boot 2.5.0后,启动失败
java.lang.ClassCastException: java.lang.String cannot be cast to org.springframework.beans.factory.config.TypedStringValue
at com.alipay.sofa.tracer.boot.datasource.processor.DataSourceBeanFactoryPostProcessor.createDataSourceProxy(DataSourceBeanFactoryPostProcessor.java:123) ~[tracer-sofa-boot-starter-2.2.0.jar:2.2.0]
at com.alipay.sofa.tracer.boot.datasource.processor.DataSourceBeanFactoryPostProcessor.postProcessBeanFactory(DataSourceBeanFactoryPostProcessor.java:63) ~[tracer-sofa-boot-starter-2.2.0.jar:2.2.0]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:283) ~[spring-context-4.3.19.RELEASE.jar:4.3.19.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:178) ~[spring-context-4.3.19.RELEASE.jar:4.3.19.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.19.RELEASE.jar:4.3.19.RELEASE]

url = jdbc:mysql://1.1.1.1:3306/xxx?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull

  • SOFATracer version: 2.2.0
  • JVM version (e.g. java -version):1.8

When use httpclient print log ,if server response blank can cause NPE.

Describe the bug

When server response is blank ,using HttpClient print log cause NPE

Expected behavior

When server response is blank, using HttpClient print log usually.

Actual behavior

java.lang.NullPointerException: null
    at com.alipay.sofa.tracer.plugins.httpclient.interceptor.AbstractHttpRequestInterceptor.appendHttpClientResponseSpanTags(AbstractHttpRequestInterceptor.java:95)
    at com.alipay.sofa.tracer.plugins.httpclient.interceptor.SofaTracerHttpInterceptor.process(SofaTracerHttpInterceptor.java:62)

Steps to reproduce

Using Spring MVC server code maybe like :

/**
     * Request http://localhost:8080/httpclient
     *
     */
    @RequestMapping(value = "/httpclient", method = RequestMethod.HEAD)
    @ResponseBody
    public void head() {
        // do nothing
    }

can support httpclient4.2 version

Whether you can support httpclient4.2 version, old projects may not be developed according to the version supported by sofa tracer.

service name error

The Zipkin service name displays the URL address, which should be the application name

统计日志设置的时间间隔参数未生效

Describe the bug

rpc-server-stat 和 rpc-client-stat日志在指定的interval间隔时间内未打印。

EnterpriseRpcSofaTracer 初始化在 SofaTracerAutoConfiguration 之前,导致前者未获取到配置项。

Typo: Deamon

Describe the bug

There is a class named TracerLogRootDeamon, Deamon should be Daemon

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

  • SOFATracer version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

SOFATracer remote report data to Zipkin version 2.1.X version problem

Describe the bug

  • 1.TraceId we print to disk and report to Zipkin length are not equal.Such as print disk is 0a0fe87a153519650379710017813 ,but in Zipkin

image

  • 2.SpanId and parentSpanId error. The parentSpanId in Zipkin version 2.1.X report is blank ,

image

If no parentSpanId the SOFATracer Link path will hava no layer.

Expected behavior

TraceId should be same and Zipkin view has the SOFATracer link path layer.

Actual behavior

TraceId not same and parentSpanId error.

Steps to reproduce

Can use such example

Provide a sampling functionality to tracer

Sometimes, report/print every tracing will consume a lot of resource, SOFATracer can add a sampling functionality so that SOFATracer don't have to report/print every tracing.

Dependency optimization

Describe the bug

SOFATracer project has multiple slf4j-api and slf4j adapter dependencies

Expected behavior

In project only has one GAV

Actual behavior

image

Steps to reproduce

mvn dependency:tree

Environment

  • SOFATracer version: 2.1.1
  • JVM version (e.g. java -version): JDK7/JDK8
  • Maven version:3.2.5

master分支下直接执行mvn clean install会报错

报错信息如下:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project tracer-core: Compilation failure
[ERROR] Annotation generator had thrown the exception. java.lang.NoClassDefFoundError: javax/annotation/Generated
[ERROR] at org.openjdk.jmh.generators.core.BenchmarkGenerator.generateImport(BenchmarkGenerator.java:601)
[ERROR] at org.openjdk.jmh.generators.core.BenchmarkGenerator.generateClass(BenchmarkGenerator.java:559)
[ERROR] at org.openjdk.jmh.generators.core.BenchmarkGenerator.generate(BenchmarkGenerator.java:120)
[ERROR] at org.openjdk.jmh.generators.BenchmarkProcessor.process(BenchmarkProcessor.java:58)
[ERROR] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:964)
[ERROR] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:881)
[ERROR] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2100(JavacProcessingEnvironment.java:110)
[ERROR] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1202)
[ERROR] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1311)
[ERROR] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1250)
[ERROR] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:928)
[ERROR] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
[ERROR] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
[ERROR] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
[ERROR] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
[ERROR] at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
[ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
[ERROR] at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
[ERROR] at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:152)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] Caused by: java.lang.ClassNotFoundException: javax.annotation.Generated
[ERROR] at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
[ERROR] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
[ERROR] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
[ERROR] ... 41 more

关于日志的疑问

1、“提供异步落地磁盘的日志打印能力”
——————-这个使用log4j2的AsyncLogger就可以搞定吧?为什么通过集成disruptor的源代码而不是依赖jar包的方式呢?

2、另外看到工程里的slf4j-api和slf4j-log4j有多个版本,感觉较乱。
image

Tracer dependency management

Tracer module dependency better, tracer-sofa-boot-starter can run in SOFABoot and Spring Boot。And also we can provide tracer-all depend on other tracer modules.Other components can only depend on tracer-all.

按照 readme 说明配置 com.alipay.sofa.tracer.zipkin.enabled 等后没有上报 zipkin

按照readme 的设置后,zipkin 没有收到日志信息,日志文件夹下也没生成 tracerlog。

application.properties

server.port=8880
spring.application.name=provider

# logging path
logging.path=c:\\logs
# enable zipkin
com.alipay.sofa.tracer.zipkin.enabled=true
# zipkin server url
com.alipay.sofa.tracer.zipkin.baseUrl=http://localhost:9411

pom.xml

<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demoprovider</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demoprovider</name>
    <description>Demo project for Spring Boot</description>

 <!--   <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
        <relativePath/> &lt;!&ndash; lookup parent from repository &ndash;&gt;
    </parent>-->
    <parent>
        <groupId>com.alipay.sofa</groupId>
        <artifactId>sofaboot-dependencies</artifactId>
        <version>2.3.1</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8
        </project.reporting.outputEncoding>
        <java.version>1.7</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>com.alipay.sofa</groupId>
            <artifactId>rpc-sofa-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.alipay.sofa</groupId>
            <artifactId>tracer-sofa-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin</artifactId>
            <version>1.19.2</version>
        </dependency>
        <dependency>
            <groupId>io.zipkin.reporter</groupId>
            <artifactId>zipkin-reporter</artifactId>
            <version>0.6.12</version>
        </dependency>
    </dependencies>

    <!--<build>-->
        <!--<plugins>-->
            <!--<plugin>-->
                <!--<groupId>org.springframework.boot</groupId>-->
                <!--<artifactId>spring-boot-maven-plugin</artifactId>-->
            <!--</plugin>-->
        <!--</plugins>-->
    <!--</build>-->
</project>

ZipkinSampleController.java

package com.example.demoprovider.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @author : liu.jf
 * @version : 1.0
 * @description :
 * @projectName : sofabootdemo
 * @createTime : 2018/6/7 16:25
 */
@RestController
public class ZipkinSampleController
{
	private static final String TEMPLATE = "Hello, %s!";

	private final AtomicLong counter  = new AtomicLong();

	/***
	 * http://localhost:8080/zipkin
	 * @param name name
	 * @return map
	 */
	@RequestMapping("/zipkin")
	public Map<String, Object> zipkin(@RequestParam(value = "name", defaultValue = "SOFATracer Zipkin Remote Report") String name) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("success", true);
		resultMap.put("id", counter.incrementAndGet());
		resultMap.put("content", String.format(TEMPLATE, name));
		return resultMap;
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.