6 stable releases

3.1.0 Mar 27, 2020
3.0.1 Mar 27, 2020
2.1.0 Mar 26, 2020
1.0.0 Mar 24, 2020

#1098 in Database interfaces

26 downloads per month

Apache-2.0

25KB
479 lines

Rust Agent for Aino.io

Aino-io

Rust implementation of Aino.io logging agent.

What is Aino.io and what does this Agent have to do with it?

Aino.io is an analytics and monitoring tool for integrated enterprise applications and digital business processes. Aino.io can help organizations manage, develop, and run the digital parts of their day-to-day business. Read more from our web pages.

Aino.io works by analyzing transactions between enterprise applications and other pieces of software. This Agent helps to store data about the transactions to Aino.io platform using Aino.io Data API (version 2.0). See API documentation for detailed information about the API.

Technical requirements

  • Rust 1.39

1. Usage

Add this to your Cargo.toml:

[dependencies]
ainoio-agent = "1.0"

Now, you can use ainoio-agent:

use ainoio_agent;

2. Configuring the agent

Agent is configured with an TOML configuration file. Below is an example.

let config = ainoio_agent::AinoConfig::new().expect("Failed to load aino configuration");
Configuration file example
[connection]
url = "https://data.aino.io/rest/v2/transaction"
api_key = "<your api key here>"
send_interval = 1000

The configuration files are placed in a config-directory. They are read in the following order:

  1. config/default.toml
  2. config/.toml
    • the environmant is read from the RUN_MODE environment variable.
  3. config/local.toml
    • This should be used to local testing, and should not be commited.
  4. All environment variables prefixed with AINO.

3. Send a request to Aino.io:

Example

Logging is done by creating a Transaction object and passing it to the agent:

use ainoio_agent;
use std::time::SystemTime;

// Load the configuration
let config = ainoio_agent::AinoConfig::new()?;
// Start the Aino agent
// This must be called exactly once before any transactions are sent
ainoio_agent::start(config)?;

let timestamp = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap();

// Create transaction object
let mut transaction = ainoio_agent::Transaction::new("SAP".to_string(),
    "Card Management".to_string(), "Payment".to_string(), ainoio_agent::Status::Success,
    timestamp.as_millis(), "1249F41E55A1123FB".to_string());
transaction.message = Some("Data transfer successful.".to_string());
transaction.payload_type = Some("Product Update".to_string());

let metadata = ainoio_agent::TransactionMetadata::new("Card API".to_string(), "https://somecardsystem.com".to_string());
transaction.add_metadata(metadata);

let id = ainoio_agent::TransactionId::new("OrderId".to_string(), vec!["123456".to_string(), "xxasd".to_string()]);
transaction.add_id(id);

// Add the transaction into the queue, it will be sent after `send_interval' has elapsed at the latests
ainoio_agent::add_transaction(transaction).expect("Failed to add transaction to the send queue.");

License

Copyright © 2020 Aino.io. Licensed under the Apache 2.0 License.

Dependencies

~11MB
~231K SLoC