Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 7823041

Browse files
authored
don't panic if internal.MeasurementRecorder hasn't been initialized (#1290)
1 parent 0028eea commit 7823041

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

stats/record.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ func Record(ctx context.Context, ms ...Measurement) {
9696
if len(ms) == 0 {
9797
return
9898
}
99-
recorder := internal.MeasurementRecorder.(measurementRecorder)
99+
recorder, initialized := internal.MeasurementRecorder.(measurementRecorder)
100+
if !initialized {
101+
// The init function in view/worker.go has not been run yet. It is
102+
// safe to assume no view has been registered and drop the measurement.
103+
return
104+
}
100105
record := false
101106
for _, m := range ms {
102107
if m.desc.subscribed() {

0 commit comments

Comments
 (0)