All Projects → lyft → gostats

lyft / gostats

Licence: other
Go client for Stats

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to gostats

parallel mAP evaluation
This repo parallelizes mAP_evaluation using python's multiprocessing module.
Stars: ✭ 18 (-65.38%)
Mutual labels:  lyft
omnibot
One slackbot to rule them all
Stars: ✭ 69 (+32.69%)
Mutual labels:  lyft
lyft.github.io
This is code for oss.lyft.com website.
Stars: ✭ 13 (-75%)
Mutual labels:  lyft
lyft-node-sdk
Node SDK for the Lyft Public API
Stars: ✭ 15 (-71.15%)
Mutual labels:  lyft
dailycodingproblem
Solutions to Daily Coding Problem questions
Stars: ✭ 26 (-50%)
Mutual labels:  lyft
Cartography
Cartography is a Python tool that consolidates infrastructure assets and the relationships between them in an intuitive graph view powered by a Neo4j database.
Stars: ✭ 2,169 (+4071.15%)
Mutual labels:  lyft
Scissors
✂ Android image cropping library
Stars: ✭ 1,858 (+3473.08%)
Mutual labels:  lyft
Confidant
Confidant: your secret keeper. https://lyft.github.io/confidant
Stars: ✭ 1,666 (+3103.85%)
Mutual labels:  lyft
React Javascript To Typescript Transform
Convert React JavaScript code to TypeScript with proper typing
Stars: ✭ 1,575 (+2928.85%)
Mutual labels:  lyft
Libretaxi
Open source Uber #deleteuber
Stars: ✭ 3,687 (+6990.38%)
Mutual labels:  lyft

Gostats GoDoc Build Status

gostats is a Go metrics library with support for Counters, Gauges, and Timers.

Installation

go get github.com/lyft/gostats

Building & Testing

go test ./...

Usage

In order to start using gostats, import it into your project with:

import "github.com/lyft/gostats"

Mocking

A thread-safe mock sink is provided by the gostats/mock package. The mock sink also provides methods that are useful for testing (as demonstrated below).

package mock_test

import (
	"testing"

	"github.com/lyft/gostats"
	"github.com/lyft/gostats/mock"
)

type Config struct {
	Stats stats.Store
}

func TestMockExample(t *testing.T) {
	sink := mock.NewSink()
	conf := Config{
		Stats: stats.NewStore(sink, false),
	}
	conf.Stats.NewCounter("name").Inc()
	conf.Stats.Flush()
	sink.AssertCounterEquals(t, "name", 1)
}

If you do not need to assert on the contents of the sink the below example can be used to quickly create a thread-safe stats.Scope:

package config

import (
	"github.com/lyft/gostats"
	"github.com/lyft/gostats/mock"
)

type Config struct {
	Stats stats.Store
}

func NewConfig() *Config {
	return &Config{
		Stats: stats.NewDefaultStore(),
	}
}

func NewMockConfig() *Config {
	sink := mock.NewSink()
	return &Config{
		Stats: stats.NewStore(sink, false),
	}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].