Skip to content

Commit

Permalink
Merge pull request #26 from f100024/bump-version-0.3.6
Browse files Browse the repository at this point in the history
Bump version 0.3.6
  • Loading branch information
f100024 authored Oct 27, 2023
2 parents 7f940fd + 56bdc61 commit 2d3249f
Show file tree
Hide file tree
Showing 18 changed files with 1,203 additions and 1,333 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ vendor/
.vscode/
.build/
.tarballs/
target/

# App binary
syncthing_exporter
4 changes: 3 additions & 1 deletion .promu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
verbose: true
go:
version: 1.20
version: 1.21
cgo: false
repository:
path: github.com/f100024/syncthing_exporter
Expand Down Expand Up @@ -46,6 +46,7 @@ crossbuild:
- linux/mipsle
- linux/ppc64
- linux/ppc64le
- linux/riscv64
- linux/s390x
- netbsd/386
- netbsd/amd64
Expand All @@ -58,3 +59,4 @@ crossbuild:
- openbsd/armv7
- windows/386
- windows/amd64
- windows/arm64
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.3.6 / 2023-10-27
---
* Fixed bug (#25) node reporting down
* Updated Grafana Dashboard example
* Added linux/riscv64 build
* Switched to go1.21
* Updated dependencies
## 0.3.5 / 2023-06-08
---
* Switched to go1.20
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20 as builder
FROM golang:1.21 as builder
COPY . /builddir
WORKDIR /builddir

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

GO := go
PROMU := $(GOPATH)/bin/promu
PROMU_VERSION := 0.14.0
PROMU_VERSION := 0.15.0
PKGS = $(shell $(GO) list ./... | grep -v /vendor/)
PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.5
0.3.6
4 changes: 2 additions & 2 deletions collector/rest_db_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"
"net/url"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down
4 changes: 2 additions & 2 deletions collector/rest_db_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package collector

import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"os"
"strings"
"testing"

Expand All @@ -15,7 +15,7 @@ import (

func TestNewDBStatusReport(t *testing.T) {

jsonResponse, _ := ioutil.ReadFile("fixtures/rest_db_status_response.json")
jsonResponse, _ := os.ReadFile("fixtures/rest_db_status_response.json")

ts := httptest.NewTLSServer(
http.HandlerFunc(
Expand Down
4 changes: 2 additions & 2 deletions collector/rest_stats_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"net/url"
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down
6 changes: 3 additions & 3 deletions collector/rest_stats_device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package collector

import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"os"
"strings"
"testing"

Expand All @@ -15,7 +15,7 @@ import (

func TestNewStatsDeviceReport(t *testing.T) {

jsonResponse, _ := ioutil.ReadFile("fixtures/rest_stats_device_response.json")
jsonResponse, _ := os.ReadFile("fixtures/rest_stats_device_response.json")

ts := httptest.NewTLSServer(
http.HandlerFunc(
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestNewStatsDeviceReport(t *testing.T) {

func TestStatsDeviceReportWithNoLastConnectionDuration(t *testing.T) {

jsonResponse, _ := ioutil.ReadFile("fixtures/rest_stats_device_response_missed_lastConnectionDurationS.json")
jsonResponse, _ := os.ReadFile("fixtures/rest_stats_device_response_missed_lastConnectionDurationS.json")

ts := httptest.NewTLSServer(
http.HandlerFunc(
Expand Down
10 changes: 4 additions & 6 deletions collector/rest_svc_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"
"net/url"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/syncthing/syncthing/lib/ur/contract"
)
Expand Down Expand Up @@ -172,10 +172,8 @@ func NewSVCReport(logger log.Logger, client *http.Client, url *url.URL, token *s
nil,
),
Value: func(svcData *contract.Report) float64 {
if svcData.UniqueID != "" {
return float64(1)
}
return float64(0)
// Leave this parameter for backward compatibility with versions < v0.3.0 of grafana dashboards
return float64(1)
},
},
}
Expand Down
39 changes: 32 additions & 7 deletions collector/rest_svc_report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package collector

import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"os"
"strings"
"testing"

Expand All @@ -15,7 +15,7 @@ import (

func TestNewSVCReport(t *testing.T) {

jsonResponse, _ := ioutil.ReadFile("fixtures/rest_svc_report_response.json")
jsonResponse, _ := os.ReadFile("fixtures/rest_svc_report_response.json")

ts := httptest.NewTLSServer(
http.HandlerFunc(
Expand All @@ -26,10 +26,7 @@ func TestNewSVCReport(t *testing.T) {
)
defer ts.Close()

u, err := url.Parse(ts.URL)
if err != nil {
t.Errorf("url parse error: %s", err)
}
u, _ := url.Parse(ts.URL)

promlogConfig := &promlog.Config{}
logger := promlog.New(promlogConfig)
Expand Down Expand Up @@ -80,7 +77,35 @@ func TestNewSVCReport(t *testing.T) {
syncthing_rest_svc_report_uptime 1.276967e+06
`

err = testutil.CollectAndCompare(
err := testutil.CollectAndCompare(
NewSVCReport(logger, HttpClient, u, &testToken),
strings.NewReader(expected),
)

if err != nil {
t.Errorf("NewSVCReportError %s", err)
}
}

func TestFailedNewSVCReport(t *testing.T) {

u, _ := url.Parse("http://wrong-url")
promlogConfig := &promlog.Config{}
logger := promlog.New(promlogConfig)

testToken := "12345"
expected := `
# HELP syncthing_rest_svc_report_json_parse_failures Number of errors while parsing JSON.
# TYPE syncthing_rest_svc_report_json_parse_failures counter
syncthing_rest_svc_report_json_parse_failures 0
# HELP syncthing_rest_svc_report_total_scrapes Current total Syncthings scrapes.
# TYPE syncthing_rest_svc_report_total_scrapes counter
syncthing_rest_svc_report_total_scrapes 1
# HELP syncthing_rest_svc_report_up Was the last scrape of the Syncthing endpoint successful.
# TYPE syncthing_rest_svc_report_up gauge
syncthing_rest_svc_report_up 0
`
err := testutil.CollectAndCompare(
NewSVCReport(logger, HttpClient, u, &testToken),
strings.NewReader(expected),
)
Expand Down
4 changes: 2 additions & 2 deletions collector/rest_system_connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"
"net/url"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down
4 changes: 2 additions & 2 deletions collector/rest_system_connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package collector

import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"os"
"strings"
"testing"

Expand All @@ -15,7 +15,7 @@ import (

func TestNewSCReport(t *testing.T) {

jsonResponse, err := ioutil.ReadFile("fixtures/rest_system_connections_response.json")
jsonResponse, err := os.ReadFile("fixtures/rest_system_connections_response.json")
if err != nil {
t.Error("Cant open fixtures file")
}
Expand Down
Loading

0 comments on commit 2d3249f

Please sign in to comment.