Skip to content

Commit

Permalink
not use ctx as param
Browse files Browse the repository at this point in the history
  • Loading branch information
khushijain21 committed Jun 3, 2024
1 parent 5e20a77 commit f59e941
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bridges/otelzap/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (o *Core) With(fields []zapcore.Field) zapcore.Core {
cloned := o.clone()
if len(fields) > 0 {
ctx, attrbuf := convertField(fields)
if ctx != nil {
if ctx != nil {
cloned.ctx = ctx
}
cloned.attr = append(cloned.attr, attrbuf...)
Expand Down Expand Up @@ -162,7 +162,7 @@ func (o *Core) Write(ent zapcore.Entry, fields []zapcore.Field) error {
r.AddAttributes(o.attr...)
if len(fields) > 0 {
ctx, attrbuf := convertField(fields)
if ctx != nil {
if ctx != nil {
o.ctx = ctx
}
r.AddAttributes(attrbuf...)
Expand All @@ -172,8 +172,9 @@ func (o *Core) Write(ent zapcore.Entry, fields []zapcore.Field) error {
return nil
}

func convertField(ctx context.Context, fields []zapcore.Field) (context.Context, []log.KeyValue) {
func convertField(fields []zapcore.Field) (context.Context, []log.KeyValue) {
// TODO: Use objectEncoder from a pool instead of newObjectEncoder.
var ctx context.Context
enc := newObjectEncoder(len(fields))
for _, field := range fields {
if ctxFld, ok := field.Interface.(context.Context); ok {
Expand Down

0 comments on commit f59e941

Please sign in to comment.