<commit_before>package main

import (
	"flag"
	"fmt"
	"math/rand"
	"net/http"
	_ "net/http/pprof"
	"os"
	"os/signal"
	"sort"
	"strings"
	"syscall"
	"time"

	"github.com/uber-go/zap"
	"github.com/yulrizka/bot"
	"github.com/yulrizka/fam100"
	"golang.org/x/net/context"
)

var (
	log                  zap.Logger
	logLevel             int
	minQuorum            = 3 // minimum players to start game
	graphiteURL          = ""
	quorumWait           = 120 * time.Second
	telegramInBufferSize = 10000
	gameInBufferSize     = 10000
	gameOutBufferSize    = 10000
	defaultQuestionLimit = 0
	botName              = "fam100bot"
	startedAt            time.Time
	timeoutChan          = make(chan string, 10000)
	finishedChan         = make(chan string, 10000)
	adminID              = ""
	httpTimeout          = 15 * time.Second
	roundDuration        = 90

	// compiled time information
	VERSION   = ""
	BUILDTIME = ""
)

type logger struct {
	zap.Logger
}

func (l logger) Error(msg string, fields ...zap.Field) {
	l.Logger.Error(msg, fields...)
	errorCount.Inc(1)
}

func init() {
	log = logger{zap.NewJSON(zap.AddCaller(), zap.AddStacks(zap.FatalLevel))}
	fam100.ExtraQuestionSeed = 1
}

func main() {
	flag.StringVar(&botName, "botname", "fam100bot", "bot name")
	flag.StringVar(&adminID, "admin", "", "admin id")
	flag.IntVar(&minQuorum, "quorum", 3, "minimal channel quorum")
	flag.StringVar(&graphiteURL, "graphite", "", "graphite url, empty to disable")
	flag.IntVar(&roundDuration, "roundDuration", 90, "round duration in second")
	flag.IntVar(&defaultQuestionLimit, "questionLimit", -1, "defaultQuestionLimit")
	logLevel := zap.LevelFlag("v", zap.InfoLevel, "log level: all, debug, info, warn, error, panic, fatal, none")
	flag.Parse()

	go func() {
		log.Info("http listener", zap.Error(http.ListenAndServe("localhost:5050", nil)))
	}()

	// setup logger
	log.SetLevel(*logLevel)
	bot.SetLogger(log)
	fam100.SetLogger(log)<commit_msg>Add blocking profile rate<commit_after>package main

import (
	"flag"
	"fmt"
	"math/rand"
	"net/http"
	_ "net/http/pprof"
	"os"
	"os/signal"
	"runtime"
	"sort"
	"strings"
	"syscall"
	"time"

	"github.com/uber-go/zap"
	"github.com/yulrizka/bot"
	"github.com/yulrizka/fam100"
	"golang.org/x/net/context"
)

var (
	log                  zap.Logger
	logLevel             int
	minQuorum            = 3 // minimum players to start game
	graphiteURL          = ""
	quorumWait           = 120 * time.Second
	telegramInBufferSize = 10000
	gameInBufferSize     = 10000
	gameOutBufferSize    = 10000
	defaultQuestionLimit = 0
	botName              = "fam100bot"
	startedAt            time.Time
	timeoutChan          = make(chan string, 10000)
	finishedChan         = make(chan string, 10000)
	adminID              = ""
	httpTimeout          = 15 * time.Second
	roundDuration        = 90
	blockProfileRate     = 0

	// compiled time information
	VERSION   = ""
	BUILDTIME = ""
)

type logger struct {
	zap.Logger
}

func (l logger) Error(msg string, fields ...zap.Field) {
	l.Logger.Error(msg, fields...)
	errorCount.Inc(1)
}

func init() {
	log = logger{zap.NewJSON(zap.AddCaller(), zap.AddStacks(zap.FatalLevel))}
	fam100.ExtraQuestionSeed = 1
}

func main() {
	flag.StringVar(&botName, "botname", "fam100bot", "bot name")
	flag.StringVar(&adminID, "admin", "", "admin id")
	flag.IntVar(&minQuorum, "quorum", 3, "minimal channel quorum")
	flag.StringVar(&graphiteURL, "graphite", "", "graphite url, empty to disable")
	flag.IntVar(&roundDuration, "roundDuration", 90, "round duration in second")
	flag.IntVar(&defaultQuestionLimit, "questionLimit", -1, "set default question limit")
	flag.IntVar(&blockProfileRate, "blockProfile", 0, "enable go routine blockProfile for profiling rate set to 1000000000 for sampling every sec")
	logLevel := zap.LevelFlag("v", zap.InfoLevel, "log level: all, debug, info, warn, error, panic, fatal, none")
	flag.Parse()

	go func() {
		if blockProfileRate > 0 {
			runtime.SetBlockProfileRate(blockProfileRate)
			log.Info("runtime.BlockProfile is enabled", zap.Int("rate", blockProfileRate))
		}
		log.Info("http listener", zap.Error(http.ListenAndServe("localhost:5050", nil)))
	}()

	// setup logger
	log.SetLevel(*logLevel)
	bot.SetLogger(log)
	fam100.SetLogger(log)
{'fraction_non_alphanumeric': 0.13859275053304904, 'fraction_numerical': 0.03103529969201611, 'mean_word_length': 3.370600414078675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '1152771', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1478, 'n_words': 326}