Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add evaluation details to finally hook #280

Merged
merged 4 commits into from
Dec 6, 2024

Conversation

beeme1mr
Copy link
Member

@beeme1mr beeme1mr commented Nov 19, 2024

This PR

  • extends the finally stage in hooks to include evaluation details.

Related Issues

#281

Notes

This is a breaking change but will significantly enhance the usefulness of the finally stage. Currently, the finally stage is used to perform end-of-transaction or clean-up tasks. If this proposal is accepted, the finally stage will have access to the same evaluation details that are returned to the application author.

This change will make implementing the OpenTelemetry Feature Flag Semantic Convention changes easier because the evaluation details in the finally stage can contain all the telemetry we'll need. Values like flag set id and flag set version can be supplied via flag metadata, which isn't accessible in the error or current finally stages.

Here's a draft PR showing how this could be implemented in JavaScript.

Follow-up Tasks

Implement the changes in all SDKs.

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Copy link
Member

@lukas-reining lukas-reining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the change, I am just wondering if we should make this a breaking change.
Maybe we could avoid it as stated in the comment.

specification/sections/04-hooks.md Outdated Show resolved Hide resolved
specification/sections/04-hooks.md Show resolved Hide resolved
Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment here.

But mostly I'd like to have some consensus on this before we get to implementaiton.

beeme1mr and others added 2 commits November 27, 2024 12:25
@beeme1mr beeme1mr self-assigned this Nov 27, 2024
@beeme1mr
Copy link
Member Author

beeme1mr commented Dec 4, 2024

I'm going to merge on Friday unless there's an objection. Thanks!

@toddbaert toddbaert self-requested a review December 5, 2024 21:01
Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, and for the record, I think we should generally implement this in SDKs as a breaking change without incrementing the major version, using the leeway this policy gives us. I really don't think many will be impacted, and I think it's an easy and clear fix for those few who are.

@beeme1mr beeme1mr enabled auto-merge (squash) December 6, 2024 15:46
@beeme1mr beeme1mr merged commit 776ee1f into main Dec 6, 2024
1 check passed
@beeme1mr beeme1mr deleted the expand-finally-hook-stage branch December 6, 2024 15:46
@beeme1mr beeme1mr linked an issue Dec 11, 2024 that may be closed by this pull request
github-merge-queue bot pushed a commit to open-feature/js-sdk that referenced this pull request Dec 12, 2024
## This PR

- adds evaluation details to the `finally` stage in hooks.

### Notes

This breaks the signature of the `finally` stages based on [this spec
enhancement](open-feature/spec#280). It is
**not** considered a breaking change to the SDK because hooks are marked
as experimental in the spec, and the change has no impact on known
hooks.

The noteworthy change to the interface is:

```diff
- finally?(hookContext: Readonly<HookContext<T>>, hookHints?: HookHints): HooksReturn;
+ finally?(hookContext: Readonly<HookContext<T>>, evaluationDetails: EvaluationDetails<T>, hookHints?: HookHints): HooksReturn;
```

### Follow-up Tasks

- Update the JS contribs repo

---------

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
kevinmlong pushed a commit to kevinmlong/openfeature-js-sdk that referenced this pull request Dec 21, 2024
## This PR

- adds evaluation details to the `finally` stage in hooks.

### Notes

This breaks the signature of the `finally` stages based on [this spec
enhancement](open-feature/spec#280). It is
**not** considered a breaking change to the SDK because hooks are marked
as experimental in the spec, and the change has no impact on known
hooks.

The noteworthy change to the interface is:

```diff
- finally?(hookContext: Readonly<HookContext<T>>, hookHints?: HookHints): HooksReturn;
+ finally?(hookContext: Readonly<HookContext<T>>, evaluationDetails: EvaluationDetails<T>, hookHints?: HookHints): HooksReturn;
```

### Follow-up Tasks

- Update the JS contribs repo

---------

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support expanded OpenTelemetry semantic attributes
7 participants