Skip to content

Commit b59d688

Browse files
authored
Add metrics for latency seconds to options (#98033)
This will send distribution metrics for latency batched updates for sentry options
1 parent 08e9d26 commit b59d688

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/sentry/runner/commands/configoptions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import time
23
from typing import Any
34

45
import click
@@ -120,6 +121,7 @@ def configoptions(
120121
from sentry import options
121122

122123
ctx.obj["dry_run"] = dry_run
124+
ctx.obj["timestamp"] = timestamp
123125

124126
with open(file) if file is not None else sys.stdin as stream:
125127
options_to_update = safe_load(stream)
@@ -216,6 +218,13 @@ def patch(ctx: click.Context) -> None:
216218
tags={"status": status},
217219
sample_rate=1.0,
218220
)
221+
if ctx.obj["timestamp"] is not None:
222+
metrics.distribution(
223+
key="options_automator.latency_seconds",
224+
value=time.time() - ctx.obj["timestamp"],
225+
tags={"status": status},
226+
sample_rate=1.0,
227+
)
219228
exit(ret_val)
220229

221230

@@ -311,5 +320,12 @@ def sync(ctx: click.Context) -> None:
311320
tags={"status": status},
312321
sample_rate=1.0,
313322
)
323+
if ctx.obj["timestamp"] is not None:
324+
metrics.distribution(
325+
key="options_automator.latency_seconds",
326+
value=time.time() - ctx.obj["timestamp"],
327+
tags={"status": status},
328+
sample_rate=1.0,
329+
)
314330

315331
exit(ret_val)

0 commit comments

Comments
 (0)