-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from rollbar/pawel/telemetry
added telemetry support
- Loading branch information
Showing
9 changed files
with
444 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module github.com/rollbar/rollbar-go | ||
|
||
go 1.13 | ||
|
||
require github.com/stretchr/testify v1.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package rollbar | ||
|
||
import "sync" | ||
|
||
// NewQueue returns a new queue with the given initial size. | ||
func NewQueue(size int) *Queue { | ||
return &Queue{ | ||
nodes: make([]interface{}, size), | ||
size: size, | ||
} | ||
} | ||
|
||
// Queue is a basic FIFO queue based on a circular list that resizes as needed. | ||
type Queue struct { | ||
nodes []interface{} | ||
size int | ||
head int | ||
tail int | ||
count int | ||
|
||
lock sync.RWMutex | ||
} | ||
|
||
// Push adds a node to the queue. | ||
func (q *Queue) Push(n interface{}) { | ||
q.lock.Lock() | ||
defer q.lock.Unlock() | ||
if q.head == q.tail && q.count > 0 { | ||
nodes := make([]interface{}, len(q.nodes)+q.size) | ||
copy(nodes, q.nodes[q.head:]) | ||
copy(nodes[len(q.nodes)-q.head:], q.nodes[:q.head]) | ||
q.head = 0 | ||
q.tail = len(q.nodes) | ||
q.nodes = nodes | ||
} | ||
q.nodes[q.tail] = n | ||
q.tail = (q.tail + 1) % len(q.nodes) | ||
q.count++ | ||
} | ||
|
||
// Pop removes and returns a node from the queue in first to last order. | ||
func (q *Queue) Pop() interface{} { | ||
q.lock.Lock() | ||
defer q.lock.Unlock() | ||
if q.count == 0 { | ||
return nil | ||
} | ||
node := q.nodes[q.head] | ||
q.head = (q.head + 1) % len(q.nodes) | ||
q.count-- | ||
return node | ||
} | ||
|
||
// Items returns all populated (non nil) items | ||
func (q *Queue) Items() []interface{} { | ||
q.lock.RLock() | ||
defer q.lock.RUnlock() | ||
return q.nodes[:q.count] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.