<commit_before>// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package event provides support for event based telemetry.
package event

import (
	"fmt"
	"time"
)

type eventType uint8

const (
	LogType = eventType(iota)
	StartSpanType
	EndSpanType
	LabelType
	DetachType
	RecordType
)

type Event struct {
	typ     eventType
	At      time.Time
	Message string
	Error   error

	tags []Tag
}

func (e Event) IsLog() bool       { return e.typ == LogType }
func (e Event) IsEndSpan() bool   { return e.typ == EndSpanType }
func (e Event) IsStartSpan() bool { return e.typ == StartSpanType }
func (e Event) IsLabel() bool     { return e.typ == LabelType }
func (e Event) IsDetach() bool    { return e.typ == DetachType }
func (e Event) IsRecord() bool    { return e.typ == RecordType }

func (e Event) Format(f fmt.State, r rune) {
	if !e.At.IsZero() {
		fmt.Fprint(f, e.At.Format("2006/01/02 15:04:05 "))
	}
	fmt.Fprint(f, e.Message)
	if e.Error != nil {
		if f.Flag('+') {
			fmt.Fprintf(f, ": %+v", e.Error)
		} else {
			fmt.Fprintf(f, ": %v", e.Error)
		}
	}
	for it := e.Tags(); it.Valid(); it.Advance() {
		tag := it.Tag()
		fmt.Fprintf(f, "\n\t%s = %v", tag.Key.Name(), tag.Value)
	}
}

func (ev Event) Tags() TagIterator {
	if len(ev.tags) == 0 {
		return TagIterator{}
	}
	return NewTagIterator(ev.tags...)
}

func (ev Event) Map() TagMap {
	return NewTagMap(ev.tags...)
}<commit_msg>internal/telemetry: normalize the event reciever names to all use ev<commit_after>// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package event provides support for event based telemetry.
package event

import (
	"fmt"
	"time"
)

type eventType uint8

const (
	LogType = eventType(iota)
	StartSpanType
	EndSpanType
	LabelType
	DetachType
	RecordType
)

type Event struct {
	typ     eventType
	At      time.Time
	Message string
	Error   error

	tags []Tag
}

func (ev Event) IsLog() bool       { return ev.typ == LogType }
func (ev Event) IsEndSpan() bool   { return ev.typ == EndSpanType }
func (ev Event) IsStartSpan() bool { return ev.typ == StartSpanType }
func (ev Event) IsLabel() bool     { return ev.typ == LabelType }
func (ev Event) IsDetach() bool    { return ev.typ == DetachType }
func (ev Event) IsRecord() bool    { return ev.typ == RecordType }

func (ev Event) Format(f fmt.State, r rune) {
	if !ev.At.IsZero() {
		fmt.Fprint(f, ev.At.Format("2006/01/02 15:04:05 "))
	}
	fmt.Fprint(f, ev.Message)
	if ev.Error != nil {
		if f.Flag('+') {
			fmt.Fprintf(f, ": %+v", ev.Error)
		} else {
			fmt.Fprintf(f, ": %v", ev.Error)
		}
	}
	for it := ev.Tags(); it.Valid(); it.Advance() {
		tag := it.Tag()
		fmt.Fprintf(f, "\n\t%s = %v", tag.Key.Name(), tag.Value)
	}
}

func (ev Event) Tags() TagIterator {
	if len(ev.tags) == 0 {
		return TagIterator{}
	}
	return NewTagIterator(ev.tags...)
}

func (ev Event) Map() TagMap {
	return NewTagMap(ev.tags...)
}
{'fraction_non_alphanumeric': 0.14790788193318197, 'fraction_numerical': 0.012974375608173857, 'mean_word_length': 3.2073669849931785, 'pattern_counts': {'":': 4, '<': 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': '343803', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1126, 'n_words': 349}