dwyl / aws-sdk-mock

:rainbow: AWSomocks for Javascript/Node.js aws-sdk tested, documented & maintained. Contributions welcome!
Apache License 2.0
1.1k stars 109 forks source link

AWS XRay support #141

Open DianaIonita opened 6 years ago

DianaIonita commented 6 years ago

I'm adding AWS XRay support in my projects and for that I need to wrap my AWS object like so:

const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));

Once I do that, however, I seem to no longer be able to use aws-sdk-mock - it's not triggering mocked callbacks when mocking, for instance, AWS.Lambda. Is there a known workaround or is this something you might add support for in the future?

Thanks

RichardWright commented 5 years ago

@nelsonic Would this be a good enhancement for someone new to this project to add?

nelsonic commented 5 years ago

PickleRick (@RichardWright), if you're happy to write the tests and feature for this we'd be delighted to receive a pull request! 👍

RichardWright commented 5 years ago

@nelsonic Looking at aws-sdk-mock code, would a mock xray even belong in this project (i.e new repo aws-xray-mock)? It's seperate package and the architecture doesn't fit it. Have you ever thougth about how to do this?

nelsonic commented 5 years ago

@RichardWright good question. the use-case described by @DianaIonita above indicates that the mock would be created by aws-sdk-mock and invocations of AWSXRay would return a mock event/context. We are not using XRay (any more). But give that others have 👍 this issue, we would be glad to get a PR. Yes, it could be a separate package/module but it feels more like a method/service of this one. 🤔

RichardWright commented 5 years ago

@DianaIonita Circling back here..

We used the real xray sdk in conjunction with aws-sdk-mock and it worked. How are you initialising the xray sdk with the aws sdk?

DianaIonita commented 5 years ago

Hi @RichardWright,

Thanks for having a look. I just tried to reproduce this issue again on a fresh repo, but had no luck. I'm not sure what was wrong in the first place, but whatever it was, seems to have fixed itself. If I run into this again, I'll add more details.

Thanks

RichardWright commented 5 years ago

@DianaIonita 👍

RichardWright commented 5 years ago

@nelsonic I guess close the issue? Mocking xray probably belongs to a new module I'd say.