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

infrastructures.NewRelic   A

Complexity

Conditions 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nop 0
dl 0
loc 13
rs 9.95
c 0
b 0
f 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