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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2021-09-11 dremio v18.0 软件包可以使用了
2019-09-11 kuma 学习四 策略
2019-09-11 kuma 学习三 组件说明
2019-09-11 kuma 学习二 centos 安装
2019-09-11 Load Testing Socket.IO Web Applications and Infrastructure
2019-09-11 artillery 学习一 简单使用
2019-09-11 kuma 学习一 minikube 安装