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(fastify): add requestHook support #1255

Merged
merged 5 commits into from
Nov 6, 2022

Conversation

luismiramirez
Copy link
Contributor

The requestHook config option allows custom span handling per request layer.

Which problem is this PR solving?

  • Adds requestHook support so users can add custom handling on spans.

Short description of the changes

  • It's inspired by how requestHook is implemented in web instrumentations
  • The requestHook user-defined function is called any time _hookPreHandler() is executed

The `requestHook` config option allows custom span handling per request
layer.
@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

Merging #1255 (38cc88d) into main (3214bf2) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1255      +/-   ##
==========================================
+ Coverage   96.08%   96.09%   +0.01%     
==========================================
  Files          14       19       +5     
  Lines         893     1127     +234     
  Branches      191      233      +42     
==========================================
+ Hits          858     1083     +225     
- Misses         35       44       +9     
Impacted Files Coverage Δ
...try-instrumentation-fastify/src/instrumentation.ts 97.61% <100.00%> (ø)
...telemetry-instrumentation-fastify/src/constants.ts 100.00% <0.00%> (ø)
...opentelemetry-instrumentation-fastify/src/utils.ts 87.50% <0.00%> (ø)
...tapackages/auto-instrumentations-node/src/utils.ts 98.18% <0.00%> (ø)
...nstrumentation-fastify/src/enums/AttributeNames.ts 100.00% <0.00%> (ø)

- Add a test for when an exception is thrown from inside the hook
- Export the types
- Don't use Fastify core types so the package doesn't need to be a
  dependency
- Rephrase docs to be clearer about when the request hook is executed
- Remove sinon
- Use proper component to log hook errors
Copy link
Member

@blumamir blumamir left a comment

Choose a reason for hiding this comment

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

Thanks for addressing everything.
added few nit comments

Copy link
Member

@blumamir blumamir left a comment

Choose a reason for hiding this comment

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

LGTM 🥇

- Fix types in docs
- Make FastifyRequestInfo an interface
- Use SemanticAttributes enums instead of plain strings
- Remove extra diag error call
- Some lint fixes
@blumamir blumamir merged commit c9923e3 into open-telemetry:main Nov 6, 2022
@dyladan dyladan mentioned this pull request Nov 6, 2022
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.

2 participants