This repository has been archived by the owner on May 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #4 from essentialkaos/develop
Version 2.0.0
- Loading branch information
Showing
9 changed files
with
287 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: go | ||
|
||
go: | ||
- 1.6.2 | ||
- tip | ||
|
||
sudo: false | ||
|
||
os: | ||
- linux | ||
|
||
before_install: | ||
- go get pkg.re/essentialkaos/ek.v1 | ||
|
||
script: | ||
- go build examples/annotations_example.go | ||
- go build examples/async_example.go | ||
- go build examples/basic_example.go | ||
- go build examples/collector_example.go |
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,2 @@ | ||
# Dummy make file | ||
# |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/essentialkaos/librato" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
func main() { | ||
librato.Mail = "[email protected]" | ||
librato.Token = "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" | ||
|
||
// Add annotation to example:annotation_1 stream | ||
errs := librato.AddAnnotation("example:annotation_1", | ||
librato.Annotation{ | ||
Title: "Deploy v31", | ||
Source: "server123", | ||
Desc: "Revision: abcd1234", | ||
Links: []string{ | ||
"https://build-service.com/build/31", | ||
"https://git-repo.com/commit/abcd1234", | ||
}, | ||
}, | ||
) | ||
|
||
if len(errs) != 0 { | ||
fmt.Println("Errors:") | ||
|
||
for _, err := range errs { | ||
fmt.Printf(" %v\n", err) | ||
} | ||
} else { | ||
fmt.Println("Annotation added") | ||
} | ||
|
||
time.Sleep(time.Minute) | ||
|
||
// Delete stream example:annotation_1 with all annotations | ||
errs = librato.DeleteAnnotations("example:annotation_1") | ||
|
||
if len(errs) != 0 { | ||
fmt.Println("Errors:") | ||
|
||
for _, err := range errs { | ||
fmt.Printf(" %v\n", err) | ||
} | ||
} else { | ||
fmt.Println("Annotation deleted") | ||
} | ||
} |
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,40 @@ | ||
package main | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"pkg.re/essentialkaos/ek.v1/rand" | ||
|
||
"github.com/essentialkaos/librato" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
func main() { | ||
librato.Mail = "[email protected]" | ||
librato.Token = "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" | ||
|
||
// Create struct for async sending metrics data | ||
// With this preferences metrics will be sended to Librato once | ||
// a minute or if queue size reached 60 elements | ||
metrics, err := librato.NewMetrics(time.Minute, 60) | ||
|
||
if err != nil { | ||
fmt.Printf("Error: %v\n", err) | ||
return | ||
} | ||
|
||
for { | ||
metrics.Add( | ||
librato.Gauge{ | ||
Name: "example:gauge_1", | ||
Value: rand.Int(1000), | ||
}, | ||
) | ||
|
||
time.Sleep(15 * time.Second) | ||
} | ||
} |
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,49 @@ | ||
package main | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"pkg.re/essentialkaos/ek.v1/rand" | ||
|
||
"github.com/essentialkaos/librato" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
func main() { | ||
librato.Mail = "[email protected]" | ||
librato.Token = "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" | ||
|
||
for { | ||
errs := librato.AddMetric( | ||
librato.Gauge{ | ||
Name: "example:gauge_1", | ||
Value: rand.Int(1000), | ||
}, | ||
librato.Gauge{ | ||
Name: "example:gauge_2", | ||
Value: float64(rand.Int(1000)) / float64(rand.Int(20)), | ||
Source: "go_librato_example", | ||
}, | ||
librato.Counter{ | ||
Name: "example:counter_1", | ||
Value: rand.Int(1000), | ||
}, | ||
) | ||
|
||
if len(errs) != 0 { | ||
fmt.Println("Errors:") | ||
|
||
for _, err := range errs { | ||
fmt.Printf(" %v\n", err) | ||
} | ||
} else { | ||
fmt.Println("Data sended to Librato Metrics") | ||
} | ||
|
||
time.Sleep(time.Minute) | ||
} | ||
} |
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,54 @@ | ||
package main | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"pkg.re/essentialkaos/ek.v1/rand" | ||
|
||
"github.com/essentialkaos/librato" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
func main() { | ||
librato.Mail = "[email protected]" | ||
librato.Token = "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" | ||
|
||
collector := librato.NewCollector(time.Minute, collectSomeMetrics) | ||
collector.ErrorHandler = errorHandler | ||
|
||
for { | ||
time.Sleep(time.Hour) | ||
} | ||
} | ||
|
||
func collectSomeMetrics() []librato.Measurement { | ||
fmt.Println("Metrics collected") | ||
|
||
return []librato.Measurement{ | ||
librato.Gauge{ | ||
Name: "example:gauge_1", | ||
Value: rand.Int(1000), | ||
}, | ||
librato.Gauge{ | ||
Name: "example:gauge_2", | ||
Value: float64(rand.Int(1000)) / float64(rand.Int(20)), | ||
Source: "go_librato_example", | ||
}, | ||
librato.Counter{ | ||
Name: "example:counter_1", | ||
Value: rand.Int(1000), | ||
}, | ||
} | ||
} | ||
|
||
func errorHandler(errs []error) { | ||
fmt.Println("Errors:") | ||
|
||
for _, err := range errs { | ||
fmt.Printf(" %v\n", err) | ||
} | ||
} |
Oops, something went wrong.