Rust implementation of Aino.io logging agent.
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.
Add this to your Cargo.toml
:
toml
[dependencies]
ainoio-agent = "1.0"
Now, you can use ainoio-agent:
rust
use ainoio_agent;
Agent is configured with an TOML configuration file. Below is an example.
rust
let config = ainoio_agent::AinoConfig::new().expect("Failed to load aino configuration");
toml
[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/
Logging is done by creating a Transaction
object and passing it to the agent:
```rust
use ainoio_agent;
use std::time::SystemTime;
// Load the configuration let config = ainoioagent::AinoConfig::new().expect("Failed to load aino configuration"); // Start the Aino agent // This must be called exactly once before any transactions are sent ainoioagent::start(config);
let timestamp = SystemTime::now().durationsince(SystemTime::UNIXEPOCH).unwrap();
// Create transaction object let mut transaction = ainoioagent::Transaction::new("SAP".tostring(), "Card Management".tostring(), "Payment".tostring(), ainoioagent::Status::Success, timestamp.asmillis(), "1249F41E55A1123FB".tostring()); transaction.message = Some("Data transfer successful.".tostring()); transaction.payloadtype = Some("Product Update".tostring());
let metadata = ainoioagent::TransactionMetadata::new("Card API".tostring(), "https://somecardsystem.com".tostring()); transaction.addmetadata(metadata);
let id = ainoioagent::TransactionId::new("OrderId".tostring(), vec!["123456".tostring(), "xxasd".tostring()]); transaction.add_id(id);
// Add the transaction into the queue, it will be sent after `sendinterval' has elapsed at the latests ainoioagent::add_transaction(transaction).expect("Failed to add transaction to the send queue."); ```
Copyright © 2020 Aino.io. Licensed under the Apache 2.0 License.