Skip to content

Commit f5502b1

Browse files
committed
fix emitters
1 parent 53cffcf commit f5502b1

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

pkg/beholder/dual_source_emitter.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ func (d *DualSourceEmitter) Close() error {
5656
}
5757

5858
func (d *DualSourceEmitter) Emit(ctx context.Context, body []byte, attrKVs ...any) error {
59+
return d.BatchEmit(ctx, NewMessage(body, attrKVs...))
60+
}
5961

62+
func (d *DualSourceEmitter) BatchEmit(ctx context.Context, messages ...Message) error {
6063
// Emit via OTLP first
61-
if err := d.otelCollectorEmitter.Emit(ctx, body, attrKVs...); err != nil {
64+
if err := d.otelCollectorEmitter.BatchEmit(ctx, messages...); err != nil {
6265
return err
6366
}
6467

@@ -72,7 +75,7 @@ func (d *DualSourceEmitter) Emit(ctx context.Context, body []byte, attrKVs ...an
7275
ctx, cancel = d.stopCh.Ctx(ctx)
7376
defer cancel()
7477

75-
if err := d.chipIngressEmitter.Emit(ctx, body, attrKVs...); err != nil {
78+
if err := d.chipIngressEmitter.BatchEmit(ctx, messages...); err != nil {
7679
// If the chip ingress emitter fails, we ONLY log the error
7780
// because we still want to send the data to the OTLP collector and not cause disruption
7881
d.log.Infof("failed to emit to chip ingress: %v", err)

pkg/beholder/noop.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ func (e noopMessageEmitter) Close() error { return nil }
108108
func (noopMessageEmitter) Emit(ctx context.Context, body []byte, attrKVs ...any) error {
109109
return nil
110110
}
111+
112+
func (noopMessageEmitter) BatchEmit(ctx context.Context, messages ...Message) error {
113+
return nil
114+
}
115+
111116
func (noopMessageEmitter) EmitMessage(ctx context.Context, message Message) error {
112117
return nil
113118
}

0 commit comments

Comments
 (0)