Skip to content

Conversation

@emicovi
Copy link
Contributor

@emicovi emicovi commented Nov 10, 2025

Summary

This patch gives explicit names to internal Fastify hook callbacks used by the OpenTelemetry instrumentation plugin so spans show meaningful callback names instead of anonymous functions.

What changed

  • Named the handlers registered with instance.addHook for:
    • onRouteonRouteHook
    • onRequestonRequestHook
    • onResponseonResponseHook
  • Added an "Unreleased" chore entry in CHANGELOG.md referencing this change.

Why

Named hook handlers improve span attribution in tracing and align with the repository-wide initiative to avoid anonymous hook handlers (see issue #110). This is a non-behavioral refactor intended to make traces clearer and easier to debug.

Tests

  • Ran locally: npm test
  • Result: 45 tests passed, 0 failures; 100% coverage.

Related

Notes

  • Non-breaking change; purely naming/refactor.
  • CI may show "workflow awaiting approval" — a maintainer might need to approve workflow runs for this PR.

Copy link
Member

@Fdawgs Fdawgs left a comment

Choose a reason for hiding this comment

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

Please revert stylistic changes like whitespace, quotes etc.

@emicovi
Copy link
Contributor Author

emicovi commented Nov 10, 2025

Please revert stylistic changes like whitespace, quotes etc.

Done. Sorry for that

@emicovi emicovi requested a review from Fdawgs November 10, 2025 11:33
@Fdawgs
Copy link
Member

Fdawgs commented Nov 10, 2025

Please revert stylistic changes like whitespace, quotes etc.

Done. Sorry for that

Quite a lot still there

@emicovi
Copy link
Contributor Author

emicovi commented Nov 10, 2025

Please revert stylistic changes like whitespace, quotes etc.

Done. Sorry for that

Quite a lot still there

Rebased on latest upstream/main and force-pushed. Thanks again

@emicovi
Copy link
Contributor Author

emicovi commented Nov 10, 2025

Applied suggestion. Thanks

@metcoder95 metcoder95 changed the title chore: name Fastify hook handlers feat: name Fastify hook handlers Nov 11, 2025
@Fdawgs Fdawgs changed the title feat: name Fastify hook handlers refactor: name Fastify hook handlers Nov 16, 2025
@metcoder95 metcoder95 merged commit 5af5eca into fastify:main Nov 26, 2025
17 checks passed
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.

Introduce named function across org

4 participants