Skip to content

Commit a04e6f2

Browse files
authored
metrics: add metrics and telemetry package (#500)
1 parent 4d3a6ad commit a04e6f2

38 files changed

+1260
-79
lines changed

.travis.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ sudo: required
22

33
go_import_path: github.com/ory/hydra
44

5+
cache:
6+
directories:
7+
- $GOPATH/src
8+
- $GOPATH/pkg
9+
- ./vendor/
10+
511
services:
612
- docker
713

@@ -25,14 +31,18 @@ install:
2531
- go install github.com/ory/hydra
2632

2733
script:
28-
- |-
29-
touch ./coverage.tmp && echo 'mode: atomic' > coverage.txt && go list ./... | grep -v /vendor | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | grep -v /vendor | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.txt' && rm coverage.tmp
34+
- touch ./coverage.tmp
35+
- |
36+
echo 'mode: atomic' > coverage.txt
37+
- |
38+
go list ./... | grep -v /cmd | grep -v /vendor | xargs -n1 -I{} sh -c 'go test -race -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | grep -v /vendor | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.txt || exit 255' && rm coverage.tmp
39+
- touch ./coverage.tmp
40+
- |
41+
go list ./cmd/... | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | grep -v /vendor | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.txt || exit 255' && rm coverage.tmp
3042
- goveralls -coverprofile="coverage.txt"
31-
- go test -race $(go list ./... | grep -v /vendor | grep -v /cmd)
32-
- go test -v -bench=.* -run=none $(glide novendor)
33-
- docker build -t hydra-travis-ci .
43+
- docker build -t hydra-travis-ci -f Dockerfile-without-telemetry .
3444
- docker run -d hydra-travis-ci
35-
- DATABASE_URL=memory hydra host --dangerous-auto-logon --dangerous-force-http &
45+
- DATABASE_URL=memory hydra host --dangerous-auto-logon --dangerous-force-http --disable-telemetry &
3646
- while ! echo exit | nc localhost 4444; do sleep 1; done
3747
# Test clients
3848
- hydra clients create --id foobar

Dockerfile-demo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ RUN glide install --skip-test -v
1010
ADD . .
1111
RUN go install .
1212

13-
ENTRYPOINT /go/bin/hydra migrate sql $DATABASE_URL; /go/bin/hydra host --dangerous-auto-logon --dangerous-force-http
13+
ENTRYPOINT /go/bin/hydra migrate sql $DATABASE_URL; /go/bin/hydra host --dangerous-auto-logon --dangerous-force-http --disable-telemetry
1414

1515
EXPOSE 4444

Dockerfile-without-telemetry

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM golang:1.8-alpine
2+
3+
RUN apk add --no-cache git
4+
RUN go get github.com/Masterminds/glide
5+
WORKDIR /go/src/github.com/ory/hydra
6+
7+
ADD ./glide.yaml ./glide.yaml
8+
ADD ./glide.lock ./glide.lock
9+
RUN glide install --skip-test -v
10+
11+
ADD . .
12+
RUN go install .
13+
14+
ENTRYPOINT /go/bin/hydra host --disable-telemetry
15+
16+
EXPOSE 4444

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
This list makes you aware of (breaking) changes. For patch notes, please check the [releases tab](https://github.com/ory/hydra/releases).
44

5+
## 0.9.0
6+
7+
This version adds performance metrics to `/health` and sends anonymous usage statistics to our servers, [click here](https://ory.gitbooks.io/hydra/content/telemetry.html) for more
8+
details on this feature and how to disable it.
9+
510
## 0.8.0
611

712
This PR improves some performance bottlenecks, offers more control over Hydra, moves to Go 1.8,

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ community on [Gitter](https://gitter.im/ory-am/hydra). For advanced use cases, c
5151
- [Using Docker](#using-docker)
5252
- [Building from source](#building-from-source)
5353
- [Security](#security)
54+
- [Telemetry](#telemetry)
5455
- [Documentation](#documentation)
5556
- [Guide](#guide)
5657
- [HTTP API documentation](#http-api-documentation)
@@ -218,6 +219,11 @@ ORY Hydra is trusted by companies all around the world, has a vibrant community
218219
each day. Of course, we also compiled a security guide with more details on cryptography and security concepts.
219220
Read [the security guide now](https://ory.gitbooks.io/hydra/content/security.html).
220221

222+
## Telemetry
223+
224+
ORY Hydra collects summarized, anonymized telemetry which can optionally be turned off. Click [here](https://ory.gitbooks.io/hydra/content/telemetry.html)
225+
to learn more.
226+
221227
## Documentation
222228

223229
### Guide

client/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"net/http"
77

88
"github.com/julienschmidt/httprouter"
9-
"github.com/ory/hydra/rand/sequence"
109
"github.com/ory/herodot"
1110
"github.com/ory/hydra/firewall"
11+
"github.com/ory/hydra/rand/sequence"
1212
"github.com/ory/ladon"
1313
"github.com/pkg/errors"
1414
)

client/manager_http.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
)
1313

1414
type HTTPManager struct {
15-
Client *http.Client
16-
Endpoint *url.URL
17-
Dry bool
15+
Client *http.Client
16+
Endpoint *url.URL
17+
Dry bool
1818
FakeTLSTermination bool
1919
}
2020

client/manager_sql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package client
22

33
import (
4+
"context"
45
"database/sql"
56
"fmt"
67
"strings"
7-
"context"
88

99
"github.com/jmoiron/sqlx"
1010
"github.com/ory/fosite"

client/manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/julienschmidt/httprouter"
1313
_ "github.com/lib/pq"
14+
"github.com/ory/dockertest"
1415
"github.com/ory/fosite"
1516
"github.com/ory/herodot"
1617
. "github.com/ory/hydra/client"
@@ -19,7 +20,6 @@ import (
1920
"github.com/ory/hydra/pkg"
2021
"github.com/ory/ladon"
2122
"github.com/stretchr/testify/assert"
22-
"github.com/ory/dockertest"
2323
)
2424

2525
var clientManagers = map[string]Storage{}

cmd/cli/handler_warden.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func newWardenHandler(c *config.Config) *WardenHandler {
2323

2424
func (h *WardenHandler) IsAuthorized(cmd *cobra.Command, args []string) {
2525
m := &oauth2.HTTPIntrospector{
26-
Endpoint: h.Config.Resolve("/oauth2/introspect"),
27-
Client: h.Config.OAuth2Client(cmd),
26+
Endpoint: h.Config.Resolve("/oauth2/introspect"),
27+
Client: h.Config.OAuth2Client(cmd),
2828
}
2929

3030
if len(args) != 1 {

0 commit comments

Comments
 (0)