| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package infrastructures |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "github.com/memnix/memnix-rest/config" |
||
| 5 | "github.com/newrelic/go-agent/v3/newrelic" |
||
| 6 | "github.com/pkg/errors" |
||
| 7 | ) |
||
| 8 | |||
| 9 | var relicApp *newrelic.Application |
||
| 10 | |||
| 11 | // NewRelic creates a newrelic application |
||
| 12 | func NewRelic() error { |
||
| 13 | app, err := newrelic.NewApplication( |
||
| 14 | newrelic.ConfigAppName(config.EnvHelper.GetEnv("NEWRELIC_NAME")), |
||
| 15 | newrelic.ConfigLicense(config.EnvHelper.GetEnv("NEWRELIC_KEY")), |
||
| 16 | newrelic.ConfigAppLogForwardingEnabled(true), |
||
| 17 | ) |
||
| 18 | if err != nil { |
||
| 19 | return errors.Wrap(err, "error creating newrelic application") |
||
| 20 | } |
||
| 21 | |||
| 22 | relicApp = app |
||
| 23 | |||
| 24 | return nil |
||
| 25 | } |
||
| 26 | |||
| 27 | // GetRelicApp returns the newrelic application |
||
| 28 | func GetRelicApp() *newrelic.Application { |
||
| 29 | return relicApp |
||
| 30 | } |
||
| 31 |