Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Commit

Permalink
Change strategy, change datadog metrics name
Browse files Browse the repository at this point in the history
  • Loading branch information
scoiatael committed Mar 8, 2017
1 parent 4c6efa8 commit c6097f4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
override: make test
7 changes: 5 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ func (c Config) HttpHandler() actions.HttpHandler {
}

func (c *Config) Init() error {
new_provider := persistence.CassandraProvider{Hosts: c.Hosts, Keyspace: c.Keyspace}
new_provider := persistence.CassandraProvider{
Hosts: c.Hosts,
Keyspace: c.Keyspace,
}
err := new_provider.Init()
if err != nil {
return err
}
c.provider = &new_provider

dd := telemetry.NewDatadog(c.StatsdAddr, c.Keyspace)
dd := telemetry.NewDatadog(c.StatsdAddr, "archai", c.Keyspace)
c.telemetry = dd

c.initialized = true
Expand Down
2 changes: 1 addition & 1 deletion persistence/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (cp *CassandraProvider) Session() (Session, error) {
return nil, fmt.Errorf("Initialize CassandraProvider with NewProvider first")
}

const createKeySpace = `CREATE KEYSPACE IF NOT EXISTS %s WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };`
const createKeySpace = `CREATE KEYSPACE IF NOT EXISTS %s WITH replication = { 'class' : 'NetworkTopologyStrategy' };`

func (c *CassandraProvider) createKeySpace() error {
cluster := c.NewCluster()
Expand Down
4 changes: 3 additions & 1 deletion telemetry/datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (c *Client) on_error(err error) {

func (c *Client) Failure(title, text string) {
if c.initialized {
title = c.client.Namespace + "." + title
ev := statsd.NewEvent(title, text)
ev.AlertType = statsd.Error
err := errors.Wrap(c.client.Event(ev), "Failed sending event to DataDog")
Expand All @@ -41,13 +42,14 @@ func (c *Client) Incr(name string, tags []string) {
}
}

func NewDatadog(addr string, namespace string) Datadog {
func NewDatadog(addr string, namespace string, keyspace string) Datadog {
c, err := statsd.New(addr)
if err != nil {
client := &Client{}
client.on_error(err)
return client
}
c.Namespace = namespace + "."
c.Tags = append(c.Tags, "keyspace:"+keyspace)
return &Client{client: c, initialized: true}
}

0 comments on commit c6097f4

Please sign in to comment.