Removed redundant metrics, fixed description accuracy, and excluded no-data fallback from generation timing.
This commit is contained in:
+9
-12
@@ -163,15 +163,15 @@ async def generate(
|
||||
:param hard_limit: Character count to hard-cut the sentence at.
|
||||
:return: A new generated sentence.
|
||||
"""
|
||||
word = await db.get_random_start_word(channel_id)
|
||||
|
||||
if word is None:
|
||||
return (
|
||||
"There's not enough data to generate a message yet."
|
||||
" Chat a bit more so I can learn how this channel talks!"
|
||||
)
|
||||
|
||||
with metrics.GENERATION_DURATION.time():
|
||||
word = await db.get_random_start_word(channel_id)
|
||||
|
||||
if word is None:
|
||||
return (
|
||||
"There's not enough data to generate a message yet."
|
||||
" Chat a bit more so I can learn how this channel talks!"
|
||||
)
|
||||
|
||||
parts: list[str] = [word]
|
||||
current_length = len(word)
|
||||
|
||||
@@ -201,7 +201,4 @@ async def generate(
|
||||
result = result[:hard_limit]
|
||||
|
||||
# Strip the internal sentence-end marker so it never appears in output.
|
||||
result = result.removesuffix(DEFAULT_SENTENCE_END)
|
||||
|
||||
metrics.GENERATED_MESSAGE_LENGTH.observe(len(result))
|
||||
return result
|
||||
return result.removesuffix(DEFAULT_SENTENCE_END)
|
||||
|
||||
@@ -172,8 +172,6 @@ async def ingest_message(
|
||||
[ChannelImage(channel_id, user_id, url) for url in image_urls]
|
||||
)
|
||||
|
||||
metrics.MESSAGES_INGESTED.inc()
|
||||
|
||||
if cache is not None:
|
||||
cache.put(
|
||||
message.id,
|
||||
|
||||
+1
-15
@@ -31,16 +31,11 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
_FAST_BUCKETS = (0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0)
|
||||
_SLOW_BUCKETS = (0.1, 0.5, 1.0, 5.0, 10.0, 30.0, 60.0, 120.0, 300.0, 600.0)
|
||||
_LENGTH_BUCKETS = (10, 50, 100, 200, 500, 750, 1000, 1500, 2000)
|
||||
_MESSAGES_BUCKETS = (100, 500, 1000, 5000, 10000, 25000, 50000)
|
||||
|
||||
BUILD_INFO = Info("crabstero_build", "Build information")
|
||||
BUILD_INFO.info({"version": __version__})
|
||||
|
||||
MESSAGES_INGESTED = Counter(
|
||||
"crabstero_messages_ingested_total",
|
||||
"Messages ingested into a Markov chain",
|
||||
)
|
||||
MESSAGES_UNINGESTED = Counter(
|
||||
"crabstero_messages_uningested_total",
|
||||
"Messages uningested from a Markov chain after deletion",
|
||||
@@ -57,10 +52,6 @@ MESSAGES_PROCESSED = Counter(
|
||||
"crabstero_messages_processed_total",
|
||||
"Messages seen by the listener",
|
||||
)
|
||||
CHANNELS_INGESTED = Counter(
|
||||
"crabstero_channels_ingested_total",
|
||||
"Channels fully ingested successfully",
|
||||
)
|
||||
PINGME = Counter(
|
||||
"crabstero_pingme_total",
|
||||
"/pingme command outcomes",
|
||||
@@ -110,14 +101,9 @@ GENERATION_DURATION = Histogram(
|
||||
"Time to generate a Markov response",
|
||||
buckets=_FAST_BUCKETS,
|
||||
)
|
||||
GENERATED_MESSAGE_LENGTH = Histogram(
|
||||
"crabstero_generated_message_length_characters",
|
||||
"Length of generated reply bodies in characters",
|
||||
buckets=_LENGTH_BUCKETS,
|
||||
)
|
||||
CHANNEL_INGESTION_MESSAGES = Histogram(
|
||||
"crabstero_channel_ingestion_messages",
|
||||
"Messages ingested per channel run",
|
||||
"Messages iterated per channel ingestion run",
|
||||
buckets=_MESSAGES_BUCKETS,
|
||||
)
|
||||
|
||||
|
||||
@@ -83,8 +83,7 @@ async def ingest_channel(
|
||||
metrics.CHANNEL_INGESTION_MESSAGES.observe(count)
|
||||
|
||||
logger.info(
|
||||
"[%s] Ingestion of channel history complete. %d messages ingested.",
|
||||
"[%s] Ingestion of channel history complete. %d messages iterated.",
|
||||
channel.id,
|
||||
count,
|
||||
)
|
||||
metrics.CHANNELS_INGESTED.inc()
|
||||
|
||||
Reference in New Issue
Block a user