Skip to content

Commit

Permalink
otelzap: Add skeleton for array encoder (#5611)
Browse files Browse the repository at this point in the history
Part of
#5191

Pre-work
#5279

This PR adds skeleton for arrayEncoder
  • Loading branch information
khushijain21 authored May 21, 2024
1 parent c47a69c commit e6f7c8e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bridges/otelzap/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func NewCore(name string, opts ...Option) *Core {
}
}

// LevelEnabler decides whether a given logging level is enabled when logging a message.
// Enabled decides whether a given logging level is enabled when logging a message.
func (o *Core) Enabled(level zapcore.Level) bool {
r := log.Record{}
r.SetSeverity(convertLevel(level))
Expand Down
47 changes: 46 additions & 1 deletion bridges/otelzap/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import (
"go.opentelemetry.io/otel/log"
)

var _ zapcore.ObjectEncoder = (*objectEncoder)(nil)
var (
_ zapcore.ObjectEncoder = (*objectEncoder)(nil)
_ zapcore.ArrayEncoder = (*arrayEncoder)(nil)
)

// objectEncoder implements zapcore.ObjectEncoder.
// It encodes given fields to OTel key-values.
Expand Down Expand Up @@ -146,3 +149,45 @@ func assignUintValue(v uint64) log.Value {
}
return log.Int64Value(int64(v))
}

// arrayEncoder implements [zapcore.ArrayEncoder].
type arrayEncoder struct {
elems []log.Value // nolint:unused
}

// TODO.
func (a *arrayEncoder) AppendArray(v zapcore.ArrayMarshaler) error {
return nil
}

// TODO.
func (a *arrayEncoder) AppendObject(v zapcore.ObjectMarshaler) error {
return nil
}

// TODO.
func (a *arrayEncoder) AppendReflected(v interface{}) error {
return nil
}

// TODO.
func (a *arrayEncoder) AppendComplex128(v complex128) {}
func (a *arrayEncoder) AppendFloat32(v float32) {}
func (a *arrayEncoder) AppendByteString(v []byte) {}
func (a *arrayEncoder) AppendBool(v bool) {}
func (a *arrayEncoder) AppendUint64(v uint64) {}
func (a *arrayEncoder) AppendFloat64(v float64) {}
func (a *arrayEncoder) AppendInt(v int) {}
func (a *arrayEncoder) AppendInt64(v int64) {}
func (a *arrayEncoder) AppendString(v string) {}
func (a *arrayEncoder) AppendComplex64(v complex64) {}
func (a *arrayEncoder) AppendDuration(v time.Duration) {}
func (a *arrayEncoder) AppendInt32(v int32) {}
func (a *arrayEncoder) AppendInt16(v int16) {}
func (a *arrayEncoder) AppendInt8(v int8) {}
func (a *arrayEncoder) AppendTime(v time.Time) {}
func (a *arrayEncoder) AppendUint(v uint) {}
func (a *arrayEncoder) AppendUint32(v uint32) {}
func (a *arrayEncoder) AppendUint16(v uint16) {}
func (a *arrayEncoder) AppendUint8(v uint8) {}
func (a *arrayEncoder) AppendUintptr(v uintptr) {}

0 comments on commit e6f7c8e

Please sign in to comment.