• parca 简单试用


    parca 支持多种模式的数据ingestion 以下测试下基于pull 模式的

    数据ingestion 模式

    参考图

    环境准备

    • docker-compose.yaml
     
    version: '3'
    services:
      app:
        build: ./
        ports:
        - "3000:3000"
      parca:
        image: ghcr.io/parca-dev/parca:v0.12.1
        command: /parca --config-path=/opt/parca.yaml
        ports:
        - "7070:7070"
        volumes:
        - "./parca.yaml:/opt/parca.yaml"

    parca 配置

    debug_info:
      bucket:
        type: "FILESYSTEM"
        config:
          directory: "./tmp"
      cache:
        type: "FILESYSTEM"
        config:
          directory: "./tmp"
     
    scrape_configs:
      - job_name: "default"
        scrape_interval: "2s"
        static_configs:
          - targets: ["127.0.0.1:7070"]
      - job_name: "myapp"
        scrape_interval: "2s"
        static_configs:
          - targets: ["app:3000"]
    • app dockerfile
    FROM golang:1.19-alpine3.16 AS build-env
    WORKDIR /go/src/app
    RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
     
    ENV  GO111MODULE=on
    ENV  GOPROXY=https://goproxy.cn
    COPY . .
    RUN apk update && apk add git \
        && go build -o app
     
    FROM alpine:latest
    WORKDIR /app
    RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
    RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
    COPY --from=build-env /go/src/app/app /app/app
    EXPOSE 3000
    CMD ["/app/app"]

    app.go

    package main
     
    import (
        "log"
        "net/http"
        "net/http/pprof"
    )
     
    func main() {
        mux := http.NewServeMux()
        mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
            w.Header().Add("dalong", "app")
            w.Write([]byte("dalongdemo"))
        })
        mux.HandleFunc("/debug/pprof/", pprof.Index)
        mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
        mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
        mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
        mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
        log.Fatal(http.ListenAndServe("0.0.0.0:3000", mux))
    }

    运行&效果

    • 启动
    docker-compose up -d 
    • 效果

    target


    查询


    调用链

    说明

    以上是基于pull 模式的使用,实际上对于golang 应用我们是可以拿来即用的,还是比较方便的,后续深入研究下

    参考资料

    https://github.com/rongfengliang/parca-docker-compose-learning
    https://www.parca.dev/docs/instrumenting-go
    https://github.com/parca-dev/parca
    https://github.com/parca-dev/parca-agent

  • 相关阅读:
    在请求中使用XML Publisher生成文件报错
    Oracle Sourcing Implementation and Administration Guide(转)
    API To Import Negotiations(转)
    使用POI动态更新导出的EXCEL模板中的列
    使用POI设置导出的EXCEL锁定指定的单元格
    QML获取随机颜色
    Access导出excel
    Component
    QML中打印
    Qt Quick Dialogs
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/16685125.html
Copyright © 2020-2023  润新知