Skip to content

[bridges:otelzap] zapcore.Core does not Sync (flush) #7509

Closed as not planned
Closed as not planned
@Gjergj

Description

@Gjergj

Description

When using the otelzap bridge in a short lived cli application zapcore.Core does not flush on application exit even when calling Sync method.

Environment

  • OS: [macos, linux]
  • Architecture: [ x86, arm64]
  • Go Version: [ go1.24.3]
  • go.opentelemetry.io/contrib/bridges/otelzap v0.11.0

Steps To Reproduce

  1. Using this code ...
 exporter, err = otlploggrpc.New(ctx, opts...)
  processor := sdklog.NewBatchProcessor(exporter)
   res, _ := resource.New(ctx,
   	resource.WithProcess(),
   	resource.WithContainer(),
   	resource.WithProcessExecutableName(),
   	resource.WithHost())
   provider := sdklog.NewLoggerProvider(sdklog.WithResource(res), sdklog.WithProcessor(processor))

   core := otelzap.NewCore("siren", otelzap.WithLoggerProvider(provider))
  1. Run the code (I can provide full main method if needed)
  2. I notice that after application exit the last couple of logs are missing

Expected behavior

Logs to flush/sync

From a quick glance at the code

func (o *Core) Sync() error {
it seems that Sync is not implemented

I can follow up with a PR with possible fix but wanted an opinion or some context why Sync implementation is the way it is

Metadata

Metadata

Assignees

Labels

bridge: zapRelated to the zap bridgebugSomething isn't workingquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions