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

Proposal: Pattern on when to return `ctx.Err()`

Open pellared opened this issue 2 years ago • 2 comments

Based on: https://github.com/open-telemetry/opentelemetry-go/pull/3990

A function SHOULD NOT return ctx.Err() if the method was not interrupted because of the context passed to a function.

For instance: 1 .There is a func (srv *Service) Shutdown(ctx context.Context) error 2. The Shudown is called the first time. 3. A canceled ctx is passed 4. There is "no work in progress". Therefore, the service can be immediately shutdown. 5. nil is returned as Shutdown succeeded and nothing had to be interrupted.

As part of this issue I propose to

  1. Describe the pattern in CONTRIBUTING.md
  2. we can create bugs for places when we see that this pattern is not followed (e.g. in exporter's shutdown)

pellared avatar Apr 12 '23 19:04 pellared

Hi @pellared I am interested in contributing to the 2nd point mentioned above, Could you help me with creating initial bug/issue to get started with? Thanks.

Kaushal28 avatar May 02 '23 11:05 Kaushal28

@Kaushal28

  1. Find places where this pattern is not followed
  2. For each create an an issue and reference this one as a pattern (e.g. you can write Part of #3991) in the description.

pellared avatar May 04 '23 09:05 pellared