Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/auth/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub fn read_only_scopes() -> Vec<&'static str> {
pub fn default_scopes() -> Vec<&'static str> {
vec![
// APM
"apm_generate_metrics",
Comment thread
srosenthal-dd marked this conversation as resolved.
"apm_read",
"apm_remote_configuration_read",
"apm_remote_configuration_write",
Expand Down
10 changes: 5 additions & 5 deletions src/commands/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::util_ext;
// ---------------------------------------------------------------------------

pub async fn metrics_list(cfg: &Config) -> Result<()> {
let api = crate::make_api_no_auth!(SpansMetricsAPI, cfg);
let api = crate::make_api!(SpansMetricsAPI, cfg);
Comment thread
srosenthal-dd marked this conversation as resolved.
let resp = api
.list_spans_metrics()
.await
Expand All @@ -27,7 +27,7 @@ pub async fn metrics_list(cfg: &Config) -> Result<()> {
}

pub async fn metrics_get(cfg: &Config, metric_id: &str) -> Result<()> {
let api = crate::make_api_no_auth!(SpansMetricsAPI, cfg);
let api = crate::make_api!(SpansMetricsAPI, cfg);
let resp = api
.get_spans_metric(metric_id.to_string())
.await
Expand All @@ -38,7 +38,7 @@ pub async fn metrics_get(cfg: &Config, metric_id: &str) -> Result<()> {
pub async fn metrics_create(cfg: &Config, file: &str) -> Result<()> {
let body: datadog_api_client::datadogV2::model::SpansMetricCreateRequest =
util::read_json_file(file)?;
let api = crate::make_api_no_auth!(SpansMetricsAPI, cfg);
let api = crate::make_api!(SpansMetricsAPI, cfg);
let resp = api
.create_spans_metric(body)
.await
Expand All @@ -49,7 +49,7 @@ pub async fn metrics_create(cfg: &Config, file: &str) -> Result<()> {
pub async fn metrics_update(cfg: &Config, metric_id: &str, file: &str) -> Result<()> {
let body: datadog_api_client::datadogV2::model::SpansMetricUpdateRequest =
util::read_json_file(file)?;
let api = crate::make_api_no_auth!(SpansMetricsAPI, cfg);
let api = crate::make_api!(SpansMetricsAPI, cfg);
let resp = api
.update_spans_metric(metric_id.to_string(), body)
.await
Expand All @@ -58,7 +58,7 @@ pub async fn metrics_update(cfg: &Config, metric_id: &str, file: &str) -> Result
}

pub async fn metrics_delete(cfg: &Config, metric_id: &str) -> Result<()> {
let api = crate::make_api_no_auth!(SpansMetricsAPI, cfg);
let api = crate::make_api!(SpansMetricsAPI, cfg);
api.delete_spans_metric(metric_id.to_string())
.await
.map_err(|e| anyhow::anyhow!("failed to delete spans metric: {e:?}"))?;
Expand Down
13 changes: 13 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10001,6 +10001,19 @@ enum TracesActions {
group_by: Option<String>,
},
/// Manage span-based metrics
///
/// Create, list, get, update, and delete metrics generated from span data.
///
/// EXAMPLES:
/// pup traces metrics list
/// pup traces metrics get my-metric-id
/// pup traces metrics create --file metric.json
///
/// AUTHENTICATION:
/// Requires either OAuth2 authentication or API keys.
/// list/get work with the default apm_read scope. create/update/delete
/// require apm_generate_metrics, which is also requested by default.
#[command(verbatim_doc_comment)]
Metrics {
#[command(subcommand)]
action: SpansMetricsActions,
Expand Down