-
Notifications
You must be signed in to change notification settings - Fork 2
/
newrelic.go
31 lines (26 loc) · 1.17 KB
/
newrelic.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/deployment-notifications#examples
// curl -H "x-api-key:REPLACE_WITH_YOUR_API_KEY" -d "deployment[app_name]=REPLACE_WITH_YOUR_APP_NAME" -d "deployment[description]=This is an app id deployment" https://api.newrelic.com/deployments.xml
package main
import (
"bytes"
"fmt"
"net/http"
"net/url"
"strconv"
)
func NewRelicRequest(state *HerokuAppState) *http.Request {
urlStr := "https://api.newrelic.com/deployments.xml"
params := url.Values{
"deployment[app_name]": {state.Env["NEW_RELIC_APP_NAME"]},
"deployment[application_id]": {state.Env["NEW_RELIC_ID"]},
"deployment[user]": {state.User},
"deployment[description]": {fmt.Sprintf("%s %s", state.App, state.Release)},
"deployment[changelog]": {fmt.Sprintf(" %s", state.GitLog)},
"deployment[revision]": {state.Head},
}
req, _ := http.NewRequest("POST", urlStr, bytes.NewBufferString(params.Encode()))
req.Header.Add("x-license-key", state.Env["NEW_RELIC_LICENSE_KEY"])
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("Content-Length", strconv.Itoa(len(params.Encode())))
return req
}