Skip to content

fix: WebMock instrumentation with Typhoeus#66

Merged
jgraichen merged 1 commit intomainfrom
fix/webmock
Feb 16, 2025
Merged

fix: WebMock instrumentation with Typhoeus#66
jgraichen merged 1 commit intomainfrom
fix/webmock

Conversation

@jgraichen
Copy link
Copy Markdown
Owner

The WebMock instrumentation for Typhoeus::Hydra didn't work anymore with the patches Restify added to its Hydra object to keep track of the OTEL context. The patched removed the callback behavior in Hydra that was used by WebMock.

This commit fixes that by keeping tracking of the OTEL context with the Typhoeus request itself, restoring the context when Hydra actually adds the request. Otherwise, the same code is called as before and callbacks will work again too.

The WebMock support is further expanded to catch exceptions and bubble them up to the promise, e.g. when request ain't allowed. Before, they only stopped the background thread, and promises run into a timeout. Now, whenever an exception is raised to a specific request, it will instead reject the Promise of that request.

Lastly, the commit adds specs for the WebMock integration as well as the working OTEL context propagation.

The WebMock instrumentation for Typhoeus::Hydra didn't work anymore with
the patches Restify added to it's Hydra object to keep track of the OTEL
context. The patched removed the callback behavior in Hydra that was
used by WebMock.

This commit fixes that by keeping tracking of the OTEL context with the
Typhoeus request itself, restoring the context when Hydra actually adds
the request. Otherwise, the same code is called as before and callbacks
will work again too.

The WebMock support is further expanded to catch exception and bubble
them up to the promise, e.g. when request ain't allowed. Before, they
only stopped the background thread, and promises run into a timeout.
Now, whenever an exception is raised to a specific request, it will
instead reject the Promise of that request.

Lastly, the commit adds specs for the WebMock integration as well as the
working OTEL context propagation.
@jgraichen jgraichen added the bug label Feb 16, 2025
@jgraichen jgraichen self-assigned this Feb 16, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.88%. Comparing base (b9ee383) to head (5ebc2aa).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #66      +/-   ##
==========================================
+ Coverage   95.87%   95.88%   +0.01%     
==========================================
  Files          21       21              
  Lines         678      681       +3     
==========================================
+ Hits          650      653       +3     
  Misses         28       28              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jgraichen jgraichen merged commit f34ea0b into main Feb 16, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant