首页 技术 正文
技术 2022年11月21日
0 收藏 755 点赞 4,946 浏览 1709 个字

测试使用docker 部署

docker-compose文件

注意网络模型选择的host,同时配置了opentracing 服务

version: "3"
services:
  bblfsh:
    image: bblfsh/bblfshd
    privileged: true
    environment:
    - "JAEGER_AGENT_HOST=localhost"
    - "JAEGER_AGENT_PORT=6831"
    - "JAEGER_SAMPLER_TYPE=const"
    - "JAEGER_SAMPLER_PARAM=1"
    network_mode: "host"
    ports:
    - "9432:9432"
    volumes:
    - "/var/lib/bblfshd:/var/lib/bblfshd"
    - "/var/run/docker.sock:/var/run/docker.sock"
  jaeger:
    image: jaegertracing/all-in-one:1.8
    ports:
    - "5775:5775/udp"
    - "6831:6831/udp"
    - "6832:6832/udp"
    - "5778:5778"
    - "16686:16686"
    - "14268:14268"
    - "9411:9411"

  

安装驱动

对于语言解析处理的docker 镜像,inside 容器,为了简单,添加的只有golang 的
如果网络比较好的话,可以安装所有的,使用--all参数,或者推荐的 --recommended

 

bblfshctl driver install docker://bblfsh/go-driver:latest

解析 golang 语言

inside 容器,因为按照其他语言的驱动有点慢,所以自己copy 一个golang 代码文件到容器,同时
只安装了简单的golang driver

  • 准备golang 代码
    main.go

 

package main
import "fmt"
func main() {
 fmt.Println("demoapp")
}

  

拷贝文件
注意修改为自己的容器id

<wiz_code_mirror>

     

docker cp main.go 4116cc1ee650:/opt/

  

  • 指定解析
bblfshctl parse /opt/main.go
  • 生成的代码ast 解析
    比较多,保留部分

 

Status: Ok
Elapsed: 1.099302113s
Module {
. Roles: File,Module
. Children: {
. . 0: Expr {
. . . Roles: Expression
. . . StartPosition: {
. . . . Offset: 0
. . . . Line: 1
. . . . Col: 1
. . . }
. . . Properties: {
. . . . internalRole: body
. . . }
. . . Children: {
. . . . 0: Call {
. . . . . Roles: Function,Call,Expression
. . . . . StartPosition: {
. . . . . . Offset: 0
. . . . . . Line: 1
. . . . . . Col: 1
. . . . . }
. . . . . Properties: {
. . . . . . internalRole: value
. . . . . }
. . . . . Children: {
. . . . . . 0: Name {
. . . . . . . Roles: Identifier,Expression,Call,Callee
. . . . . . . TOKEN "print"
. . . . . . . StartPosition: {
. . . . . . . . Offset: 0
. . . . . . . . Line: 1
. . . . . . . . Col: 1
. . . . . . . }
。。。。

  

  • opentracing 统计分析
    不同driver 的请求
    Babelfish 基本试用
    golang 解析的请求链路
    Babelfish 基本试用

说明

Babelfish 的功能很强大, 对于我们分析代码是很方便的,同时生产环境,建议的方式是使用client 调用grpc 服务,同时官方也提供了
一个web 的dashboard ,方便我们测试
Babelfish 基本试用

参考资料

https://doc.bblf.sh/using-babelfish/advanced-usage.html

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,078
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,553
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,402
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,177
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,814
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898