diff --git a/src/commands/send_metric/mod.rs b/src/commands/send_metric/mod.rs index 906dd4308a..42f0513b1d 100644 --- a/src/commands/send_metric/mod.rs +++ b/src/commands/send_metric/mod.rs @@ -13,6 +13,17 @@ use anyhow::Result; use clap::{command, Args, Subcommand}; use clap::{ArgMatches, Command, Parser}; +const DEPRECATION_MESSAGE: &str = "DEPRECATION NOTICE: \ + The send-metric commands are deprecated and will be \ + removed in the next major release. \ + Sentry will reject all metrics sent after October 7, 2024. Learn more: \ + https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics"; + +const INCREMENT_ABOUT: &str = "Increment a counter metric"; +const DISTRIBUTION_ABOUT: &str = "Update a distribution metric with the provided value"; +const GAUGE_ABOUT: &str = "Update a gauge metric with the provided value"; +const SET_ABOUT: &str = "Update a set metric with the provided value"; + #[derive(Args)] pub(super) struct SendMetricArgs { #[command(subcommand)] @@ -20,20 +31,26 @@ pub(super) struct SendMetricArgs { } #[derive(Subcommand)] -#[command(about = "Send a metric to Sentry.")] -#[command(long_about = "Send a metric event to Sentry.{n}{n}\ +#[command(about = "[DEPRECATED] Send a metric to Sentry.")] +#[command(long_about = format!("{DEPRECATION_MESSAGE}{{n}}{{n}}\ +Send a metric event to Sentry.{{n}}{{n}}\ This command will validate input parameters and attempt to send a metric to \ Sentry. Due to network errors and rate limits, the metric is not guaranteed to \ arrive. Check the debug output for transmission errors by passing --log-level=\ -debug or setting `SENTRY_LOG_LEVEL=debug`.")] +debug or setting `SENTRY_LOG_LEVEL=debug`."))] +#[command(hide=true)] enum SendMetricSubcommand { - #[command(about = "Increment a counter metric")] + #[command(about = format!("[DEPRECATED] {INCREMENT_ABOUT}"))] + #[command(long_about = format!("{DEPRECATION_MESSAGE}{{n}}{{n}}{INCREMENT_ABOUT}"))] Increment(IncrementMetricArgs), - #[command(about = "Update a distribution metric with the provided value")] + #[command(about = format!("[DEPRECATED] {DISTRIBUTION_ABOUT}"))] + #[command(long_about = format!("{DEPRECATION_MESSAGE}{{n}}{{n}}{DISTRIBUTION_ABOUT}"))] Distribution(FloatValueMetricArgs), - #[command(about = "Update a gauge metric with the provided value")] + #[command(about = format!("[DEPRECATED] {GAUGE_ABOUT}"))] + #[command(long_about = format!("{DEPRECATION_MESSAGE}{{n}}{{n}}{GAUGE_ABOUT}"))] Gauge(FloatValueMetricArgs), - #[command(about = "Update a set metric with the provided value")] + #[command(about = format!("[DEPRECATED] {SET_ABOUT}"))] + #[command(long_about = format!("{DEPRECATION_MESSAGE}{{n}}{{n}}{SET_ABOUT}"))] Set(SetMetricArgs), } @@ -48,6 +65,9 @@ pub(super) fn execute(_: &ArgMatches) -> Result<()> { // _ => panic!("expected send-metric subcommand"), // }; let SentryCLICommand::SendMetric(SendMetricArgs { subcommand }) = SentryCLI::parse().command; + + log::warn!("{DEPRECATION_MESSAGE}"); + match subcommand { SendMetricSubcommand::Increment(args) => increment::execute(args), SendMetricSubcommand::Distribution(args) => distribution::execute(args), diff --git a/tests/integration/_cases/help/help.trycmd b/tests/integration/_cases/help/help.trycmd index d3b5ecd539..62e5ef0829 100644 --- a/tests/integration/_cases/help/help.trycmd +++ b/tests/integration/_cases/help/help.trycmd @@ -26,7 +26,6 @@ Commands: repos Manage repositories on Sentry. send-event Send a manual event to Sentry. send-envelope Send a stored envelope to Sentry. - send-metric Send a metric to Sentry. sourcemaps Manage sourcemaps for Sentry releases. uninstall Uninstall the sentry-cli executable. upload-proguard Upload ProGuard mapping files to a project. diff --git a/tests/integration/_cases/send_metric/send_metric-distribution-help.trycmd b/tests/integration/_cases/send_metric/send_metric-distribution-help.trycmd index 0a861b376c..21ea3e4b37 100644 --- a/tests/integration/_cases/send_metric/send_metric-distribution-help.trycmd +++ b/tests/integration/_cases/send_metric/send_metric-distribution-help.trycmd @@ -1,25 +1,47 @@ ``` $ sentry-cli send-metric distribution --help ? success +DEPRECATION NOTICE: The send-metric commands are deprecated and will be removed in the next major +release. Sentry will reject all metrics sent after October 7, 2024. Learn more: +https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics + Update a distribution metric with the provided value -Usage: sentry-cli[EXE] send-metric distribution [OPTIONS] --name --value +Usage: sentry-cli send-metric distribution [OPTIONS] --name --value Options: - -n, --name The name of the metric, identifying it in Sentry. - --header Custom headers that should be attached to all requests - in key:value format. - -u, --unit Any custom unit. You can have multiple metrics with the same name - but different units. - --auth-token Use the given Sentry auth token. - -t, --tags ... Metric tags as key:value pairs. Tags allow you to add dimensions to - your metrics and can be filtered or grouped by in Sentry. - -v, --value Metric value, any finite 64 bit float. - --log-level Set the log output verbosity. [possible values: trace, debug, info, - warn, error] - --quiet Do not print any output while preserving correct exit code. This - flag is currently implemented only for selected subcommands. - [aliases: silent] - -h, --help Print help + -n, --name + The name of the metric, identifying it in Sentry. + + --header + Custom headers that should be attached to all requests + in key:value format. + + -u, --unit + Any custom unit. You can have multiple metrics with the same name but different units. + + --auth-token + Use the given Sentry auth token. + + -t, --tags ... + Metric tags as key:value pairs. Tags allow you to add dimensions to your metrics and can + be filtered or grouped by in Sentry. + + -v, --value + Metric value, any finite 64 bit float. + + --log-level + Set the log output verbosity. + + [possible values: trace, debug, info, warn, error] + + --quiet + Do not print any output while preserving correct exit code. This flag is currently + implemented only for selected subcommands. + + [aliases: silent] + + -h, --help + Print help (see a summary with '-h') ``` diff --git a/tests/integration/_cases/send_metric/send_metric-gauge-help.trycmd b/tests/integration/_cases/send_metric/send_metric-gauge-help.trycmd index 95ef289ba6..60b1fdb6e0 100644 --- a/tests/integration/_cases/send_metric/send_metric-gauge-help.trycmd +++ b/tests/integration/_cases/send_metric/send_metric-gauge-help.trycmd @@ -1,25 +1,47 @@ ``` $ sentry-cli send-metric gauge --help ? success +DEPRECATION NOTICE: The send-metric commands are deprecated and will be removed in the next major +release. Sentry will reject all metrics sent after October 7, 2024. Learn more: +https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics + Update a gauge metric with the provided value -Usage: sentry-cli[EXE] send-metric gauge [OPTIONS] --name --value +Usage: sentry-cli send-metric gauge [OPTIONS] --name --value Options: - -n, --name The name of the metric, identifying it in Sentry. - --header Custom headers that should be attached to all requests - in key:value format. - -u, --unit Any custom unit. You can have multiple metrics with the same name - but different units. - --auth-token Use the given Sentry auth token. - -t, --tags ... Metric tags as key:value pairs. Tags allow you to add dimensions to - your metrics and can be filtered or grouped by in Sentry. - -v, --value Metric value, any finite 64 bit float. - --log-level Set the log output verbosity. [possible values: trace, debug, info, - warn, error] - --quiet Do not print any output while preserving correct exit code. This - flag is currently implemented only for selected subcommands. - [aliases: silent] - -h, --help Print help + -n, --name + The name of the metric, identifying it in Sentry. + + --header + Custom headers that should be attached to all requests + in key:value format. + + -u, --unit + Any custom unit. You can have multiple metrics with the same name but different units. + + --auth-token + Use the given Sentry auth token. + + -t, --tags ... + Metric tags as key:value pairs. Tags allow you to add dimensions to your metrics and can + be filtered or grouped by in Sentry. + + -v, --value + Metric value, any finite 64 bit float. + + --log-level + Set the log output verbosity. +[..] + [possible values: trace, debug, info, warn, error] + + --quiet + Do not print any output while preserving correct exit code. This flag is currently + implemented only for selected subcommands. +[..] + [aliases: silent] + + -h, --help + Print help (see a summary with '-h') ``` diff --git a/tests/integration/_cases/send_metric/send_metric-help.trycmd b/tests/integration/_cases/send_metric/send_metric-help.trycmd index 308ba7b348..8fcc986e02 100644 --- a/tests/integration/_cases/send_metric/send_metric-help.trycmd +++ b/tests/integration/_cases/send_metric/send_metric-help.trycmd @@ -1,6 +1,10 @@ ``` $ sentry-cli send-metric --help ? success +DEPRECATION NOTICE: The send-metric commands are deprecated and will be removed in the next major +release. Sentry will reject all metrics sent after October 7, 2024. Learn more: +https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics + Send a metric event to Sentry. This command will validate input parameters and attempt to send a metric to Sentry. Due to network @@ -10,10 +14,10 @@ transmission errors by passing --log-level=debug or setting `SENTRY_LOG_LEVEL=de Usage: sentry-cli[EXE] send-metric [OPTIONS] [COMMAND] Commands: - increment Increment a counter metric - distribution Update a distribution metric with the provided value - gauge Update a gauge metric with the provided value - set Update a set metric with the provided value + increment [DEPRECATED] Increment a counter metric + distribution [DEPRECATED] Update a distribution metric with the provided value + gauge [DEPRECATED] Update a gauge metric with the provided value + set [DEPRECATED] Update a set metric with the provided value help Print this message or the help of the given subcommand(s) Options: diff --git a/tests/integration/_cases/send_metric/send_metric-increment-help.trycmd b/tests/integration/_cases/send_metric/send_metric-increment-help.trycmd index c21ecc361d..f5976ae19e 100644 --- a/tests/integration/_cases/send_metric/send_metric-increment-help.trycmd +++ b/tests/integration/_cases/send_metric/send_metric-increment-help.trycmd @@ -1,26 +1,49 @@ ``` $ sentry-cli send-metric increment --help ? success +DEPRECATION NOTICE: The send-metric commands are deprecated and will be removed in the next major +release. Sentry will reject all metrics sent after October 7, 2024. Learn more: +https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics + Increment a counter metric -Usage: sentry-cli[EXE] send-metric increment [OPTIONS] --name +Usage: sentry-cli send-metric increment [OPTIONS] --name Options: - -n, --name The name of the metric, identifying it in Sentry. - --header Custom headers that should be attached to all requests - in key:value format. - -u, --unit Any custom unit. You can have multiple metrics with the same name - but different units. - --auth-token Use the given Sentry auth token. - -t, --tags ... Metric tags as key:value pairs. Tags allow you to add dimensions to - your metrics and can be filtered or grouped by in Sentry. - -v, --value Value to increment the metric by, any finite 64 bit float. - [default: 1] - --log-level Set the log output verbosity. [possible values: trace, debug, info, - warn, error] - --quiet Do not print any output while preserving correct exit code. This - flag is currently implemented only for selected subcommands. - [aliases: silent] - -h, --help Print help + -n, --name + The name of the metric, identifying it in Sentry. + + --header + Custom headers that should be attached to all requests + in key:value format. + + -u, --unit + Any custom unit. You can have multiple metrics with the same name but different units. + + --auth-token + Use the given Sentry auth token. + + -t, --tags ... + Metric tags as key:value pairs. Tags allow you to add dimensions to your metrics and can + be filtered or grouped by in Sentry. + + -v, --value + Value to increment the metric by, any finite 64 bit float. +[..] + [default: 1] + + --log-level + Set the log output verbosity. +[..] + [possible values: trace, debug, info, warn, error] + + --quiet + Do not print any output while preserving correct exit code. This flag is currently + implemented only for selected subcommands. +[..] + [aliases: silent] + + -h, --help + Print help (see a summary with '-h') ``` diff --git a/tests/integration/_cases/send_metric/send_metric-increment-unsuccessful-api-call.trycmd b/tests/integration/_cases/send_metric/send_metric-increment-unsuccessful-api-call.trycmd index d8dacf11fd..2394d4adee 100644 --- a/tests/integration/_cases/send_metric/send_metric-increment-unsuccessful-api-call.trycmd +++ b/tests/integration/_cases/send_metric/send_metric-increment-unsuccessful-api-call.trycmd @@ -1,6 +1,7 @@ ``` $ sentry-cli send-metric increment -n testmetric ? failed +[..] error: API request failed caused by: sentry reported an error: internal server error (http status: 500) diff --git a/tests/integration/_cases/send_metric/send_metric-no-subcommand.trycmd b/tests/integration/_cases/send_metric/send_metric-no-subcommand.trycmd index 84d871d095..faf061102e 100644 --- a/tests/integration/_cases/send_metric/send_metric-no-subcommand.trycmd +++ b/tests/integration/_cases/send_metric/send_metric-no-subcommand.trycmd @@ -1,15 +1,15 @@ ``` $ sentry-cli send-metric ? failed -Send a metric to Sentry. +[DEPRECATED] Send a metric to Sentry. Usage: sentry-cli[EXE] send-metric [OPTIONS] Commands: - increment Increment a counter metric - distribution Update a distribution metric with the provided value - gauge Update a gauge metric with the provided value - set Update a set metric with the provided value + increment [DEPRECATED] Increment a counter metric + distribution [DEPRECATED] Update a distribution metric with the provided value + gauge [DEPRECATED] Update a gauge metric with the provided value + set [DEPRECATED] Update a set metric with the provided value help Print this message or the help of the given subcommand(s) Options: diff --git a/tests/integration/_cases/send_metric/send_metric-set-help.trycmd b/tests/integration/_cases/send_metric/send_metric-set-help.trycmd index 72a7014ae3..3ae0453ebf 100644 --- a/tests/integration/_cases/send_metric/send_metric-set-help.trycmd +++ b/tests/integration/_cases/send_metric/send_metric-set-help.trycmd @@ -1,26 +1,48 @@ ``` $ sentry-cli send-metric set --help ? success +DEPRECATION NOTICE: The send-metric commands are deprecated and will be removed in the next major +release. Sentry will reject all metrics sent after October 7, 2024. Learn more: +https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics + Update a set metric with the provided value -Usage: sentry-cli[EXE] send-metric set [OPTIONS] --name --value +Usage: sentry-cli send-metric set [OPTIONS] --name --value Options: - -n, --name The name of the metric, identifying it in Sentry. - --header Custom headers that should be attached to all requests - in key:value format. - -u, --unit Any custom unit. You can have multiple metrics with the same name - but different units. - --auth-token Use the given Sentry auth token. - -t, --tags ... Metric tags as key:value pairs. Tags allow you to add dimensions to - your metrics and can be filtered or grouped by in Sentry. - -v, --value Value to add to the set. If the set already contains the provided - value, the set's unique count will not increase. - --log-level Set the log output verbosity. [possible values: trace, debug, info, - warn, error] - --quiet Do not print any output while preserving correct exit code. This - flag is currently implemented only for selected subcommands. - [aliases: silent] - -h, --help Print help + -n, --name + The name of the metric, identifying it in Sentry. + + --header + Custom headers that should be attached to all requests + in key:value format. + + -u, --unit + Any custom unit. You can have multiple metrics with the same name but different units. + + --auth-token + Use the given Sentry auth token. + + -t, --tags ... + Metric tags as key:value pairs. Tags allow you to add dimensions to your metrics and can + be filtered or grouped by in Sentry. + + -v, --value + Value to add to the set. If the set already contains the provided value, the set's unique + count will not increase. + + --log-level + Set the log output verbosity. +[..] + [possible values: trace, debug, info, warn, error] + + --quiet + Do not print any output while preserving correct exit code. This flag is currently + implemented only for selected subcommands. +[..] + [aliases: silent] + + -h, --help + Print help (see a summary with '-h') ```