當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。