开发者社区 > 通义灵码 > 正文

通义灵码输出死循环bug记录

我提问:如果系统使用tcp服务调用,Zipkin可以用追踪链路吗

灵码的回复:

当系统使用 TCP 服务调用时,传统的基于 HTTP 的分布式追踪工具(如 Zipkin 或 Jaeger)可能无法直接支持 TCP 调用的追踪。但是,可以通过一些方法来扩展和自定义追踪工具,使其能够支持 TCP 服务调用。
解决方案
自定义 Span 生成
手动记录 Span 数据
详细步骤

  1. 自定义 Span 生成
    在每个服务中手动生成和记录 Span 数据,并将其发送到 Zipkin 服务器。
  2. 手动记录 Span 数据
    在每个服务中添加代码来记录 Span 数据。
    示例代码
    假设你有三个服务:柜面系统(FrontendService)、存款系统(DepositService)和会计系统(AccountingService),并且它们之间通过 TCP 进行通信。
    定义 Span 生成器
    首先,定义一个简单的 Span 生成器类:

import brave.Span;
import brave.Tracer;
import brave.handler.FinishedSpanHandler;
import brave.propagation.TraceContext;
import brave.propagation.TraceContext.Extractor;
import brave.propagation.TraceContext.Injector;
import brave.propagation.TraceContextOrSamplingFlags;
import brave.propagation.TraceContextOrSamplingFlagsParser;
import brave.propagation.TraceContextOrSamplingFlagsParser.Parser;
import brave.sampler.Sampler;
import brave.sampler.SamplerFunction;
import brave.spring.webmvc.SpanCustomizer;
import brave.spring.webmvc.TracingHandlerInterceptor;
import brave.spring.webmvc.TracingHandlerInterceptorAutoConfiguration;
import brave.spring.webmvc.TracingWebAutoConfiguration;
import brave.spring.webmvc.config.TracingAutoConfiguration;
import brave.spring.webmvc.config.TracingWebMvcAutoConfiguration;
import brave.spring.webmvc.filter.TracingFilterAutoConfiguration;
import brave.spring.webmvc.servlet.TracingServletAutoConfiguration;
import brave.spring.webmvc.servlet.TracingServletConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBean;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapter;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerConfigurerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerConfigurerConfigurerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerConfigurerConfigurerConfigurerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerConfigurerConfigurerConfigurerConfigurerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerAdapterConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurerConfigurer;
import brave.spring.webmvc.servlet.TracingServletRegistrationBeanCustomizerConfigurerAdapter

然后一直输出import

展开
收起
1299493925908472 2024-09-12 16:08:51 43 0
0 条回答
写回答
取消 提交回答
问答分类:
问答标签:
问答地址:

通义灵码是基于通义大模型的 AI 研发辅助工具,提供代码生成、研发问答、任务执行等能力,为开发者带来智能化研发体验,引领 AI 原生研发新范式。通义灵码包含 AI 编码助手和 AI 程序员。

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载