Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #29 from Financial-Times/remove-graphite-integration
Browse files Browse the repository at this point in the history
Remove graphite integration
  • Loading branch information
tamas-molnar committed Sep 19, 2018
2 parents 38ded06 + 7fde053 commit ec7e982
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 79 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ $GOPATH/bin/content-preview \
--transform-app-uri "http://methode-article-transformer-01-iw-uk-p.svc.ft.com/map/" \
--transform-app-health-uri "http://methode-article-transformer-01-iw-uk-p.svc.ft.com/build-info" \
--transform-app-panic-guide "https://sites.google.com/a/ft.com/dynamic-publishing-team/methode-article-transformer-panic-guide" \
--graphite-tcp-address "graphite.ft.com:2003" \
--graphite-prefix "coco.services.$ENV.content-preview.%i"
```

With Docker:
Expand All @@ -66,8 +64,6 @@ With Docker:
--env "TRANSFORM_APP_URI=http://$HOSTNAME:8080/map/" \
--env "TRANSFORM_APP_HEALTH_URI=http://$HOSTNAME:8080/__health" \
--env "TRANSFORM_APP_PANIC_GUIDE=https://sites.google.com/a/ft.com/dynamic-publishing-team/methode-article-transformer-panic-guide" \
--env "GRAPHITE_TCP_ADDRESS=graphite.ft.com:2003" \
--env "GRAPHITE_PREFIX=coco.services.$ENV.content-preview.%i" \
coco/content-preview
`

Expand Down
25 changes: 0 additions & 25 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,6 @@ func main() {
Desc: "Describe the business impact the dependent services would produce if one is broken.",
EnvVar: "BUSINESS_IMPACT",
})
graphiteTCPAddress := app.String(cli.StringOpt{
Name: "graphite-tcp-address",
Value: "",
Desc: "Graphite TCP address, e.g. graphite.ft.com:2003. Leave as default if you do NOT want to output to graphite (e.g. if running locally)",
EnvVar: "GRAPHITE_TCP_ADDRESS",
})
graphitePrefix := app.String(cli.StringOpt{
Name: "graphite-prefix",
Value: "coco.services.$ENV.content-preview.0",
Desc: "Prefix to use. Should start with content, include the environment, and the host name. e.g. coco.pre-prod.sections-rw-neo4j.1",
EnvVar: "GRAPHITE_PREFIX",
})
logMetrics := app.Bool(cli.BoolOpt{
Name: "log-metrics",
Value: false,
Desc: "Whether to log metrics. Set to true if running locally and you want metrics output",
EnvVar: "LOG_METRICS",
})
app.Action = func() {
sc := ServiceConfig{
appSystemCode: *appSystemCode,
Expand All @@ -132,16 +114,13 @@ func main() {
transformAppHealthUri: *transformAppHealthUri,
transformAppPanicGuide: *transformAppPanicGuide,
businessImpact: *businessImpact,
graphiteTCPAddress: *graphiteTCPAddress,
graphitePrefix: *graphitePrefix,
}

appLogger := NewAppLogger()
metricsHandler := NewMetrics()
contentHandler := ContentHandler{&sc, appLogger, &metricsHandler}
h := setupServiceHandler(sc, metricsHandler, contentHandler)
appLogger.ServiceStartedEvent(*appSystemCode, sc.asMap())
metricsHandler.OutputMetricsIfRequired(*graphiteTCPAddress, *graphitePrefix, *logMetrics)
err := http.ListenAndServe(":"+*appPort, h)
if err != nil {
logrus.Fatalf("Unable to start server: %v", err)
Expand Down Expand Up @@ -184,8 +163,6 @@ type ServiceConfig struct {
transformAppHealthUri string
transformAppPanicGuide string
businessImpact string
graphiteTCPAddress string
graphitePrefix string
}

func (sc ServiceConfig) asMap() map[string]interface{} {
Expand All @@ -202,7 +179,5 @@ func (sc ServiceConfig) asMap() map[string]interface{} {
"source-app-panic-guide": sc.sourceAppPanicGuide,
"transform-app-panic-guide": sc.transformAppPanicGuide,
"business-impact": sc.businessImpact,
"graphite-tcp-address": sc.graphiteTCPAddress,
"graphite-prefix": sc.graphitePrefix,
}
}
12 changes: 5 additions & 7 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
)

const (
sourceAppName = "Native Content Service"
transformAppName = "Native Content Transformer Service"
previewableUuid = "d7db73ec-cf53-11e5-92a1-c5e23ef99c77"
sourceAppName = "Native Content Service"
transformAppName = "Native Content Transformer Service"
previewableUuid = "d7db73ec-cf53-11e5-92a1-c5e23ef99c77"
unpreviewableUuid = "b82cc800-87c1-4983-83d2-0bd677f49b2b"
)

Expand Down Expand Up @@ -54,7 +54,7 @@ func methodeApiHandlerMock(w http.ResponseWriter, r *http.Request) {
w.Header().Set(tid.TransactionIDHeader, "tid_w58gqvazux")
}

if r.Header.Get("Authorization") == "Basic " + methodeApiAuth {
if r.Header.Get("Authorization") == "Basic "+methodeApiAuth {
switch uuid {
case previewableUuid:
file, err := os.Open("test-resources/methode-api-output.json")
Expand Down Expand Up @@ -167,8 +167,6 @@ func startContentPreviewService() {
transformAppHealthUri: transformAppHealthUrl,
transformAppPanicGuide: "panic guide",
businessImpact: "business impact",
graphiteTCPAddress: "",
graphitePrefix: "",
}

appLogger := NewAppLogger()
Expand Down Expand Up @@ -257,7 +255,7 @@ func TestInvalidAuth(t *testing.T) {
}
defer resp.Body.Close()

assert.Equal(t, 5, resp.StatusCode / 100, "Response status should be 5xx")
assert.Equal(t, 5, resp.StatusCode/100, "Response status should be 5xx")
}

func TestShouldReturn503whenMethodeApiIsNotHappy(t *testing.T) {
Expand Down
7 changes: 0 additions & 7 deletions helm/content-preview/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ spec:
value: {{ .Values.env.TRANSFORM_APP_NAME }}
- name: TRANSFORM_APP_PANIC_GUIDE
value: {{ .Values.env.TRANSFORM_APP_PANIC_GUIDE }}
- name: GRAPHITE_TCP_ADDRESS
valueFrom:
configMapKeyRef:
name: global-config
key: graphite.address
- name: GRAPHITE_PREFIX
value: coco.services.k8s.{{ .Values.service.name }}
- name: SOURCE_APP_NAME
value: methode-api
- name: SOURCE_APP_URI
Expand Down
21 changes: 2 additions & 19 deletions metrics.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package main

import (
"github.com/cyberdelia/go-metrics-graphite"
"github.com/rcrowley/go-metrics"
standardLog "log"
"net"
"net/http"
"os"
"time"

"github.com/rcrowley/go-metrics"
)

type Metrics struct {
Expand Down Expand Up @@ -43,16 +39,3 @@ func (m Metrics) recordResponseEvent() {
func metricsHttpEndpoint(w http.ResponseWriter, r *http.Request) {
metrics.WriteOnce(metrics.DefaultRegistry, w)
}

//OutputMetricsIfRequired will send metrics to Graphite if a non-empty graphiteTCPAddress is passed in, or to the standard log if logMetrics is true.
// Make sure a sensible graphitePrefix that will uniquely identify your service is passed in, e.g. "content.test.people.rw.neo4j.ftaps58938-law1a-eu-t
func (m Metrics) OutputMetricsIfRequired(graphiteTCPAddress string, graphitePrefix string, logMetrics bool) {
if graphiteTCPAddress != "" {
addr, _ := net.ResolveTCPAddr("tcp", graphiteTCPAddress)
go graphite.Graphite(m.registry, 5*time.Second, graphitePrefix, addr)
}
if logMetrics { //useful locally
//messy use of the 'standard' log package here as this method takes the log struct, not an interface, so can't use logrus.Logger
go metrics.Log(metrics.DefaultRegistry, 60*time.Second, standardLog.New(os.Stdout, "metrics", standardLog.Lmicroseconds))
}
}
28 changes: 11 additions & 17 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
"versionExact": "0.1.1"
},
{
"checksumSHA1": "fqpohN7Qp2qj7TLMbUxh/cK4oH0=",
"checksumSHA1": "lQfsRf7gWYQDNoI3IOZuwNGUwRo=",
"path": "github.com/Financial-Times/service-status-go/buildinfo",
"revision": "3f5199736a3d7ae52394c63aac36834786825e21",
"revisionTime": "2016-03-23T11:15:42Z",
"version": "0.1.0",
"versionExact": "0.1.0"
},
{
"checksumSHA1": "2rGNLXdRC3qr5n5ll7BpYt8HCK8=",
"checksumSHA1": "7QAsTdXi/6nTkDhqKy54YIc69d4=",
"path": "github.com/Financial-Times/service-status-go/gtg",
"revision": "3f5199736a3d7ae52394c63aac36834786825e21",
"revisionTime": "2016-03-23T11:15:42Z",
"version": "0.1.0",
"versionExact": "0.1.0"
},
{
"checksumSHA1": "973POGyMCoyaKQuIYX2f7EKFwlQ=",
"checksumSHA1": "YxgjuCI4TJyfQujUeQk3V+gypzo=",
"path": "github.com/Financial-Times/service-status-go/httphandlers",
"revision": "3f5199736a3d7ae52394c63aac36834786825e21",
"revisionTime": "2016-03-23T11:15:42Z",
Expand All @@ -51,44 +51,38 @@
"versionExact": "v0.2.0"
},
{
"checksumSHA1": "/6H1rhQmbq8mEP29pnmLmdwBKUE=",
"path": "github.com/cyberdelia/go-metrics-graphite",
"revision": "39f87cc3b432bbb898d7c643c0e93cac2bc865ad",
"revisionTime": "2016-12-19T23:08:53Z"
},
{
"checksumSHA1": "OFu4xJEIjiI8Suu+j/gabfp+y6Q=",
"checksumSHA1": "DuEyF75v9xaKXfJsCPRdHNOpGZk=",
"origin": "github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew",
"path": "github.com/davecgh/go-spew/spew",
"revision": "4d4bfba8f1d1027c4fdbe371823030df51419987",
"revisionTime": "2017-01-30T11:31:45Z"
},
{
"checksumSHA1": "I+GdpjQMP4tAYwF4CAklylRWeYI=",
"checksumSHA1": "xf8OgfavaJruzIqqtrb3ugrHdlU=",
"path": "github.com/gorilla/handlers",
"revision": "3a5767ca75ece5f7f1440b1d16975247f8d8b221",
"revisionTime": "2016-12-06T05:51:44Z"
},
{
"checksumSHA1": "urMd7A9QPAJYY0GZJL9qBhlUmD8=",
"checksumSHA1": "QQe2WybsKsiDEsBzIElxUjQV3qg=",
"path": "github.com/gorilla/mux",
"revision": "757bef944d0f21880861c2dd9c871ca543023cba",
"revisionTime": "2016-09-20T23:08:13Z"
},
{
"checksumSHA1": "EcZfls6vcqjasWV/nBlu+C+EFmc=",
"checksumSHA1": "QLrHi7aXd1N8K6PE+XvrKYuKGlQ=",
"path": "github.com/hashicorp/go-version",
"revision": "e96d3840402619007766590ecea8dd7af1292276",
"revisionTime": "2016-10-31T18:26:05Z"
},
{
"checksumSHA1": "lvjAdn0k3UFBN9rbH2cVKmlhgoQ=",
"checksumSHA1": "kAifcJ9VFmW/qITPM328LCMpXpw=",
"path": "github.com/jawher/mow.cli",
"revision": "660b9261e2c80bb92e5a0eaa581596084656140e",
"revisionTime": "2016-09-19T11:45:49Z"
},
{
"checksumSHA1": "zKKp5SZ3d3ycKe4EKMNT0BqAWBw=",
"checksumSHA1": "+oyIJwPyeof36XCkY8awrNfxaNM=",
"origin": "github.com/stretchr/testify/vendor/github.com/pmezard/go-difflib/difflib",
"path": "github.com/pmezard/go-difflib/difflib",
"revision": "4d4bfba8f1d1027c4fdbe371823030df51419987",
Expand All @@ -107,7 +101,7 @@
"revisionTime": "2017-12-05T20:32:29Z"
},
{
"checksumSHA1": "JXUVA1jky8ZX8w09p2t5KLs97Nc=",
"checksumSHA1": "ziYrpyU5zo1q9+n1kaXqkR3kP2s=",
"path": "github.com/stretchr/testify/assert",
"revision": "4d4bfba8f1d1027c4fdbe371823030df51419987",
"revisionTime": "2017-01-30T11:31:45Z"
Expand All @@ -125,7 +119,7 @@
"revisionTime": "2017-12-11T20:45:21Z"
},
{
"checksumSHA1": "iKgeC4jGetV1a+cyKz9EI8Ldlyo=",
"checksumSHA1": "VaWt1KQODK3z6ymfOyyxHPgzHis=",
"path": "golang.org/x/sys/unix",
"revision": "571f7bbbe08da2a8955aed9d4db316e78630e9a3",
"revisionTime": "2017-12-16T14:55:03Z"
Expand Down

0 comments on commit ec7e982

Please sign in to comment.