本文整理汇总了Golang中github.com/yvasiyarov/gorelic.NewAgent函数的典型用法代码示例。如果您正苦于以下问题:Golang NewAgent函数的具体用法?Golang NewAgent怎么用?Golang NewAgent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewAgent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: configureNewRelic
func configureNewRelic() {
agent := gorelic.NewAgent()
agent.Verbose = true
agent.NewrelicLicense = os.Getenv("NEW_RELIC_LICENSE_KEY")
agent.NewrelicName = "Go sendgrid events handler"
agent.Run()
}
示例2: NewrelicAgentMiddleware
// NewrelicAgentMiddleware inits gorelic's NewRelic object and returns handler function
func NewrelicAgentMiddleware(license string, appname string, verbose bool) gin.HandlerFunc {
var agent *gorelic.Agent
if license == "" {
return nil
}
agent = gorelic.NewAgent()
agent.NewrelicLicense = license
agent.HTTPTimer = metrics.NewTimer()
agent.CollectHTTPStat = true
agent.Verbose = verbose
agent.NewrelicName = appname
agent.Run()
return func(c *gin.Context) {
startTime := time.Now()
c.Next()
if agent != nil {
agent.HTTPTimer.UpdateSince(startTime)
}
}
}
示例3: configureReporting
func configureReporting(app *handlers.App) http.Handler {
var handler http.Handler = app
if app.Config.Reporting.Bugsnag.APIKey != "" {
bugsnagConfig := bugsnag.Configuration{
APIKey: app.Config.Reporting.Bugsnag.APIKey,
// TODO(brianbland): provide the registry version here
// AppVersion: "2.0",
}
if app.Config.Reporting.Bugsnag.ReleaseStage != "" {
bugsnagConfig.ReleaseStage = app.Config.Reporting.Bugsnag.ReleaseStage
}
if app.Config.Reporting.Bugsnag.Endpoint != "" {
bugsnagConfig.Endpoint = app.Config.Reporting.Bugsnag.Endpoint
}
bugsnag.Configure(bugsnagConfig)
handler = bugsnag.Handler(handler)
}
if app.Config.Reporting.NewRelic.LicenseKey != "" {
agent := gorelic.NewAgent()
agent.NewrelicLicense = app.Config.Reporting.NewRelic.LicenseKey
if app.Config.Reporting.NewRelic.Name != "" {
agent.NewrelicName = app.Config.Reporting.NewRelic.Name
}
agent.CollectHTTPStat = true
agent.Verbose = app.Config.Reporting.NewRelic.Verbose
agent.Run()
handler = agent.WrapHTTPHandler(handler)
}
return handler
}
示例4: InitNewRelicAgent
// InitNewRelicAgent initializes a new gorelic agent for usage in Handler
func InitNewRelicAgent(license string, appname string, verbose bool) (*gorelic.Agent, error) {
if license == "" {
return gorelic.NewAgent(), fmt.Errorf("Please specify a NewRelic license")
}
agent = gorelic.NewAgent()
agent.NewrelicLicense = license
agent.NewrelicName = appname
agent.HTTPTimer = metrics.NewTimer()
agent.CollectHTTPStat = true
agent.Verbose = verbose
agent.Run()
return agent, nil
}
示例5: runLogProcesses
func runLogProcesses() {
fmt.Println("Initialize relic ")
agent := gorelic.NewAgent()
agent.Verbose = true
agent.NewrelicLicense = os.Getenv("GRANTHCO_LOG_CREDENTIALS")
agent.Run()
}
示例6: startNewRelic
func startNewRelic() {
key := os.Getenv("NEW_RELIC_LICENSE_KEY")
agent := gorelic.NewAgent()
agent.Verbose = true
agent.NewrelicLicense = key
fmt.Println("Starting NewRelic for " + key)
agent.Run()
}
示例7: startNewrelic
func startNewrelic() {
if cfg.NewrelicEnabled {
nr := gorelic.NewAgent()
nr.Verbose = cfg.NewrelicVerbose
nr.NewrelicLicense = cfg.NewrelicKey
nr.NewrelicName = cfg.NewrelicName
nr.Run()
}
}
示例8: startMonitoring
func startMonitoring(license string) {
agent := gorelic.NewAgent()
agent.Verbose = true
agent.CollectHTTPStat = true
agent.NewrelicLicense = license
agent.NewrelicName = "Cloudgov Deck"
if err := agent.Run(); err != nil {
fmt.Println(err.Error())
}
}
示例9: main
func main() {
var (
newrelicLicense = os.Getenv("NEWRELIC_LICENSE")
newrelicName = os.Getenv("NEWRELIC_NAME")
)
if newrelicLicense != "" && newrelicName != "" {
agent := gorelic.NewAgent()
agent.Verbose = true
agent.NewrelicLicense = os.Getenv("NEWRELIC_LICENSE")
agent.NewrelicName = os.Getenv("NEWRELIC_NAME")
agent.Run()
}
m := martini.Classic()
m.Get("/", func() string {
return "Hello world!"
})
var logger *log.Logger
logger = m.Injector.Get(reflect.TypeOf(logger)).Interface().(*log.Logger)
m.Post("**", func(res http.ResponseWriter, req *http.Request) (int, string) {
var (
contentTypeHeader []string
contentType string
)
contentTypeHeader = req.Header["Content-Type"]
if len(contentTypeHeader) > 0 {
contentType = contentTypeHeader[0]
} else {
return 400, "Content-Type header is mandatory"
}
body, err := ioutil.ReadAll(req.Body)
if err != nil {
return 400, "Invalid request body"
}
if contentType == "application/x-php" {
qsa := toMapStringString(req.URL.Query())
return checkPhp(res, string(body[:]), qsa)
}
return 415, "Content-Type not currently supported"
})
var corsOrigins = os.Getenv("CORS_ORIGINS")
if corsOrigins != "" {
logger.Println("activating CORS: " + corsOrigins)
m.Use(cors.Allow(&cors.Options{
AllowOrigins: strings.Split(corsOrigins, ","),
AllowMethods: []string{"GET", "POST"},
AllowHeaders: []string{"Origin", "Content-Type"},
}))
}
m.Run()
}
示例10: registerNewRelic
func registerNewRelic() {
agent := gorelic.NewAgent()
agent.Verbose = true
agent.NewrelicLicense = os.Getenv("NEWRELIC_LICENSE")
log.Printf("NRL %s", agent.NewrelicLicense)
agent.NewrelicName = "Gaia"
agent.CollectHTTPStat = true
agent.Verbose = true
agent.Run()
}
示例11: startMetrics
func startMetrics() {
newRelicAPIKey := os.Getenv("NEW_RELIC_KEY")
if newRelicAPIKey == "" {
return
}
agent := gorelic.NewAgent()
agent.Verbose = false
agent.NewrelicLicense = newRelicAPIKey
agent.Run()
}
示例12: gorelicMonitor
func gorelicMonitor() {
if envIsStaging() || envIsProduction() {
if key := os.Getenv("NEW_RELIC_LICENSE_KEY"); key != "" {
agent := gorelic.NewAgent()
agent.NewrelicName = "emojitrack-gostreamer"
agent.NewrelicLicense = key
agent.Verbose = false
agent.Run()
}
}
}
示例13: initGorelic
func initGorelic() {
if !conf.IsDev() {
return
}
agent = gorelic.NewAgent()
agent.NewrelicName = "go-gamereviews"
agent.Verbose = true
agent.NewrelicLicense = conf.Config.NewrelicLicense
agent.CollectHTTPStat = true
agent.HTTPTimer = metrics.NewTimer()
agent.Run()
}
示例14: main
func main() {
flag.Parse()
if *newrelicLicense == "" {
log.Fatalf("Please, pass a valid newrelic license key.\n Use --help to get more information about available options\n")
}
agent := gorelic.NewAgent()
agent.Verbose = true
agent.NewrelicLicense = *newrelicLicense
agent.Run()
doSomeJob(100)
}
示例15: main
func main() {
flag.Parse()
if *newrelicLicense == "" {
log.Fatalf("Please, pass a valid newrelic license key.\n Use --help to get more information about available options\n")
}
agent := gorelic.NewAgent()
agent.Verbose = true
agent.CollectHTTPStat = true
agent.NewrelicLicense = *newrelicLicense
agent.Run()
http.HandleFunc("/", agent.WrapHTTPHandlerFunc(helloServer))
http.ListenAndServe(":8080", nil)
}