https://github.com/refcell/ddog
Minimal Datadog SDK Built in Pure Rust
https://github.com/refcell/ddog
Last synced: 9 months ago
JSON representation
Minimal Datadog SDK Built in Pure Rust
- Host: GitHub
- URL: https://github.com/refcell/ddog
- Owner: refcell
- License: gpl-3.0
- Created: 2022-08-09T17:08:51.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-11T15:26:03.000Z (over 2 years ago)
- Last Synced: 2025-05-05T15:54:38.295Z (9 months ago)
- Language: Rust
- Size: 756 KB
- Stars: 7
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# ddog • [](https://github.com/abigger87/ddog/actions/workflows/ci.yaml)  [](https://crates.io/crates/ddog)
A **Minimal** Datadog SDK Built in _Pure_ Rust.
## Getting Started
Add the `ddog` crate to your project:
```toml
ddog = "0.1.0"
```
## Usage
The simplest way to use the Datadog SDK is by using the [Builder](ddog::prelude::Builder).
To create a new builder, you can instantiate one with the [new](ddog::prelude::Builder::new) method: `let mut builder = ddog::prelude::Builder::new();`.
Then, to create a new query with a given endpoint, the Builder has explicit methods exposed for the specified endpoint.
For example, to post metrics series data to datadog, call the [post_series](ddog::prelude::Builder::post_series) method which returns a [Route](ddog::prelude::tr::Route) trait.
## Examples
Below we show how to use [ddog](https://github.com/abigger87/ddog) to post metric series data to the Datadog API.
Note: This request will not succeed since the `DD_API_KEY` environment variable is set to an invalid value in the request headers section.
```rust
use ddog::prelude::*;
async {
let mut builder = builder::Builder::new();
let (status, res) = builder.v2()
.post_series()
.headers(vec![
("Accept", "application/json"),
("Content-Type", "application/json"),
("DD-API-KEY", ""),
("DD-APPLICATION-KEY", ""),
])
.body(
r#"{
"series": [{
"metric": "my.metric.name",
"type": 1,
"interval": 100000,
"unit": "count",
"tags": [ "my_tag:" ],
"source_type_name": "my_source_type",
"resources": [{
"name": "length",
"type": "time"
}],
"points": [
{ "timestamp": 1660157680, "value": 10.0 },
],
"metadata": {
"origin": {
"metric_type": 1,
"product": 1,
"service": 1
}
}
}]
}"#
)
.execute().await;
// This should return a 403 status code now since the above API key is invalid.
println!("Status Code: {:?}", status);
println!("Response: {:?}", res);
};
```
## License
[AGPL-3.0-only](https://github.com/abigger87/ddog/blob/master/LICENSE)
## Acknowledgements
- [datadog-apm-rust-sync](https://github.com/kitsuneninetails/datadog-apm-rust-sync)