go-graphite / go-carbon

Golang implementation of Graphite/Carbon server with classic architecture: Agent -> Cache -> Persister
MIT License
801 stars 126 forks source link

[Q]How to build local version in order to investigate? #582

Open interfan7 opened 3 months ago

interfan7 commented 3 months ago

I need the ability to build locally in order to debug and investigate a query which takes very long.

I'm not too familiar with Go and have zero experience with building it. Preferably I want to build in Mac and the target shall be a Linux Ubuntu machine. Are there instructions to start?

What to investigate? I've a case of a query which doesn't complete even in 2 minutes, even though CPU usage and IO disks counters don't seem to reach the limits. That query shall return almost 80K metrics (Whisper files).
I want to start by inserting my own log lines to track down and pin-point what takes so long, is it really about reading datapoints from Whisper files?

deniszh commented 3 months ago
  1. Install make and golang on mac, e.g. with manual on https://go.dev/doc/install
  2. cd to project directory and run
    make clean && make

    It will print you a build command, like

    go build -mod vendor --ldflags '-X main.BuildVersion=v0.17.3-7-g1159' github.com/go-graphite/go-carbon

    and produce go-carbon binary in current directory.

    $ file go-carbon
    go-carbon: Mach-O 64-bit executable arm64
  3. Remove go-carbon binary and prepend go command above with flags to build linux binary (GOOS=linux GOARCH=amd64) instead:
    GOOS=linux GOARCH=amd64 go build -mod vendor --ldflags '-X main.BuildVersion=v0.17.3-7-g1159' github.com/go-graphite/go-carbon

    Now you have linux binary instead:

    $ file go-carbon
    go-carbon: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=... with debug_info, not stripped
interfan7 commented 3 months ago

@deniszh I think the explenation just couldn't be any better!! 👏🏻🙏🏻