Skip to content

Commit

Permalink
ref(metrics): Deprecate send-metric commands (#2154)
Browse files Browse the repository at this point in the history
Closes #2150
  • Loading branch information
szokeasaurusrex authored Sep 19, 2024
1 parent b9acc54 commit c433b4c
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 80 deletions.
34 changes: 27 additions & 7 deletions src/commands/send_metric/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,44 @@ 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)]
subcommand: SendMetricSubcommand,
}

#[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),
}

Expand All @@ -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),
Expand Down
1 change: 0 additions & 1 deletion tests/integration/_cases/help/help-windows.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
upload-proguard Upload ProGuard mapping files to a project.
help Print this message or the help of the given subcommand(s)
Expand Down
1 change: 0 additions & 1 deletion tests/integration/_cases/help/help.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <NAME> --value <VALUE>

Options:
-n, --name <NAME> The name of the metric, identifying it in Sentry.
--header <KEY:VALUE> Custom headers that should be attached to all requests
in key:value format.
-u, --unit <UNIT> Any custom unit. You can have multiple metrics with the same name
but different units.
--auth-token <AUTH_TOKEN> Use the given Sentry auth token.
-t, --tags <KEY:VALUE>... 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> Metric value, any finite 64 bit float.
--log-level <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 <NAME>
The name of the metric, identifying it in Sentry.

--header <KEY:VALUE>
Custom headers that should be attached to all requests
in key:value format.

-u, --unit <UNIT>
Any custom unit. You can have multiple metrics with the same name but different units.

--auth-token <AUTH_TOKEN>
Use the given Sentry auth token.

-t, --tags <KEY:VALUE>...
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>
Metric value, any finite 64 bit float.

--log-level <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')

```
52 changes: 37 additions & 15 deletions tests/integration/_cases/send_metric/send_metric-gauge-help.trycmd
Original file line number Diff line number Diff line change
@@ -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 <NAME> --value <VALUE>

Options:
-n, --name <NAME> The name of the metric, identifying it in Sentry.
--header <KEY:VALUE> Custom headers that should be attached to all requests
in key:value format.
-u, --unit <UNIT> Any custom unit. You can have multiple metrics with the same name
but different units.
--auth-token <AUTH_TOKEN> Use the given Sentry auth token.
-t, --tags <KEY:VALUE>... 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> Metric value, any finite 64 bit float.
--log-level <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 <NAME>
The name of the metric, identifying it in Sentry.

--header <KEY:VALUE>
Custom headers that should be attached to all requests
in key:value format.

-u, --unit <UNIT>
Any custom unit. You can have multiple metrics with the same name but different units.

--auth-token <AUTH_TOKEN>
Use the given Sentry auth token.

-t, --tags <KEY:VALUE>...
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>
Metric value, any finite 64 bit float.

--log-level <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')

```
12 changes: 8 additions & 4 deletions tests/integration/_cases/send_metric/send_metric-help.trycmd
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <NAME>

Options:
-n, --name <NAME> The name of the metric, identifying it in Sentry.
--header <KEY:VALUE> Custom headers that should be attached to all requests
in key:value format.
-u, --unit <UNIT> Any custom unit. You can have multiple metrics with the same name
but different units.
--auth-token <AUTH_TOKEN> Use the given Sentry auth token.
-t, --tags <KEY:VALUE>... 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> Value to increment the metric by, any finite 64 bit float.
[default: 1]
--log-level <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 <NAME>
The name of the metric, identifying it in Sentry.

--header <KEY:VALUE>
Custom headers that should be attached to all requests
in key:value format.

-u, --unit <UNIT>
Any custom unit. You can have multiple metrics with the same name but different units.

--auth-token <AUTH_TOKEN>
Use the given Sentry auth token.

-t, --tags <KEY:VALUE>...
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>
Value to increment the metric by, any finite 64 bit float.
[..]
[default: 1]

--log-level <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')

```
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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] <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:
Expand Down
54 changes: 38 additions & 16 deletions tests/integration/_cases/send_metric/send_metric-set-help.trycmd
Original file line number Diff line number Diff line change
@@ -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 <NAME> --value <VALUE>

Options:
-n, --name <NAME> The name of the metric, identifying it in Sentry.
--header <KEY:VALUE> Custom headers that should be attached to all requests
in key:value format.
-u, --unit <UNIT> Any custom unit. You can have multiple metrics with the same name
but different units.
--auth-token <AUTH_TOKEN> Use the given Sentry auth token.
-t, --tags <KEY:VALUE>... 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> Value to add to the set. If the set already contains the provided
value, the set's unique count will not increase.
--log-level <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 <NAME>
The name of the metric, identifying it in Sentry.

--header <KEY:VALUE>
Custom headers that should be attached to all requests
in key:value format.

-u, --unit <UNIT>
Any custom unit. You can have multiple metrics with the same name but different units.

--auth-token <AUTH_TOKEN>
Use the given Sentry auth token.

-t, --tags <KEY:VALUE>...
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>
Value to add to the set. If the set already contains the provided value, the set's unique
count will not increase.

--log-level <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')

```

0 comments on commit c433b4c

Please sign in to comment.