alexslade

alexslade

Ideas for capturing, replaying, and modifying requests like ExVCR but _in production_

This is a bit of an exploratory question, and I’d love any thoughts you have. I’m posting early in my research because I think this might be interesting to others, and I suspect I may have an XY problem.

Goal

Something a bit like ExVCR, but running in production and normally just proxying the requests.

Background

My team runs a lot of data integrations, where we work with often janky and awkward external datasources. They are important requests, but low volume and raw response time is not a primary concern. The big problem: they frequently break and it’s a pain to debug them.

We’re exploring the idea of a man-in-the-middle proxy, that will simply receive, log, and forward events to our API most of them time.

But when we need to, we can turn on interception for some set of urls. Maybe to respond with a previously saved response, or a modified one. Or to simply direct some set of requests to a different host for dev/debugging.

Here’s a real example:

  • We receive POST requests from an oracle service for a kind of SSO
  • We process that data and return a redirect url (in XML) to that request

One day, that request starts failing for some of our customers. We later find out that it was because oracle changed how they parsed XML and now needed URLs inside the XML to be URLescaped (not previously the case).

It took a few days of back and forth to solve this, and really what we wanted was the ability to quickly see and mess with requests that were in flight.

We would do this in a staging/preview environment, rarely on production, but there are use cases when we might want to do it in production. For instance, we have a partner who cannot connect to our preview env, they only support a single endpoint (which is prod).

One approach would be something like nginx, with a configurable “forward” address depending on some matchers (e.g. forward some requests to this temporary URL for debugging), but really we’d like some more control than this.

So I’m looking for pointers, and I’m hoping that there is something obvious like a way to cache a plug conn, and then pipe that back into req with some modifications…

:heart: for any advice

Most Liked

felix-starman

felix-starman

I’ll edit my comment later since I’m on a phone it’s a bit late here but I have meddled with something similar for a mocking library but realized it could be useful in other scenarios, like what you mention.

I’ll put a link to the branch and repositories to give you a starting point if it’s something that you’re interested in, but it is basically a wrapper/spy that you can program.

There’s also a ruby library called suture by a company called testdouble that does something kind of similar to what you were mentioning, although their approach is more for mechanisms to refactor nasty code

Where Next?

Popular in Questions Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement