opentelemetry-go icon indicating copy to clipboard operation
opentelemetry-go copied to clipboard

fix callback err not return

Open NameHaibinZhang opened this issue 6 months ago • 3 comments

for _, c := range p.callbacks {
	// TODO make the callbacks parallel. ( #3034 )
	if e := c(ctx); e != nil {
		err = errors.Join(err, e)
	}
	if err := ctx.Err(); err != nil {
		rm.Resource = nil
		clear(rm.ScopeMetrics) // Erase elements to let GC collect objects.
		rm.ScopeMetrics = rm.ScopeMetrics[:0]
		return err
	}
}
for e := p.multiCallbacks.Front(); e != nil; e = e.Next() {
	// TODO make the callbacks parallel. ( #3034 )
	f := e.Value.(multiCallback)
	if e := f(ctx); e != nil {
		err = errors.Join(err, e)
	}
	if err := ctx.Err(); err != nil {
		// This means the context expired before we finished running callbacks.
		rm.Resource = nil
		clear(rm.ScopeMetrics) // Erase elements to let GC collect objects.
		rm.ScopeMetrics = rm.ScopeMetrics[:0]
		return err
	}
}

if ctx.Err() is not nil, the c(ctx) err is not return

NameHaibinZhang avatar May 30 '25 03:05 NameHaibinZhang

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: NameHaibinZhang / name: Zhanghaibin (9e8fd1416f2fc15de36fbd03b1be8481117341fd)

Thank you for the PR.

Can you add a changelog entry and add a unit tests to cover these cases?

pellared avatar May 30 '25 07:05 pellared

Thank you for the PR.

Can you add a changelog entry and add a unit tests to cover these cases?

ok,i will add test

NameHaibinZhang avatar Jun 01 '25 04:06 NameHaibinZhang

@NameHaibinZhang, are you able to work on this PR?

pellared avatar Jul 11 '25 08:07 pellared

Superseded by https://github.com/open-telemetry/opentelemetry-go/pull/6914.

MrAlias avatar Jul 31 '25 18:07 MrAlias