Guides
...
Usage Metering
Ingestion Options

SDK Sample Code

6min

This sample illustrates ingesting meters in a Spring boot app.

Steps:

  1. Setup Amberflo environment
  2. Setup configuration for service discovery of Amberflo ingestion client
  3. Create helper for mapping object to Amberflo ingestion payload

Maven dependencies (check for latest versions):

XML


Setup the environment to configure Amberflo client settings

  1. Setup the environment to configure the Amberflo SDK client settings
  2. Add the following entries to the
  3. Set up an environment for service discoverable.
application.properties

Document image

Java


Setup Amberflo client bean for service discoverability

  1. Amberflo provides a singleton instance of the Amberflo client to make the ingestion process more efficient. In order to make this client a discoverable service that can be injected as a dependency, create a configuration to return the client instance as a bean.
Java


Entity to Amberflo payload mapper

In this approach, the entity is transformed to the ingestion payload using a helper. In this sample, we have an entity called Event which is mapped to the Amberflo SDK ingestion payload in the AmberfloMapper class.

Now AmberfloMapper.ingestMeterForEvent() can be called from anywhere in your code.

Sample entity class:

Java


Sample mapper helper:

Java




Updated 06 Nov 2024
Doc contributor
Did this page help you?