Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Subscription gap metric reads the end of the same stream once for each subscription

オープン
#614 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 7 日以内に返信

@nmummau がすでに取り組んでいます。

2026年10月9日 から。

  • #615 @nmummau による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
csharp
領域
observability

調査の方向性

Start with src/Core/src/Eventuous.Subscriptions/Diagnostics/SubscriptionMetrics.cs, focusing on ObserveGapValues and GetGap, then trace how measures are registered in SubscriptionRegistrationExtensions.cs. Review the SQL and KurrentDB measure implementations listed in the issue to see how they identify an end-of-stream source. Done means each shared source is read once per collection while subscription-id tags and custom implementations without a key retain their stated behavior; linked pull request 615 is already open.

索引モデルが issue の本文から書いたものです。

説明

Is your feature request related to a problem? Please describe.

AddEventuousSubscriptions() registers the subscription gap gauges in SubscriptionMetrics. On each metric collection, ObserveGapValues calls the GetSubscriptionEndOfStream delegate of every measured subscription, one after another. Each delegate reads the end of its stream from the store.

When several subscriptions read the same source, every call returns the same value, but the store gets one request for each subscription. This happens in the core SubscriptionMetrics, so it affects every store that supports the gap metric:

Store End-of-stream request for an all-stream subscription
SQL Server SELECT MAX(GlobalPosition) FROM <schema>.Messages
PostgreSQL select max(global_position) from <schema>.messages
SQLite SELECT MAX(global_position) FROM <messages table>
KurrentDB ReadAllAsync(Direction.Backwards, Position.End, 1), a gRPC read of the last event in $all

For example, an application has six all-stream subscriptions on one SQL Server store. Each collection then sends the same query six times. The position column is the clustered primary key, so each SQL query is cheap. For KurrentDB, each call is a network round trip. In all cases, the number of requests grows with the number of subscriptions and with the export frequency:

Metric export interval Subscriptions End-of-stream requests
60 seconds 6 6 each minute
200 milliseconds 6 about 30 each second

A second, related problem: GetGap runs each delegate synchronously (GetAwaiter().GetResult()) on the collection thread, with a 500 ms timeout for each subscription. When the store is slow, one collection can block for up to 500 ms multiplied by the number of subscriptions. This also applies to every store.

Observed with Eventuous 0.17.0 (Eventuous.SqlServer, Eventuous.Diagnostics.OpenTelemetry). The other stores are from a reading of the dev branch source.

Describe the solution you'd like

Read each end-of-stream source one time per collection, and share the result between the subscriptions that read that source. Make the change in SubscriptionMetrics, so that it applies to all stores.

A possible shape:

  1. IMeasuredSubscription exposes a key for its end-of-stream source in addition to the delegate. Subscriptions that read the same source return the same key. For example, a SQL all-stream subscription returns the store type, the connection, and the schema. A stream subscription adds the stream name. A KurrentDB $all subscription returns the client and $all.
  2. SubscriptionMetrics groups the measures by key. On each collection, it calls one delegate for each key and uses the result for every subscription in the group. The subscription-id tag stays the same, so the exported series do not change.
  3. Optionally, SubscriptionMetrics runs the remaining calls concurrently, with one overall timeout, rather than one blocking call after another.

The key could be optional. A subscription with no key keeps the current behavior, so custom IMeasuredSubscription implementations continue to work.

Additional context

The relevant code:

  • src/Core/src/Eventuous.Subscriptions/Diagnostics/SubscriptionMetrics.cs: ObserveGapValues and GetGap.
  • src/Core/src/Eventuous.Subscriptions/Registrations/SubscriptionRegistrationExtensions.cs: registers one GetSubscriptionEndOfStream for each measured subscription.
  • src/Relational/src/Eventuous.Sql.Base/Subscriptions/SqlSubscriptionBase.cs: GetSubscriptionEndOfStream, which SQL Server, PostgreSQL, and SQLite share.
  • PrepareEndOfStreamCommand in the all-stream and stream subscriptions of Eventuous.SqlServer, Eventuous.Postgresql, and Eventuous.Sqlite.
  • src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/: AllStreamSubscriptionMeasure, StreamSubscriptionMeasure, and BaseSubscriptionMeasure.
主要言語
C#
スター
512
フォーク
99
平均マージ
5日 6時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Eventuous/eventuous のほかの issue

Eventuous/eventuous の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。