Passed
Push — main ( f6597a...58b626 )
by Yume
01:31 queued 12s
created

infrastructures/newrelic.go   A

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 17
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A infrastructures.NewRelic 0 13 2
A infrastructures.GetRelicApp 0 2 1
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