Snowplow (java) tracker on AWS lambda

Hello all,

I have deployed a data collection pipeline implemented on AWS using lambdas (java 11). When an event is received by our API-Gateway a series of lambdas are invoked to get information from an API pass that to SQS, another lambda then process the data and fires a snowplow structured event to our collector.

I have an AWS lambda function that creates a snowplow tracker and emitter fires an event to our collector and finishes.

I’m using the SimpleEmitter which creates a runnable task and executes it via executor service

Sometimes the main thread finishes before the executor is invoked (as my lambda is very small) and the event isn’t fired, and no error message

  • I couldn’t find a “blocking emitter” that i could use? (I don’t want to use version 0.7.0 :slight_smile: )
  • Is there a better solution all together to fire events from AWS lambda?

I would appreciate any advice from your experience

Thanks.

Hi @avi_eshel_ct

I’m assuming you’re using the Snowplow Java Tracker given your description (hopefully v0.10.1), if so you should be able to use the BatchEmitter and once all events are sent, call emitter.close() which will flush events and block until the events are flushed and the threads are stopped.

The example in the repository demonstrates this and it doesn’t exit until the events are sent: https://github.com/snowplow/snowplow-java-tracker/blob/d60f3f75b9efbbca7310876f7e9f17d394d4540a/examples/simple-console/src/main/java/com/snowplowanalytics/Main.java#L52

1 Like