开源apm zipkin工具简单使用

声明,本编博客,只是为了记录
架构
开源apm zipkin工具简单使用_第1张图片

流程走向

┌─────────────┐ ┌───────────────────────┐  ┌─────────────┐  ┌──────────────────┐
│ User Code   │ │ Trace Instrumentation │  │ Http Client │  │ Zipkin Collector │
└─────────────┘ └───────────────────────┘  └─────────────┘  └──────────────────┘
       │                 │                         │                 │
           ┌─────────┐
       │ ──┤GET /foo ├─▶ │ ────┐                   │                 │
           └─────────┘         │ record tags
       │                 │ ◀───┘                   │                 │
                           ────┐
       │                 │     │ add trace headers │                 │
                           ◀───┘
       │                 │ ────┐                   │                 │
                               │ record timestamp
       │                 │ ◀───┘                   │                 │
                             ┌─────────────────┐
       │                 │ ──┤GET /foo         ├─▶ │                 │
                             │X-B3-TraceId: aa │     ────┐
       │                 │   │X-B3-SpanId: 6b  │   │     │           │
                             └─────────────────┘         │ invoke
       │                 │                         │     │ request   │
                                                         │
       │                 │                         │     │           │
                                 ┌────────┐          ◀───┘
       │                 │ ◀─────┤200 OK  ├─────── │                 │
                           ────┐ └────────┘
       │                 │     │ record duration   │                 │
            ┌────────┐     ◀───┘
       │ ◀──┤200 OK  ├── │                         │                 │
            └────────┘       ┌────────────────────────────────┐
       │                 │ ──┤ asynchronously report span     ├────▶ │
                             │                                │
                             │{                               │
                             │  "traceId": "aa",              │
                             │  "id": "6b",                   │
                             │  "name": "get",                │
                             │  "timestamp": 1483945573944000,│
                             │  "duration": 386000,           │
                             │  "annotations": [              │
                             │--snip--                        │
                             └────────────────────────────────┘

组件
collector—从收集数据
storage–存储
search–搜索组建
web UI–UI页面
Instrumenting–负责收集数据,更多信息请参考existing_instrumentations

部署
可以通过docker-compose.yml 部署,这里就简单部署了

[root@i-vzdytl5t ~]# docker run -d -p 9411:9411 openzipkin/zipkin
Unable to find image 'openzipkin/zipkin:latest' locally
Trying to pull repository docker.io/openzipkin/zipkin ... 
latest: Pulling from docker.io/openzipkin/zipkin
ff3a5c916c92: Already exists 
a8906544047d: Already exists 
590b87a38029: Pull complete 
5a45314016bd: Pull complete 
596d597fd76a: Pull complete 
0ca7f3c515ee: Pull complete 
Digest: sha256:54d39fa30f23c1f27ccc64e62ad14e73237bdddb215d6935a1b2528e32242260
Status: Downloaded newer image for docker.io/openzipkin/zipkin:latest
307bd7e7843fca7410fbd1282f4fad1520284483759b6735dff096b071038c78
[root@i-vzdytl5t ~]# docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
307bd7e7843f        openzipkin/zipkin   "/bin/bash -c 'tes..."   27 minutes ago      Up 27 minutes       9410/tcp, 0.0.0.0:9411->9411/tcp   festive_chandrasekhar

访问http://your_host:9411
开源apm zipkin工具简单使用_第2张图片
安装成功,另外还支持二进制部署以及自己编译
二进制部署

curl -sSL https://zipkin.io/quickstart.sh | bash -s
java -jar zipkin.jar

自己编译

# get the latest source
git clone https://github.com/openzipkin/zipkin
cd zipkin
# Build the server and also make its dependencies
./mvnw -DskipTests --also-make -pl zipkin-server clean install
# Run the server
java -jar ./zipkin-server/target/zipkin-server-*exec.jar

如果用docker-compose 部署的话,里面也用到了prometheus的服务,内容如下

version: '2'

services:
  storage:
    image: openzipkin/zipkin-mysql
    container_name: mysql
    # Uncomment to expose the storage port for testing
    # ports:
    #   - 3306:3306

  # The zipkin process services the UI, and also exposes a POST endpoint that
  # instrumentation can send trace data to. Scribe is disabled by default.
  zipkin:
    image: openzipkin/zipkin
    container_name: zipkin
    # Environment settings are defined here https://github.com/openzipkin/zipkin/tree/1.19.0/zipkin-server#environment-variables
    environment:
      - STORAGE_TYPE=mysql
      # Point the zipkin at the storage backend
      - MYSQL_HOST=mysql
      # Uncomment to enable scribe
      # - SCRIBE_ENABLED=true
      # Uncomment to enable self-tracing
      # - SELF_TRACING_ENABLED=true
      # Uncomment to enable debug logging
      # - JAVA_OPTS=-Dlogging.level.zipkin=DEBUG -Dlogging.level.zipkin2=DEBUG
    ports:
      # Port used for the Zipkin UI and HTTP Api
      - 9411:9411
      # Uncomment if you set SCRIBE_ENABLED=true
      # - 9410:9410
    depends_on:
      - storage

  # Adds a cron to process spans since midnight every hour, and all spans each day
  # This data is served by http://192.168.99.100:8080/dependency
  #
  # For more details, see https://github.com/openzipkin/docker-zipkin-dependencies
  dependencies:
    image: openzipkin/zipkin-dependencies
    container_name: dependencies
    entrypoint: crond -f
    environment:
      - STORAGE_TYPE=mysql
      - MYSQL_HOST=mysql
      # Add the baked-in username and password for the zipkin-mysql image
      - MYSQL_USER=zipkin
      - MYSQL_PASS=zipkin
      # Uncomment to see dependency processing logs
      # - ZIPKIN_LOG_LEVEL=DEBUG
      # Uncomment to adjust memory used by the dependencies job
      # - JAVA_OPTS=-verbose:gc -Xms1G -Xmx1G
    depends_on:
      - storage

  prometheus:
    image: prom/prometheus
    container_name: prometheus
    ports:
      - 9090:9090
    depends_on:
      - storage
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml

  grafana:
    image: grafana/grafana
    container_name: grafana
    ports:
      - 3000:3000
    depends_on:
      - prometheus
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin

  setup_grafana_datasource:
    image: appropriate/curl
    container_name: setup_grafana_datasource
    depends_on:
      - grafana
    volumes:
      - ./prometheus/create-datasource-and-dashboard.sh:/create.sh:ro
    command: /create.sh

需要在节点上部署对应语言的
比如golang的,就可以参考example_httpserver_test

目前zipkin支持一下语言,更多信息请参考existing_instrumentations

C#  
Go  
Java    
JavaScript  
Ruby    
Scala   

参考:
existing_instrumentations
quickstart

你可能感兴趣的:(pinpoint)