Skip to content

Commit

Permalink
Merge pull request hellofresh#59 from hellofresh/patch/otel-0.20
Browse files Browse the repository at this point in the history
Updated OpenTelementry to the current latest version
  • Loading branch information
vgarvardt authored May 14, 2021
2 parents df79b49 + 3a3a74c commit 38c762a
Showing 12 changed files with 77 additions and 26 deletions.
26 changes: 12 additions & 14 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -17,16 +17,12 @@ jobs:
- name: Check out code
uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
with:
version: v1.33
uses: golangci/golangci-lint-action@v2

test:
name: Test
runs-on: ubuntu-latest
needs: [lint]
needs: [ lint ]

services:
pg-pq:
@@ -62,6 +58,11 @@ jobs:
ports:
- "5672"
- "15672"
options: >-
--health-cmd "rabbitmqctl status"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:3.2-alpine
@@ -77,6 +78,11 @@ jobs:
image: mongo:3
ports:
- "27017"
options: >-
--health-cmd "mongo localhost:27017/test --quiet --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:5.7
@@ -105,7 +111,6 @@ jobs:
ports:
- "11211"


steps:
- name: Set up Go
uses: actions/setup-go@v2
@@ -124,10 +129,3 @@ jobs:
HEALTH_GO_MS_DSN: test:test@tcp(localhost:${{ job.services.mysql.ports[3306] }})/test?charset=utf8
HEALTH_GO_HTTP_URL: http://localhost:${{ job.services.http.ports[8080] }}/status
HEALTH_GO_MD_DSN: memcached://localhost:${{ job.services.memcached.ports[11211] }}/

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
if: success()
with:
file: ./coverage.txt
fail_ci_if_error: false
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# health-go
[![Go Report Card](https://goreportcard.com/badge/github.com/hellofresh/health-go)](https://goreportcard.com/report/github.com/hellofresh/health-go)
[![Go Doc](https://godoc.org/github.com/hellofresh/health-go?status.svg)](https://godoc.org/github.com/hellofresh/health-go)
[![Coverage Status](https://codecov.io/gh/hellofresh/health-go/branch/master/graph/badge.svg)](https://codecov.io/gh/hellofresh/health-go)

* Exposes an HTTP handler that retrieves health status of the application
* Implements some generic checkers for the following services:
@@ -18,7 +17,8 @@

The library exports `Handler` and `HandlerFunc` functions which are fully compatible with `net/http`.

Additionally, library exports `Measure` function that returns summary status for all the registered health checks, so it can be used in non-HTTP environments.
Additionally, library exports `Measure` function that returns summary status for all the registered health checks,
so it can be used in non-HTTP environments.

### Handler

4 changes: 4 additions & 0 deletions checks/http/check_test.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package http
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
@@ -25,5 +26,8 @@ func getURL(t *testing.T) string {
httpURL, ok := os.LookupEnv(httpURLEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
httpURL = strings.Replace(httpURL, "0.0.0.0:", "127.0.0.1:", 1)

return httpURL
}
4 changes: 4 additions & 0 deletions checks/mongo/check_test.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package mongo
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
@@ -25,5 +26,8 @@ func getDSN(t *testing.T) string {
mongoDSN, ok := os.LookupEnv(mgDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
mongoDSN = strings.Replace(mongoDSN, "0.0.0.0:", "127.0.0.1:", 1)

return mongoDSN
}
4 changes: 4 additions & 0 deletions checks/mysql/check_test.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"os"
"strings"
"sync"
"testing"
"time"
@@ -72,6 +73,9 @@ func getDSN(t *testing.T) string {
mysqlDSN, ok := os.LookupEnv(mysqlDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
mysqlDSN = strings.Replace(mysqlDSN, "0.0.0.0:", "127.0.0.1:", 1)

return mysqlDSN
}

4 changes: 4 additions & 0 deletions checks/postgres/check_test.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"os"
"strings"
"sync"
"testing"
"time"
@@ -69,6 +70,9 @@ func getDSN(t *testing.T) string {
pgDSN, ok := os.LookupEnv(pgDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
pgDSN = strings.Replace(pgDSN, "0.0.0.0:", "127.0.0.1:", 1)

return pgDSN
}

4 changes: 4 additions & 0 deletions checks/rabbitmq/aliveness_check_test.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package rabbitmq
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
@@ -27,5 +28,8 @@ func getURL(t *testing.T) string {
httpURL, ok := os.LookupEnv(httpURLEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
httpURL = strings.Replace(httpURL, "0.0.0.0:", "127.0.0.1:", 1)

return httpURL
}
4 changes: 4 additions & 0 deletions checks/rabbitmq/check_test.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package rabbitmq
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/assert"
@@ -37,5 +38,8 @@ func getDSN(t *testing.T) string {
mqDSN, ok := os.LookupEnv(mqDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
mqDSN = strings.Replace(mqDSN, "0.0.0.0:", "127.0.0.1:", 1)

return mqDSN
}
4 changes: 4 additions & 0 deletions checks/redis/check_test.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package redis
import (
"context"
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
@@ -25,5 +26,8 @@ func getDSN(t *testing.T) string {
redisDSN, ok := os.LookupEnv(rdDSNEnv)
require.True(t, ok)

// "docker-compose port <service> <port>" returns 0.0.0.0:XXXX locally, change it to local port
redisDSN = strings.Replace(redisDSN, "0.0.0.0:", "127.0.0.1:", 1)

return redisDSN
}
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -18,22 +18,42 @@ services:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5

rabbit:
image: rabbitmq:3.6-management-alpine
ports:
- "5672"
- "15672"
healthcheck:
test: [ "CMD", "rabbitmqctl", "status" ]
interval: 10s
timeout: 5s
retries: 5

redis:
image: redis:3.2-alpine
ports:
- "6379"
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 10s
timeout: 5s
retries: 5

mongo:
image: mongo:3
ports:
- "27017"
healthcheck:
test: "mongo localhost:27017/test --quiet --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)'"
interval: 10s
timeout: 5s
retries: 5

mysql:
image: mysql:5.7
@@ -44,6 +64,11 @@ services:
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: test
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
interval: 10s
timeout: 5s
retries: 5

memcached:
image: memcached:1.6.9-alpine
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ require (
github.com/streadway/amqp v1.0.0
github.com/stretchr/testify v1.7.0
go.mongodb.org/mongo-driver v1.4.1
go.opentelemetry.io/otel v0.19.0
go.opentelemetry.io/otel/trace v0.19.0
go.opentelemetry.io/otel v0.20.0
go.opentelemetry.io/otel/trace v0.20.0
google.golang.org/grpc v1.36.0
)
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -418,17 +418,17 @@ go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/otel v0.18.0/go.mod h1:PT5zQj4lTsR1YeARt8YNKcFb88/c2IKoSABK9mX0r78=
go.opentelemetry.io/otel v0.19.0 h1:Lenfy7QHRXPZVsw/12CWpxX6d/JkrX8wrx2vO8G80Ng=
go.opentelemetry.io/otel v0.19.0/go.mod h1:j9bF567N9EfomkSidSfmMwIwIBuP37AMAIzVW85OxSg=
go.opentelemetry.io/otel v0.20.0 h1:eaP0Fqu7SXHwvjiqDq83zImeehOHX8doTvU9AwXON8g=
go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo=
go.opentelemetry.io/otel/metric v0.18.0/go.mod h1:kEH2QtzAyBy3xDVQfGZKIcok4ZZFvd5xyKPfPcuK6pE=
go.opentelemetry.io/otel/metric v0.19.0 h1:dtZ1Ju44gkJkYvo+3qGqVXmf88tc+a42edOywypengg=
go.opentelemetry.io/otel/metric v0.19.0/go.mod h1:8f9fglJPRnXuskQmKpnad31lcLJ2VmNNqIsx/uIwBSc=
go.opentelemetry.io/otel/metric v0.20.0 h1:4kzhXFP+btKm4jwxpjIqjs41A7MakRFUS86bqLHTIw8=
go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU=
go.opentelemetry.io/otel/oteltest v0.18.0/go.mod h1:NyierCU3/G8DLTva7KRzGii2fdxdR89zXKH1bNWY7Bo=
go.opentelemetry.io/otel/oteltest v0.19.0 h1:YVfA0ByROYqTwOxqHVZYZExzEpfZor+MU1rU+ip2v9Q=
go.opentelemetry.io/otel/oteltest v0.19.0/go.mod h1:tI4yxwh8U21v7JD6R3BcA/2+RBoTKFexE/PJ/nSO7IA=
go.opentelemetry.io/otel/oteltest v0.20.0 h1:HiITxCawalo5vQzdHfKeZurV8x7ljcqAgiWzF6Vaeaw=
go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw=
go.opentelemetry.io/otel/trace v0.18.0/go.mod h1:FzdUu3BPwZSZebfQ1vl5/tAa8LyMLXSJN57AXIt/iDk=
go.opentelemetry.io/otel/trace v0.19.0 h1:1ucYlenXIDA1OlHVLDZKX0ObXV5RLaq06DtUKz5e5zc=
go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bjBWZQA5DXz/qg=
go.opentelemetry.io/otel/trace v0.20.0 h1:1DL6EXUdcg95gukhuRRvLDO/4X5THh/5dIV52lqtnbw=
go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=

0 comments on commit 38c762a

Please sign in to comment.