Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task ProcessAsync(LinkUpdate update, IMessageAck ack, CancellationT
if (filter.ShouldFilter(update))
{
logger.LogDebug(
"Обновление отфильтровано. UpdateId={UpdateId}, Author={Author}",
"Update filtered out. UpdateId={UpdateId}, Author={Author}",
update.Id, update.Author);
return;
}
Expand All @@ -48,7 +48,7 @@ public async Task ProcessAsync(LinkUpdate update, IMessageAck ack, CancellationT
}

logger.LogDebug(
"Обновление добавлено в буфер. UpdateId={UpdateId}, Priority={Priority}",
"Update added to the buffer. UpdateId={UpdateId}, Priority={Priority}",
update.Id, priority);
}

Expand All @@ -69,6 +69,6 @@ await publisher.PublishAsync(
ct);
}

logger.LogDebug("Служебный отчёт опубликован без обработки. UpdateId={UpdateId}", update.Id);
logger.LogDebug("System report published without processing. UpdateId={UpdateId}", update.Id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task PublishAsync(ProcessedLinkUpdate update, CancellationToken ct)
var result = await producer.ProduceAsync(topic, message, ct);

logger.LogInformation(
"Kafka: обновление опубликовано. Topic={Topic}, Partition={Partition}, Offset={Offset}, UpdateId={UpdateId}",
"Kafka: update published. Topic={Topic}, Partition={Partition}, Offset={Offset}, UpdateId={UpdateId}",
result.Topic, result.Partition.Value, result.Offset.Value, update.Id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private async Task ConsumeLoopAsync(CancellationToken stoppingToken)
consumer.Subscribe(topic);

logger.LogInformation(
"Kafka consumer запущен. Topic={Topic}, GroupId={GroupId}",
"Kafka consumer started. Topic={Topic}, GroupId={GroupId}",
topic,
kafkaOptions.Value.GroupId);

Expand All @@ -51,7 +51,7 @@ private async Task ConsumeLoopAsync(CancellationToken stoppingToken)
}
catch (ConsumeException ex)
{
logger.LogWarning(ex, "Kafka consume завершился ошибкой. Пауза перед повтором.");
logger.LogWarning(ex, "Kafka consume failed, backing off before retry.");
await Task.Delay(ConsumeErrorBackoff, stoppingToken);
continue;
}
Expand All @@ -66,7 +66,7 @@ private async Task ConsumeLoopAsync(CancellationToken stoppingToken)
}
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
{
logger.LogInformation("Kafka consumer остановлен.");
logger.LogInformation("Kafka consumer stopped.");
}
finally
{
Expand Down Expand Up @@ -108,7 +108,7 @@ private async Task ProcessMessageAsync(ConsumeResult<string, byte[]> result, Can

logger.LogError(
ex,
"Ошибка обработки Kafka сообщения. Offset не будет подтвержден. Topic={Topic}, Partition={Partition}, Offset={Offset}",
"Failed to process Kafka message. Offset will not be committed. Topic={Topic}, Partition={Partition}, Offset={Offset}",
result.Topic,
result.Partition.Value,
result.Offset.Value);
Expand All @@ -132,7 +132,7 @@ private void CommitCompleted()
{
logger.LogError(
ex,
"Не удалось подтвердить Kafka offsets. Offsets={Offsets}",
"Failed to commit Kafka offsets. Offsets={Offsets}",
string.Join(", ", offsets));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task PublishAsync(
ct);

logger.LogWarning(
"Kafka сообщение отправлено в DLQ. Topic={Topic}, Partition={Partition}, Offset={Offset}, Reason={Reason}",
"Kafka message sent to DLQ. Topic={Topic}, Partition={Partition}, Offset={Offset}, Reason={Reason}",
result.Topic,
result.Partition.Value,
result.Offset.Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<bool> HandleAsync(
{
return await TryPublishToDeadLetterAsync(
result,
$"Kafka сообщение не удалось десериализовать: {ex.Message}",
$"Failed to deserialize Kafka message: {ex.Message}",
ex,
ct);
}
Expand All @@ -45,7 +45,7 @@ public async Task<bool> HandleAsync(
{
return await TryPublishToDeadLetterAsync(
result,
"Kafka сообщение десериализовалось в null.",
"Kafka message deserialized to null.",
null,
ct);
}
Expand All @@ -56,13 +56,13 @@ public async Task<bool> HandleAsync(
{
return await TryPublishToDeadLetterAsync(
result,
"Исчерпаны попытки обработки Kafka сообщения.",
"Kafka message processing retries exhausted.",
processingError,
ct);
}

logger.LogInformation(
"Kafka сообщение обработано. Topic={Topic}, Partition={Partition}, Offset={Offset}, UpdateId={UpdateId}",
"Kafka message processed. Topic={Topic}, Partition={Partition}, Offset={Offset}, UpdateId={UpdateId}",
result.Topic,
result.Partition.Value,
result.Offset.Value,
Expand Down Expand Up @@ -94,7 +94,7 @@ public async Task<bool> HandleAsync(
{
logger.LogWarning(
ex,
"Ошибка обработки Kafka сообщения. Будет повторная попытка. Attempt={Attempt}, MaxAttempts={MaxAttempts}, UpdateId={UpdateId}",
"Failed to process Kafka message, retrying. Attempt={Attempt}, MaxAttempts={MaxAttempts}, UpdateId={UpdateId}",
attempt,
attempts,
update.Id);
Expand All @@ -108,7 +108,7 @@ public async Task<bool> HandleAsync(
{
logger.LogWarning(
ex,
"Ошибка обработки Kafka сообщения. Повторные попытки закончились. Attempts={Attempts}, UpdateId={UpdateId}",
"Failed to process Kafka message, no retries left. Attempts={Attempts}, UpdateId={UpdateId}",
attempts,
update.Id);

Expand Down Expand Up @@ -143,7 +143,7 @@ private async Task<bool> TryPublishToDeadLetterAsync(

logger.LogError(
ex,
"Не удалось отправить Kafka сообщение в DLQ. Offset не будет подтвержден, сообщение будет переигрываться. Topic={Topic}, Partition={Partition}, Offset={Offset}, DeadLetterTopic={DeadLetterTopic}",
"Failed to send Kafka message to DLQ. Offset will not be committed, the message will be replayed. Topic={Topic}, Partition={Partition}, Offset={Offset}, DeadLetterTopic={DeadLetterTopic}",
result.Topic,
result.Partition.Value,
result.Offset.Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed class YandexAiHttpClient(
IAiAgentMetrics metrics,
ILogger<YandexAiHttpClient> logger) : ILinkUpdateSummarizer
{
private const string Instructions = "You are a concise summarizer. Summarize the given update in 2-3 sentences.";
private const string Instructions = "You are a concise summarizer. Summarize the given update in 2-3 sentences. Always answer in Russian.";

public async Task<string> SummarizeAsync(string text, CancellationToken ct)
{
Expand All @@ -34,7 +34,7 @@ public async Task<string> SummarizeAsync(string text, CancellationToken ct)

if (string.IsNullOrWhiteSpace(summary))
{
logger.LogWarning("Yandex AI вернул пустой ответ. Используется обрезка текста.");
logger.LogWarning("Yandex AI returned an empty response, falling back to text truncation.");
metrics.IncrementSummarizationFallback("empty_response");

return FallbackTruncate(text, threshold);
Expand All @@ -49,7 +49,7 @@ public async Task<string> SummarizeAsync(string text, CancellationToken ct)
}
catch (Exception ex)
{
logger.LogWarning(ex, "Yandex AI суммаризация завершилась ошибкой ({Type}). Используется обрезка текста.", ex.GetType().Name);
logger.LogWarning(ex, "Yandex AI summarization failed ({Type}), falling back to text truncation.", ex.GetType().Name);
metrics.IncrementSummarizationFallback(ex.GetType().Name);

return FallbackTruncate(text, threshold);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
}
}

// Окна, не успевшие закрыться, публикуются на остановке: иначе они умрут вместе
// с процессом, а сообщения будут переигрываться с последнего подтвержденного оффсета.
public override async Task StopAsync(CancellationToken cancellationToken)
{
await base.StopAsync(cancellationToken);
Expand Down Expand Up @@ -78,21 +76,20 @@ private async Task<bool> TryPublishAsync(
await publisher.PublishAsync(group, ct);

logger.LogInformation(
"Группа опубликована. ChatId={ChatId}, UpdateId={UpdateId}, Priority={Priority}",
"Group published. ChatId={ChatId}, UpdateId={UpdateId}, Priority={Priority}",
bucket.ChatId, group.Id, group.Priority);
}
}
catch (Exception ex)
{
logger.LogError(
ex,
"Ошибка публикации сгруппированного обновления, окно возвращено в буфер. ChatId={ChatId}",
"Failed to publish the grouped update, the window was returned to the buffer. ChatId={ChatId}",
bucket.ChatId);

return false;
}

// Оффсеты исходных сообщений подтверждаются только после успешной публикации.
foreach (var buffered in bucket.Updates)
{
buffered.Ack.Release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static string BuildAcceptedTagsReply(

private static string BuildConfirmText(DialogContext ctx)
{
var url = ctx.GetPendingUrl() ?? "(unknown)";
var url = ctx.GetPendingUrl() ?? "(неизвестно)";
var tagsCsv = ctx.GetTagsCsv();
var tagsText = string.IsNullOrWhiteSpace(tagsCsv) ? "—" : string.Join(", ", tagsCsv.Split(','));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task PublishAsync(
ct);

logger.LogWarning(
"Kafka сообщение отправлено в DLQ. Topic={Topic}, Partition={Partition}, Offset={Offset}, Reason={Reason}",
"Kafka message sent to DLQ. Topic={Topic}, Partition={Partition}, Offset={Offset}, Reason={Reason}",
result.Topic,
result.Partition.Value,
result.Offset.Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ public bool TryValidate(LinkUpdate? update, out string? error)

if (update is null)
{
error = "Сообщение не удалось десериализовать.";
error = "Failed to deserialize the message.";
return false;
}

if (update.Id < 0)
{
error = "Поле 'id' не может быть отрицательным.";
error = "Field 'id' must not be negative.";
return false;
}

if (update.Url is null || !update.Url.IsAbsoluteUri)
{
error = "Поле 'url' должно содержать абсолютный URI.";
error = "Field 'url' must contain an absolute URI.";
return false;
}

Expand All @@ -31,7 +31,7 @@ public bool TryValidate(LinkUpdate? update, out string? error)
return true;
}

error = "Поле 'tgChatIds' должно содержать хотя бы один chat id.";
error = "Field 'tgChatIds' must contain at least one chat id.";
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private async Task ConsumeLoopAsync(CancellationToken stoppingToken)
consumer.Subscribe(topic);

logger.LogInformation(
"Kafka consumer запущен. Topic={Topic}, GroupId={GroupId}",
"Kafka consumer started. Topic={Topic}, GroupId={GroupId}",
topic,
kafkaOptions.Value.GroupId);

Expand All @@ -51,7 +51,7 @@ private async Task ConsumeLoopAsync(CancellationToken stoppingToken)
}
catch (ConsumeException ex)
{
logger.LogWarning(ex, "Kafka consume завершился ошибкой. Пауза перед повтором.");
logger.LogWarning(ex, "Kafka consume failed, backing off before retry.");
await Task.Delay(ConsumeErrorBackoff, stoppingToken);
continue;
}
Expand All @@ -66,7 +66,7 @@ private async Task ConsumeLoopAsync(CancellationToken stoppingToken)
}
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
{
logger.LogInformation("Kafka consumer остановлен.");
logger.LogInformation("Kafka consumer stopped.");
}
finally
{
Expand Down Expand Up @@ -106,7 +106,7 @@ private async Task ProcessMessageAsync(ConsumeResult<string, byte[]> result, Can

logger.LogError(
ex,
"Ошибка обработки Kafka сообщения. Offset не будет подтвержден. Topic={Topic}, Partition={Partition}, Offset={Offset}",
"Failed to process Kafka message. Offset will not be committed. Topic={Topic}, Partition={Partition}, Offset={Offset}",
result.Topic,
result.Partition.Value,
result.Offset.Value);
Expand All @@ -124,7 +124,7 @@ private bool TryCommit(ConsumeResult<string, byte[]> result)
{
logger.LogError(
ex,
"Не удалось подтвердить Kafka offset. Topic={Topic}, Partition={Partition}, Offset={Offset}",
"Failed to commit Kafka offset. Topic={Topic}, Partition={Partition}, Offset={Offset}",
result.Topic,
result.Partition.Value,
result.Offset.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<bool> HandleAsync(ConsumeResult<string, byte[]> result, Cancel
{
return await TryPublishToDeadLetterAsync(
result,
$"Kafka сообщение не удалось десериализовать: {ex.Message}",
$"Failed to deserialize Kafka message: {ex.Message}",
ex,
ct);
}
Expand All @@ -44,7 +44,7 @@ public async Task<bool> HandleAsync(ConsumeResult<string, byte[]> result, Cancel
{
return await TryPublishToDeadLetterAsync(
result,
error ?? "Kafka сообщение не прошло валидацию.",
error ?? "Kafka message failed validation.",
null,
ct);
}
Expand All @@ -55,13 +55,13 @@ public async Task<bool> HandleAsync(ConsumeResult<string, byte[]> result, Cancel
{
return await TryPublishToDeadLetterAsync(
result,
"Исчерпаны попытки обработки Kafka сообщения.",
"Kafka message processing retries exhausted.",
notificationError,
ct);
}

logger.LogInformation(
"Kafka сообщение обработано. Topic={Topic}, Partition={Partition}, Offset={Offset}, UpdateId={UpdateId}",
"Kafka message processed. Topic={Topic}, Partition={Partition}, Offset={Offset}, UpdateId={UpdateId}",
result.Topic,
result.Partition.Value,
result.Offset.Value,
Expand Down Expand Up @@ -90,7 +90,7 @@ public async Task<bool> HandleAsync(ConsumeResult<string, byte[]> result, Cancel
{
logger.LogWarning(
ex,
"Ошибка обработки Kafka сообщения. Будет повторная попытка. Attempt={Attempt}, MaxAttempts={MaxAttempts}, UpdateId={UpdateId}",
"Failed to process Kafka message, retrying. Attempt={Attempt}, MaxAttempts={MaxAttempts}, UpdateId={UpdateId}",
attempt,
attempts,
update.Id);
Expand All @@ -104,7 +104,7 @@ public async Task<bool> HandleAsync(ConsumeResult<string, byte[]> result, Cancel
{
logger.LogWarning(
ex,
"Ошибка обработки Kafka сообщения. Повторные попытки закончились. Attempts={Attempts}, UpdateId={UpdateId}",
"Failed to process Kafka message, no retries left. Attempts={Attempts}, UpdateId={UpdateId}",
attempts,
update.Id);

Expand Down Expand Up @@ -140,7 +140,7 @@ private async Task<bool> TryPublishToDeadLetterAsync(

logger.LogError(
ex,
"Не удалось отправить Kafka сообщение в DLQ. Offset не будет подтвержден, сообщение будет переигрываться. Topic={Topic}, Partition={Partition}, Offset={Offset}, DeadLetterTopic={DeadLetterTopic}",
"Failed to send Kafka message to DLQ. Offset will not be committed, the message will be replayed. Topic={Topic}, Partition={Partition}, Offset={Offset}, DeadLetterTopic={DeadLetterTopic}",
result.Topic,
result.Partition.Value,
result.Offset.Value,
Expand Down
Loading
Loading