File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,10 +26,7 @@ func (c *ChipIngressEmitter) Close() error {
2626}
2727
2828func (c * ChipIngressEmitter ) Emit (ctx context.Context , body []byte , attrKVs ... any ) error {
29- return c .BatchEmit (ctx , Message {
30- Body : body ,
31- Attrs : ExtractAttributes (attrKVs ... ),
32- })
29+ return c .BatchEmit (ctx , NewMessage (body , attrKVs ... ))
3330}
3431
3532func (c * ChipIngressEmitter ) BatchEmit (ctx context.Context , messages ... Message ) error {
Original file line number Diff line number Diff line change @@ -31,8 +31,9 @@ import (
3131const defaultGRPCCompressor = "gzip"
3232
3333type Emitter interface {
34- // Sends message with bytes and attributes to OTel Collector
34+ // Emit Sends message with bytes and attributes to OTel Collector
3535 Emit (ctx context.Context , body []byte , attrKVs ... any ) error
36+ BatchEmit (ctx context.Context , messages ... Message ) error
3637 io.Closer
3738}
3839
Original file line number Diff line number Diff line change @@ -22,10 +22,15 @@ func (e messageEmitter) Close() error { return nil }
2222// Emits logs the message, but does not wait for the message to be processed.
2323// Open question: what are pros/cons for using use map[]any vs use otellog.KeyValue
2424func (e messageEmitter ) Emit (ctx context.Context , body []byte , attrKVs ... any ) error {
25- message := NewMessage (body , attrKVs ... )
26- if err := message .Validate (); err != nil {
27- return err
25+ return e .BatchEmit (ctx , NewMessage (body , attrKVs ... ))
26+ }
27+
28+ func (e messageEmitter ) BatchEmit (ctx context.Context , messages ... Message ) error {
29+ for _ , message := range messages {
30+ if err := message .Validate (); err != nil {
31+ return err
32+ }
33+ e .messageLogger .Emit (ctx , message .OtelRecord ())
2834 }
29- e .messageLogger .Emit (ctx , message .OtelRecord ())
3035 return nil
3136}
You can’t perform that action at this time.
0 commit comments