ZipkinServer存储Cassandra数据分析

接着上篇我们来分析一下存储在cassandra的数据结构。

对cassandra不了解的可以看我cassandra的博客 cassandra博客目录

上一篇博客地址微服务应用开发进阶①链路追踪Zipkin

数据简述

ZipkinServer存储方式选择Cassandra3,指定相应的keyspace,我们可以看到有五张表。

  --STORAGE_TYPE=cassandra3
  • select * from autocomplete_tags; 
  • select * from dependency; 
  • select * from span; 
  • select * from span_by_service; 
  • select * from trace_by_service_span; 

autocomplete_tags: 找到半天找到一份说明,用来压测cassandra的表(浪费时间。。)

dependency:如图明显可以看到是保存依赖关系的一张表

 

 

 

span:zipkin基本的存储单元,包含一次请求的信息

annotations_query  字段类型text  请求的基本信息

http.method░http.method=POST
░http.path░http.path=/demo/servicea/person/save░mvc.controller.class░mvc.controller.class=PersonController░mvc.controller.method░mvc.controller.method=save░

Kind: 字段类型text server还是client;

l_ep和 e_ep :服务名和Ip等,示例如下

 {service:'service-a',ipv4:'192.168.56.1',ipv6:NULL,port:0}   {service:NULL,ipv4:'127.0.0.1',ipv6:NULL,port:58397} 

I_service 字段类型 text serviceName

tag 字段类型 map<text,text>  具体执行信息

 

span_by_service:serviceName和方法的信息

 

trace_by_service_span:tracle和service的信息

 

贴一份es的完整的span信息参考(网上找的,侵删):

{
  "_index": "zipkin:span-2018-08-07",
  "_type": "span",
  "_id": "AWUSkiT_lG0UQ3Osck2S",
  "_version": 1,
  "_score": 1,
  "_source": {
    "traceId": "6c3c748ff257f23b",
    "duration": 2928879,
    "localEndpoint": {
      "ipv4": "10.208.204.119",
      "port": 7900,
      "serviceName": "sleuthconsumer"
    },
    "timestamp_millis": 1533614872966,
    "kind": "SERVER",
    "name": "http:/consumer",
    "id": "6c3c748ff257f23b",
    "timestamp": 1533614872966000,
    "parentId": "6c3c748ff257f23b",
    "tags": {
      "mvc.controller.class": "HomeController",
      "mvc.controller.method": "service1",
      "lc": "hystrix",
      "spring.instance_id": "DESKTOP-CBSVPL2:sleuthConsumer:7900",
      "thread": "hystrix-sleuthConsumer2-1"
    }
  }
}

简单分析 

查询一个完整的链路发现(serviceb调用servicea),一次服务B调用服务A,产生了三个span;

第一次服务B作为服务端,被调用接口

第二次服务B作为客户端,调用A的接口

第三次服务A作为服务端,被服务B调用

所以servicec调用servicea,kafka有两条消息,servicec发送了两条消息

其他

如果不小心存储到了低版本的cassandra中,那么keyspace里面有8张表;不小心存错了一次,简述如下:

## 总共8张表
select * from annotations_index;   // 
select * from autocomplete_tags;
https://github.com/openzipkin/zipkin/blob/master/zipkin-storage/cassandra/src/test/resources/autocomplete_tags-stress.yaml
select * from dependencies;  // 应该就是依赖分析了
select * from service_name_index;// serviceName和bucket、traceId
select * from service_names; // 存储服务名serverName
select * from service_span_name_index; //服务方法和traceId
select * from span_names; // 服务名和服务方法
select * from traces; // trace信息

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Spring Boot中配置HikariCP连接池连接到Cassandra数据源的步骤如下: 1. 添加HikariCP和Cassandra驱动程序的Maven依赖: ``` <dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> <version>3.4.5</version> </dependency> <dependency> <groupId>com.datastax.oss</groupId> <artifactId>java-driver-core</artifactId> <version>4.11.0</version> </dependency> ``` 2. 在application.properties或application.yml文件中配置Cassandra数据源和HikariCP连接池: ``` spring.data.cassandra.contact-points=127.0.0.1 spring.data.cassandra.port=9042 spring.data.cassandra.keyspace-name=mykeyspace spring.datasource.hikari.maximum-pool-size=10 spring.datasource.hikari.connection-timeout=30000 spring.datasource.hikari.idle-timeout=600000 ``` 3. 在Spring Boot应用程序的@Configuration类中创建CassandraSession和DataSource bean: ``` @Configuration public class CassandraConfig { @Autowired private Environment env; @Bean public CqlSession cqlSession() { return CqlSession.builder() .addContactPoint(new InetSocketAddress(env.getProperty("spring.data.cassandra.contact-points"), Integer.parseInt(env.getProperty("spring.data.cassandra.port")))) .withKeyspace(env.getProperty("spring.data.cassandra.keyspace-name")) .build(); } @Bean public DataSource dataSource() { HikariDataSource dataSource = new HikariDataSource(); dataSource.setJdbcUrl("jdbc:cassandra://" + env.getProperty("spring.data.cassandra.contact-points") + ":" + env.getProperty("spring.data.cassandra.port") + "/" + env.getProperty("spring.data.cassandra.keyspace-name")); dataSource.setUsername(env.getProperty("spring.data.cassandra.username")); dataSource.setPassword(env.getProperty("spring.data.cassandra.password")); return dataSource; } } ``` 这样,你就可以使用HikariCP连接池连接到Cassandra数据源了。可以在Spring Boot应用程序中注入CqlSession和DataSource bean来执行Cassandra查询和操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值