指標と管理
このセクションでは、Spring Integration のメトリクスをキャプチャーする方法について説明します。最近のバージョンでは、Micrometer(https://micrometer.io (英語) を参照)にさらに依存しており、将来のリリースでは Micrometer をさらに使用する予定です。
大量の環境でのロギングの無効化
メインメッセージフローでデバッグログを制御できます。非常に大量のアプリケーションでは、isDebugEnabled()
の呼び出しは、一部のロギングサブシステムでは非常にコストがかかる可能性があります。このオーバーヘッドを回避するために、このようなすべてのロギングを無効にすることができます。例外ログ(デバッグまたはその他)は、この設定の影響を受けません。
次のリストは、ロギングを制御するために使用可能なオプションを示しています。
@Configuration
@EnableIntegration
@EnableIntegrationManagement(
defaultLoggingEnabled = "true" <1>)
public static class ContextConfiguration {
...
}
<int:management default-logging-enabled="true"/> (1)
1 | false に設定すると、ログシステムのカテゴリ設定に関係なく、メインメッセージフローのすべてのロギングが無効になります。デバッグログを有効にするには、"true" に設定します(ログサブシステムでも有効になっている場合)。Bean 定義で設定を明示的に構成していない場合にのみ適用されます。デフォルトは true です。 |
defaultLoggingEnabled は、Bean 定義で対応する設定を明示的に構成していない場合にのみ適用されます。 |
Micrometer 統合
概要
バージョン 5.0.3 以降、アプリケーションコンテキストに Micrometer (英語) MeterRegistry
が存在すると、Micrometer メトリクスのサポートがトリガーされます。
Micrometer を使用するには、MeterRegistry
Bean の 1 つをアプリケーションコンテキストに追加します。
MessageHandler
および MessageChannel
ごとに、タイマーが登録されます。MessageSource
ごとに、カウンターが登録されます。
これは、AbstractMessageHandler
、AbstractMessageChannel
、AbstractMessageSource
を継承するオブジェクトにのみ適用されます(ほとんどのフレームワークコンポーネントに当てはまります)。
メッセージチャネルの送信操作用の Timer
メーターには、次の名前またはタグがあります。
name
:spring.integration.send
tag
:type:channel
tag
:name:<componentName>
tag
:result:(success|failure)
tag
:exception:(none|exception simple class name)
description
:Send processing time
(none
例外を含む failure
結果は、チャネルの send()
操作が false
を返したことを意味します)
ポーリング可能なメッセージチャネルでの受信操作用の Counter
メーターには、次の名前またはタグがあります。
name
:spring.integration.receive
tag
:type:channel
tag
:name:<componentName>
tag
:result:(success|failure)
tag
:exception:(none|exception simple class name)
description
:Messages received
メッセージハンドラーの操作用の Timer
メーターには、次の名前またはタグがあります。
name
:spring.integration.send
tag
:type:handler
tag
:name:<componentName>
tag
:result:(success|failure)
tag
:exception:(none|exception simple class name)
description
:Send processing time
メッセージソースの Counter
メーターには、次の名前 / タグがあります。
name
:spring.integration.receive
tag
:type:source
tag
:name:<componentName>
tag
:result:success
tag
:exception:none
description
:Messages received
さらに、3 つの Gauge
メーターがあります。
spring.integration.channels
: アプリケーション内のMessageChannels
の数。spring.integration.handlers
: アプリケーション内のMessageHandlers
の数。spring.integration.sources
: アプリケーション内のMessageSources
の数。
MicrometerMetricsCaptor
のサブクラスを提供することにより、統合コンポーネントによって作成された Meters
の名前とタグをカスタマイズできます。MicrometerCustomMetricsTests [GitHub] (英語) テストケースは、その方法の簡単な例を示しています。ビルダーサブクラスの build()
メソッドをオーバーロードすることにより、メーターをさらにカスタマイズすることもできます。
バージョン 5.1.13 以降、QueueChannel
は、キューサイズと残り容量の Micrometer ゲージを公開します。
name
:spring.integration.channel.queue.size
tag
:type:channel
tag
:name:<componentName>
description
:The size of the queue channel
および
name
:spring.integration.channel.queue.remaining.capacity
tag
:type:channel
tag
:name:<componentName>
description
:The remaining capacity of the queue channel
メーターの無効化
レガシーメトリクス(現在は削除されています)を使用すると、メトリクスを収集する統合コンポーネントを指定できます。デフォルトでは、すべてのメーターは最初に使用されたときに登録されます。現在、Micrometer を使用すると、MeterFilter
を MeterRegistry
に追加して、一部またはすべてが登録されないようにすることができます。提供されている任意のプロパティ、name
、tag
などでメーターをフィルターで除外(拒否)できます。詳細については、Micrometer ドキュメントのメーターフィルター (英語) を参照してください。
例: 与えられた:
@Bean
public QueueChannel noMeters() {
return new QueueChannel(10);
}
次の方法で、このチャネルのみのメーターの登録を抑制することができます。
registry.config().meterFilter(MeterFilter.deny(id ->
"channel".equals(id.getTag("type")) &&
"noMeters".equals(id.getTag("name"))));
Spring Integration JMX サポート
JMX サポートも参照してください。