Skip to content

Commit

Permalink
model a metric
Browse files Browse the repository at this point in the history
  • Loading branch information
j-white committed May 3, 2024
1 parent d8ebc4c commit bfb0654
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/gql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ pub async fn perform_my_query(variables: get_workers_analytics_query::Variables)
let res = client.post("/graphql").json(&request_body).send().await?;
let response: get_workers_analytics_query::ResponseData = res.json().await?;
let _ = response.viewer.unwrap().accounts.iter().map(|account| account.workers_invocations_adaptive.iter().map(|worker| {
let subrequests = worker.sum.as_ref().unwrap().subrequests;
let meter = global::meter("mylibraryname");
// See https://github.com/lablabs/cloudflare-exporter/blob/05e80d9cc5034c5a40b08f7630e6ca5a54c66b20/prometheus.go#L44C61-L44C93
let requests = worker.sum.as_ref().unwrap().requests;
let meter = global::meter("cloudflare_worker_requests");
let gauge = meter
.u64_gauge("my_gauge")
.with_description("A gauge set to 1.0")
.with_unit(Unit::new("myunit"))
.u64_gauge("count")
.with_description("A gauge of the number of requests to a worker.")
.with_unit(Unit::new("requests"))
.init();
gauge.record(
subrequests,
requests,
&[
KeyValue::new("mykey1", "myvalue1"),
KeyValue::new("mykey2", "myvalue2"),
KeyValue::new("script_name", worker.dimensions.as_ref().unwrap().script_name.clone())
],
);
}));
Expand Down

0 comments on commit bfb0654

Please sign in to comment.