西维蜀黍

【Golang】Linters

Go Focused

  • GolangCI - Open Source SaaS service for running linters on Github pull requests. Free for Open Source.

  • Go Report Card - Go repo report card.

  ...


【Golang】Test - Unit Test - Testify

assert package

The assert package provides some helpful methods that allow you to write better test code in Go.

  • Prints friendly, easy to read failure descriptions
  • Allows for very readable code
  • Optionally annotate each assertion with a message
  ...


【Golang】Test - Unit Test

Unit Tests

Typically, the code we’re testing would be in a source file named something like intutils.go, and the test file for it would then be named intutils_test.go.

  ...


【Prometheus】Built-in Functions

rate() - per-second average rate

rate(v range-vector) calculates the per-second average rate of increase of the time series in the range vector(每秒增量的平均值).

Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for.

  • Also, the calculation extrapolates to the ends of the time range, allowing for missed scrapes or imperfect alignment of scrape cycles with the range’s time period.

The following example expression returns the per-second rate of HTTP requests as measured over the last 5 minutes, per time series in the range vector:

rate(http_requests_total{job="api-server"}[5m])
  ...


【Prometheus】Counter

  ...