当前位置: 首页>>代码示例>>Golang>>正文


Golang gorelic.NewAgent函数代码示例

本文整理汇总了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()
}
开发者ID:gshilin,项目名称:sendgridevents,代码行数:7,代码来源:sendgrid.go

示例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)
		}
	}
}
开发者ID:ri-nat,项目名称:gin-gorelic,代码行数:27,代码来源:gorelic.go

示例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
}
开发者ID:orivej,项目名称:distribution,代码行数:35,代码来源:main.go

示例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
}
开发者ID:gabeio,项目名称:echo-middleware,代码行数:17,代码来源:gorelic.go

示例5: runLogProcesses

func runLogProcesses() {
	fmt.Println("Initialize relic ")
	agent := gorelic.NewAgent()
	agent.Verbose = true
	agent.NewrelicLicense = os.Getenv("GRANTHCO_LOG_CREDENTIALS")
	agent.Run()

}
开发者ID:uglyfigurine,项目名称:granth.co,代码行数:8,代码来源:web.go

示例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()
}
开发者ID:gistia,项目名称:slackbot,代码行数:9,代码来源:main.go

示例7: startNewrelic

func startNewrelic() {
	if cfg.NewrelicEnabled {
		nr := gorelic.NewAgent()
		nr.Verbose = cfg.NewrelicVerbose
		nr.NewrelicLicense = cfg.NewrelicKey
		nr.NewrelicName = cfg.NewrelicName
		nr.Run()
	}
}
开发者ID:nicehash,项目名称:ether-proxy,代码行数:9,代码来源:main.go

示例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())
	}
}
开发者ID:18F,项目名称:cg-dashboard,代码行数:10,代码来源:server.go

示例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()
}
开发者ID:jokeyrhyme,项目名称:omnilint-server,代码行数:55,代码来源:omnilint-server.go

示例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()
}
开发者ID:NotyIm,项目名称:gaia,代码行数:11,代码来源:monitor.go

示例11: startMetrics

func startMetrics() {
	newRelicAPIKey := os.Getenv("NEW_RELIC_KEY")

	if newRelicAPIKey == "" {
		return
	}

	agent := gorelic.NewAgent()
	agent.Verbose = false
	agent.NewrelicLicense = newRelicAPIKey
	agent.Run()
}
开发者ID:Nom4d3,项目名称:go-bot,代码行数:12,代码来源:main.go

示例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()
		}
	}

}
开发者ID:SunGuo,项目名称:emojitrack-gostreamer,代码行数:13,代码来源:reporter.go

示例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()
}
开发者ID:macococo,项目名称:go-gamereviews,代码行数:13,代码来源:main.go

示例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)
}
开发者ID:jingweno,项目名称:gorelic,代码行数:13,代码来源:example1.go

示例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)

}
开发者ID:jingweno,项目名称:gorelic,代码行数:15,代码来源:example_web.go


注:本文中的github.com/yvasiyarov/gorelic.NewAgent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。