Add vercel.functions.metric() - #273
Open
tobiaslins wants to merge 1 commit into
Open
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
tobiaslins
marked this pull request as ready for review
August 10, 2026 09:46
elprans
reviewed
Aug 10, 2026
| _cv_wait_until: ContextVar[Callable[[Awaitable[object]], None] | None] = ContextVar( | ||
| "vercel_wait_until", default=None | ||
| ) | ||
| _cv_metric: ContextVar[_MetricCallback | None] = ContextVar("vercel_metric", default=None) |
Collaborator
There was a problem hiding this comment.
This is an odd location for this. vercel/functions would be more appropriate. Also, ContextVar is probably not the right vehicle because the callback does not change between requests, so it should just be a global.
Collaborator
There was a problem hiding this comment.
Also, I would reverse this. Instead of the runtime patching the SDK, the SDK should detect the presence of the runtime and call runtime callbacks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vercel.functions.metric(name, value, tags=None)Why
This gives Python Functions the same custom metric helper as
@vercel/functions, while keeping transport details owned by the runtime. Documentation is intentionally omitted during the soft launch.This PR pairs with the Python runtime IPC change in https://github.com/vercel/vercel-internal/pull/178.
Validation
uv run --no-sync poe test vercel vercel-cache(1062 passed, 27 credential-gated tests skipped)uv run --no-sync poe lint vercel vercel-cacheuv run poe typecheck vercel vercel-cacheThe required
vercelfeature andvercel-cacheinternal news fragments are included. The localcheck-news-fragmentscommand could not run because uv 0.11.2 removed theworkspace metadata --lockedoption still used by the repository script.