Advice on local testing strategies
Closed this issue · 5 comments
Hello,
I'm experimenting with utilizing embedded metrics in my Lambda functions, which I usually test locally by passing in a sample event to the lambda handler function. This works well, but when using the aws_embedded_metrics package, i get the following error messagewhen running a put_metric call:
Failed to connect to the socket. [Errno 61] Connection refused
Failed to write metrics to the socket. [Errno 32] Broken pipe
Ideas on a way to more gracefully handle this?
Thank you,
You’re seeing the same behavior that we discussed here: awslabs/aws-embedded-metrics-node#18. I’m planning on implementing the same solution in this repo in the next couple weeks. I’d recommend reading through that discussion and the related PR and let me know if you’d like some other behavior.
I’m the meantime, you can see how we mock in our tests here: https://github.com/awslabs/aws-embedded-metrics-python/blob/master/tests/metric_scope/test_metric_scope.py
@jaredcnance Thank you for the response! Yes the proposals in the node repo sounds good, setting an environment var to Local is good.
Thanks,
Paul
This is available in v1.0.6 now.
I am using 1.0.7 and this still fails the same way. I thought it was supposed to log metrics using EMF format. Why does it need a socket?
@atlasgurus are you overriding the environment? The socket is a mode of communication that allows you to use an external agent to buffer the data directly which is currently the recommended option for non-Lambda environments.