GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(streaming): add telemetry tags to stream metrics by oising · Pull Request #8631 · dotnet/orleans Conversation
|
|
It's alive! @ReubenBond |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
b046194 to
5749ab7
Compare
This commit introduces telemetry features to several components of the Orleans streaming system. Specifically, a new class, StreamInstrumentsTagUtils, has been created to provide methods for initializing the relevant telemetry tags. This utility is now utilized in numerous places throughout the codebase, including the PubSubRendezvousGrain and PersistentStreamPullingAgent classes, where it facilitates the monitoring of crucial streaming activities. This aids in diagnostics and performance tracking, contributing to ongoing system improvement efforts.
Use grain type instead of per-stream identifiers, keep consumer metrics balanced across add and remove paths, and add focused coverage in Orleans.Core.Tests. Co-authored-by: Copilot <[email protected]>
Enable nullable annotations for the stream tag helper, align new tests with file-scoped namespace conventions, and preserve DiagnosticListener emissions while applying tagged stream metrics. Co-authored-by: Copilot <[email protected]>
Revert formatting-only edits in PubSubRendezvousGrain while preserving the telemetry tag behavior changes. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot App <[email protected]> Copilot-Session: cd7955ca-4f1e-42b5-ac19-5d6d2c7c3959
a16145c to
2e03d91
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Adds low-cardinality telemetry tags to Orleans streaming metrics to improve diagnostics and performance tracking across pub/sub and persistent streaming components.
Changes:
StreamInstrumentsTagUtils to centralize creation of bounded, stable tag dimensions for streaming-related metrics.PubSubRendezvousGrain) and persistent streaming (PersistentStreamPullingAgent) to emit metrics with tags only when instruments are enabled.| File | Description |
|---|---|
| test/Orleans.Core.Tests/OrleansRuntime/Streams/StreamInstrumentsTagUtilsTests.cs | Adds coverage verifying tag stability and bounded dimensions for stream/grain and queue scenarios. |
| src/Orleans.Streaming/StreamInstrumentsTagUtils.cs | New internal utility for generating low-cardinality TagList sets for stream/grain/queue metrics. |
| src/Orleans.Streaming/PubSub/PubSubRendezvousGrain.cs | Emits pub/sub counters with tags when enabled (added/removed/total for producers/consumers). |
| src/Orleans.Streaming/PersistentStreams/PersistentStreamPullingAgent.cs | Emits persistent stream read/sent message counters with tags when enabled. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (_streamInstruments.PubSubConsumersTotal.Enabled) | ||
| { | ||
| tags ??= StreamInstrumentsTagUtils.InitializeTags(streamId, streamConsumer); | ||
| _streamInstruments.PubSubConsumersTotal.Add( | ||
| -(initialProducerCount - State.Producers.Count), tags.Value); | ||
| } |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: cd7955ca-4f1e-42b5-ac19-5d6d2c7c3959
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
src/Orleans.Streaming/PersistentStreams/PersistentStreamPullingAgent.cs:828
_streamInstruments is nullable, but is dereferenced without a null-guard when recording PersistentStreamSentMessages. Capturing _streamInstruments into a local avoids nullable dereference warnings and keeps the null-check and usage tied together. if (_streamInstruments?.PersistentStreamSentMessages.Enabled is true)
{
tags ??= StreamInstrumentsTagUtils.InitializeTags(
consumerData.StreamId, consumerData.StreamConsumer.GetGrainId());
_streamInstruments.PersistentStreamSentMessages.Add(1, tags.Value);
}
src/Orleans.Streaming/PubSub/PubSubRendezvousGrain.cs:313
consumerState is looked up unconditionally, even when both PubSubConsumersRemoved and PubSubConsumersTotal instruments are disabled. That adds an avoidable linear scan on every call. Consider only performing the lookup when at least one of those instruments is enabled. var consumerState = State.Consumers.FirstOrDefault(s => s.Equals(subscriptionId));
src/Orleans.Streaming/PersistentStreams/PersistentStreamPullingAgent.cs:546
_streamInstruments is declared nullable, but is dereferenced without a null-guard in this block. While the ?. ... is true condition makes this safe at runtime, nullable flow analysis may still flag it and it’s easy to regress later. Capture _streamInstruments into a local and use that for the check and the Add call.This issue also appears on line 823 of the same file.
if (_streamInstruments?.PersistentStreamReadMessages.Enabled is true)
{
tags = StreamInstrumentsTagUtils.InitializeTags(myQueueId, streamProviderName);
_streamInstruments.PersistentStreamReadMessages.Add(multiBatch.Count, tags.Value);
}
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Copilot App <[email protected]> Copilot-Session: cd7955ca-4f1e-42b5-ac19-5d6d2c7c3959
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
src/Orleans.Streaming/PubSub/PubSubRendezvousGrain.cs:223
PubSubConsumersTotal is incremented unconditionally, even if this call is re-registering an existing subscription (ie, pubSubState was already present). Since this counter is used as a +/- delta to represent the current total, it can drift upward and become inaccurate. if (_streamInstruments.PubSubConsumersTotal.Enabled)
{
tags ??= StreamInstrumentsTagUtils.InitializeTags(streamId, streamConsumer);
_streamInstruments.PubSubConsumersTotal.Add(1, tags.Value);
}
src/Orleans.Streaming/StreamInstrumentsTagUtils.cs:18
grainId.Type.ToString() will not be null and does not map default/empty grain types to the intended low-cardinality "unknown" value. If a default GrainId is ever passed, this will emit an empty/implicit grain_type dimension instead of unknown. [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static TagList InitializeTags(QualifiedStreamId streamId, GrainId grainId) =>
CreateStreamTags(streamId, grainId.Type.ToString() ?? UnknownGrainType);
src/Orleans.Streaming/PubSub/PubSubRendezvousGrain.cs:133
PubSubProducersTotal is being incremented even when State.Producers.Add(...) is a no-op (eg, producer re-registers due to retries). Since this counter is used as a +/- delta to represent the current total, it can drift upward and become inaccurate.This issue also appears on line 219 of the same file.
if (_streamInstruments.PubSubProducersTotal.Enabled)
{
tags ??= StreamInstrumentsTagUtils.InitializeTags(streamId, streamProducer);
_streamInstruments.PubSubProducersTotal.Add(1, tags.Value);
}
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.