<commit_before>package main

import (
	"fmt"
	"os"
	"runtime"

	"github.com/sjltaylor/stats-gopher/insights"
	"github.com/sjltaylor/stats-gopher/mq"
	"github.com/sjltaylor/stats-gopher/printer"
	"github.com/sjltaylor/stats-gopher/web"
	"github.com/yvasiyarov/gorelic"
)

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	newRelicMonitoring()
	startInsights()
	startPrinter()
	startWebServer()
}

func startInsights() {
	if ep := os.Getenv("NEW_RELIC_INSIGHTS_ENDPOINT"); ep != "" {
		key := os.Getenv("NEW_RELIC_INSIGHTS_KEY")

		if len(key) == 0 {
			panic("NEW_RELIC_INSIGHTS_KEY not set")
		}

		go insights.Listen(key, ep, mq.Channel())
	}
}

func startPrinter() {
	if os.Getenv("STDOUT_LISTENER") == "1" {
		go printer.Listen(mq.Channel())
	}
}

func newRelicMonitoring() {
	key := os.Getenv("NEW_RELIC_LICENSE_KEY")

	if key == "" {
		return
	}

	agent := gorelic.NewAgent()
	agent.Verbose = true
	agent.NewrelicLicense = key
	agent.Run()<commit_msg>add extra new relic parameters<commit_after>package main

import (
	"fmt"
	"os"
	"runtime"

	"github.com/sjltaylor/stats-gopher/insights"
	"github.com/sjltaylor/stats-gopher/mq"
	"github.com/sjltaylor/stats-gopher/printer"
	"github.com/sjltaylor/stats-gopher/web"
	"github.com/yvasiyarov/gorelic"
)

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	newRelicMonitoring()
	startInsights()
	startPrinter()
	startWebServer()
}

func startInsights() {
	if ep := os.Getenv("NEW_RELIC_INSIGHTS_ENDPOINT"); ep != "" {
		key := os.Getenv("NEW_RELIC_INSIGHTS_KEY")

		if len(key) == 0 {
			panic("NEW_RELIC_INSIGHTS_KEY not set")
		}

		go insights.Listen(key, ep, mq.Channel())
	}
}

func startPrinter() {
	if os.Getenv("STDOUT_LISTENER") == "1" {
		go printer.Listen(mq.Channel())
	}
}

func newRelicMonitoring() {
	key := os.Getenv("NEW_RELIC_LICENSE_KEY")

	if key == "" {
		return
	}

	agent := gorelic.NewAgent()
	agent.Verbose = true
	agent.NewrelicLicense = key
	agent.NewrelicName = "stats-gopher"
	agent.GCPollInterval = 60
	agent.Run()
{'fraction_non_alphanumeric': 0.15757878939469736, 'fraction_numerical': 0.0030015007503751876, 'mean_word_length': 4.58659217877095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3410430', 'n_tokens_mistral': 871, 'n_tokens_neox': 829, 'n_words': 121}