Skip to content
This repository has been archived by the owner on Nov 28, 2017. It is now read-only.

Use a new hash object when calculating rollups #13

Merged
merged 1 commit into from
Feb 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions haystack.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"github.com/technoweenie/grohl"
"hash"
"io"
"net/http"
"net/url"
Expand All @@ -16,7 +15,6 @@ import (
type HaystackReporter struct {
Endpoint string
Hostname string
hash hash.Hash
}

func NewHaystackReporter(config *Configuration) (*HaystackReporter, error) {
Expand All @@ -26,7 +24,7 @@ func NewHaystackReporter(config *Configuration) (*HaystackReporter, error) {
}

endpoint.User = url.UserPassword(config.HaystackUser, config.HaystackPassword)
return &HaystackReporter{endpoint.String(), config.Hostname, md5.New()}, nil
return &HaystackReporter{Endpoint: endpoint.String(), Hostname: config.Hostname}, nil
}

func (r *HaystackReporter) Report(err error, data grohl.Data) error {
Expand Down Expand Up @@ -55,7 +53,7 @@ func (r *HaystackReporter) Report(err error, data grohl.Data) error {
}

func (r *HaystackReporter) rollup(data grohl.Data, firstline string) string {
r.hash.Reset()
io.WriteString(r.hash, fmt.Sprintf("%s:%s:%s", data["ns"], data["fn"], firstline))
return fmt.Sprintf("%x", r.hash.Sum(nil))
hash := md5.New()
io.WriteString(hash, fmt.Sprintf("%s:%s:%s", data["ns"], data["fn"], firstline))
return fmt.Sprintf("%x", hash.Sum(nil))
}