<commit_before>package messages

import (
	"bytes"
	"sort"
	"time"

	"github.com/cloudfoundry/sonde-go/events"
)

type Metric struct {
	Name      string
	Value     float64
	EventTime time.Time
	Unit      string // TODO Should this be "1" if it's empty?
}

// MetricEvent represents the translation of an events.Envelope into a set
// of Metrics
type MetricEvent struct {
	Labels  map[string]string
	Metrics []*Metric
	Type    events.Envelope_EventType `json:"-"`
}

func (m *MetricEvent) Hash() string {
	var b bytes.Buffer

	// Extract keys to a slice and sort it
	keys := make([]string, len(m.Labels), len(m.Labels))
	for k, _ := range m.Labels {
		keys = append(keys, k)
	}
	sort.Strings(keys)<commit_msg>messages/metric: Don't emit Labels on messages.MetricEvent<commit_after>package messages

import (
	"bytes"
	"sort"
	"time"

	"github.com/cloudfoundry/sonde-go/events"
)

type Metric struct {
	Name      string
	Value     float64
	EventTime time.Time
	Unit      string // TODO Should this be "1" if it's empty?
}

// MetricEvent represents the translation of an events.Envelope into a set
// of Metrics
type MetricEvent struct {
	Labels  map[string]string `json:"-"`
	Metrics []*Metric
	Type    events.Envelope_EventType `json:"-"`
}

func (m *MetricEvent) Hash() string {
	var b bytes.Buffer

	// Extract keys to a slice and sort it
	keys := make([]string, len(m.Labels), len(m.Labels))
	for k, _ := range m.Labels {
		keys = append(keys, k)
	}
	sort.Strings(keys)
{'fraction_non_alphanumeric': 0.11820652173913043, 'fraction_numerical': 0.004076086956521739, 'mean_word_length': 3.5462962962962963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '400705', 'n_tokens_mistral': 514, 'n_tokens_neox': 499, 'n_words': 157}