use of com.megaease.easeagent.plugin.report.tracing.ReportSpan in project easeagent by megaease.
the class KafkaMessageListenerTracingInterceptorTest method doAfter.
@Test
public void doAfter() {
KafkaMessageListenerTracingInterceptor interceptor = new KafkaMessageListenerTracingInterceptor();
Context context = EaseAgent.getContext();
MockEaseAgent.cleanLastSpan();
interceptor.doAfter(null, context);
assertNull(MockEaseAgent.getLastSpan());
Span span = context.nextSpan().start();
context.put(KafkaMessageListenerTracingInterceptor.SPAN, span);
MethodInfo methodInfo = MethodInfo.builder().build();
interceptor.doAfter(methodInfo, context);
ReportSpan mockSpan = MockEaseAgent.getLastSpan();
SpanTestUtils.sameId(span, mockSpan);
String errorInfo = "test error";
methodInfo = MethodInfo.builder().throwable(new RuntimeException(errorInfo)).build();
span = context.nextSpan().start();
context.put(KafkaMessageListenerTracingInterceptor.SPAN, span);
interceptor.doAfter(methodInfo, context);
mockSpan = MockEaseAgent.getLastSpan();
SpanTestUtils.sameId(span, mockSpan);
assertTrue(mockSpan.tags().containsKey("error"));
assertEquals(errorInfo, mockSpan.tags().get("error"));
}
use of com.megaease.easeagent.plugin.report.tracing.ReportSpan in project easeagent by megaease.
the class SpanImplTest method flush.
@Test
public void flush() {
Span eSpan = SpanImpl.build(tracing, tracing.tracer().nextSpan(), injector);
eSpan.start();
eSpan.flush();
assertNull(MockReport.getLastSpan());
assertNotNull(MockReport.getLastSkipSpan());
ReportSpan reportSpan = MockReport.getLastSkipSpan();
Assert.assertNotNull(reportSpan);
assertEquals(eSpan.traceIdString(), reportSpan.traceId());
assertEquals(eSpan.spanIdString(), reportSpan.id());
}
use of com.megaease.easeagent.plugin.report.tracing.ReportSpan in project easeagent by megaease.
the class ConvertSpanReporter method report.
@Override
public void report(MutableSpan span) {
maybeAddErrorTag(span);
ReportSpan converted = convert(span);
delegate.report(converted);
}
use of com.megaease.easeagent.plugin.report.tracing.ReportSpan in project easeagent by megaease.
the class TracingProviderImpl method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
ThreadLocalCurrentTraceContext traceContext = ThreadLocalCurrentTraceContext.newBuilder().addScopeDecorator(AgentMDCScopeDecorator.get()).addScopeDecorator(AgentMDCScopeDecorator.getV2()).addScopeDecorator(AgentMDCScopeDecorator.getAgentDecorator()).build();
serviceName = new AutoRefreshConfigItem<>(config, ConfigConst.SERVICE_NAME, Config::getString);
/*
String target = config.getString("observability.tracings.output.target");
String zipkinUrl = config.getString("observability.tracings.output.target.zipkinUrl");
Boolean compressionEnabled = config.getBoolean("observability.tracings.output.target.zipkin.compressionEnabled");
boolean toZipkin = false;
if (target != null && target.equalsIgnoreCase("zipkin") && StringUtils.isNotEmpty(zipkinUrl)) {
toZipkin = true;
}
String zipkinUrlFromEnv = System.getenv(ENV_ZIPKIN_SERVER_URL);
if (StringUtils.isNotEmpty(zipkinUrlFromEnv)) {
toZipkin = true;
zipkinUrl = zipkinUrlFromEnv;
}
Reporter<Span> reporter;
if (toZipkin) {
reporter = AsyncReporter.create(URLConnectionSender.newBuilder()
.endpoint(zipkinUrl)
.compressionEnabled(compressionEnabled == null || compressionEnabled).build());
} else {
reporter = span -> agentReport.report(span);
}
*/
Reporter<ReportSpan> reporter;
reporter = span -> agentReport.report(span);
this.tracing = Tracing.newBuilder().localServiceName(getServiceName()).traceId128Bit(false).sampler(CountingSampler.create(1)).addSpanHandler(new CustomTagsSpanHandler(this::getServiceName, AdditionalAttributes.getHostName())).addSpanHandler(ConvertZipkinSpanHandler.builder(reporter).alwaysReportSpans(true).build()).currentTraceContext(traceContext).build();
}
use of com.megaease.easeagent.plugin.report.tracing.ReportSpan in project easeagent by megaease.
the class TraceReport method initSpanRefreshableReporter.
private RefreshableReporter<ReportSpan> initSpanRefreshableReporter(Config configs) {
SenderWithEncoder sender = ReporterRegistry.getSender(ReportConfigConst.TRACE_SENDER, configs);
TraceAsyncProps traceProperties = TraceAsyncProps.newDefault(configs);
GlobalExtrasSupplier extrasSupplier = new GlobalExtrasSupplier() {
final AutoRefreshConfigItem<String> serviceName = new AutoRefreshConfigItem<>(configs, ConfigConst.SERVICE_NAME, Config::getString);
final AutoRefreshConfigItem<String> systemName = new AutoRefreshConfigItem<>(configs, ConfigConst.SYSTEM_NAME, Config::getString);
@Override
public String service() {
return serviceName.getValue();
}
@Override
public String system() {
return systemName.getValue();
}
};
SDKAsyncReporter<ReportSpan> reporter = SDKAsyncReporter.builderSDKAsyncReporter(sender, traceProperties, extrasSupplier);
reporter.startFlushThread();
return new RefreshableReporter<>(reporter, traceProperties);
}
Aggregations