Skip to content

Commit a49f79b

Browse files
committed
internal/telemetry: hide event.Type
Change-Id: I390102bbffaa242051cc131ef0659a6544aa89c6 Reviewed-on: https://go-review.googlesource.com/c/tools/+/224938 Run-TryBot: Ian Cottrell <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]>
1 parent f207553 commit a49f79b

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

internal/telemetry/event/event.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ const (
2222
)
2323

2424
type Event struct {
25-
Type eventType
25+
typ eventType
2626
At time.Time
2727
Message string
2828
Error error
2929

3030
tags []Tag
3131
}
3232

33-
func (e Event) IsLog() bool { return e.Type == LogType }
34-
func (e Event) IsEndSpan() bool { return e.Type == EndSpanType }
35-
func (e Event) IsStartSpan() bool { return e.Type == StartSpanType }
36-
func (e Event) IsLabel() bool { return e.Type == LabelType }
37-
func (e Event) IsDetach() bool { return e.Type == DetachType }
38-
func (e Event) IsRecord() bool { return e.Type == RecordType }
33+
func (e Event) IsLog() bool { return e.typ == LogType }
34+
func (e Event) IsEndSpan() bool { return e.typ == EndSpanType }
35+
func (e Event) IsStartSpan() bool { return e.typ == StartSpanType }
36+
func (e Event) IsLabel() bool { return e.typ == LabelType }
37+
func (e Event) IsDetach() bool { return e.typ == DetachType }
38+
func (e Event) IsRecord() bool { return e.typ == RecordType }
3939

4040
func (e Event) Format(f fmt.State, r rune) {
4141
if !e.At.IsZero() {

internal/telemetry/event/label.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
// Label sends a label event to the exporter with the supplied tags.
1212
func Label(ctx context.Context, tags ...Tag) context.Context {
1313
return dispatch(ctx, Event{
14-
Type: LabelType,
14+
typ: LabelType,
1515
tags: tags,
1616
})
1717
}

internal/telemetry/event/log.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// Log sends a log event with the supplied tag list to the exporter.
1313
func Log(ctx context.Context, tags ...Tag) {
1414
dispatch(ctx, Event{
15-
Type: LogType,
15+
typ: LogType,
1616
tags: tags,
1717
})
1818
}
@@ -21,7 +21,7 @@ func Log(ctx context.Context, tags ...Tag) {
2121
// before delivering them to the exporter.
2222
func Print(ctx context.Context, message string, tags ...Tag) {
2323
dispatch(ctx, Event{
24-
Type: LogType,
24+
typ: LogType,
2525
Message: message,
2626
tags: tags,
2727
})
@@ -36,7 +36,7 @@ func Error(ctx context.Context, message string, err error, tags ...Tag) {
3636
message = ""
3737
}
3838
dispatch(ctx, Event{
39-
Type: LogType,
39+
typ: LogType,
4040
Message: message,
4141
Error: err,
4242
tags: tags,

internal/telemetry/event/metric.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func Record(ctx context.Context, tags ...Tag) {
1212
dispatch(ctx, Event{
13-
Type: RecordType,
13+
typ: RecordType,
1414
tags: tags,
1515
})
1616
}

internal/telemetry/event/trace.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ import (
1010

1111
func StartSpan(ctx context.Context, name string, tags ...Tag) (context.Context, func()) {
1212
ctx = dispatch(ctx, Event{
13-
Type: StartSpanType,
13+
typ: StartSpanType,
1414
Message: name,
1515
tags: tags,
1616
})
1717
return ctx, func() {
18-
dispatch(ctx, Event{
19-
Type: EndSpanType,
20-
})
18+
dispatch(ctx, Event{typ: EndSpanType})
2119
}
2220
}
2321

2422
// Detach returns a context without an associated span.
2523
// This allows the creation of spans that are not children of the current span.
2624
func Detach(ctx context.Context) context.Context {
27-
return dispatch(ctx, Event{Type: DetachType})
25+
return dispatch(ctx, Event{typ: DetachType})
2826
}

0 commit comments

Comments
 (0)