-
Notifications
You must be signed in to change notification settings - Fork 459
feat: Add implementation and tests for unnamed message metrics #866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bendoyon
merged 11 commits into
experimental/netstats-dispatcher
from
experimental/netstats/unnamed-message-metrics
Jun 4, 2021
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
aa439c5
Add test for named message sent
965c7a9
Add test for named messages sent to multiple clients
0a06ce5
Merge remote-tracking branch 'origin/experimental/netstats-dispatcher…
543f82d
Add test for named message received
3c6c2f7
Revert editor changes
b1d4390
Add implementation and tests for unnamed message metrics
0f3bff8
Fix variable naming
ecb10ae
Code review fixes
4fbb1f0
Merge branch 'experimental/netstats-dispatcher' into experimental/net…
ce2c927
Merge fixes
aaad13b
Code review fixes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
com.unity.multiplayer.mlapi/Runtime/Metrics/INetworkMetrics.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace MLAPI.Metrics | ||
| { | ||
| public interface INetworkMetrics | ||
| { | ||
| void TrackNetworkObject(NetworkObject networkObject); | ||
|
|
||
| void TrackNamedMessageSent(ulong receiverClientId, string messageName, ulong bytesCount); | ||
|
|
||
| void TrackNamedMessageSent(IReadOnlyCollection<ulong> receiverClientIds, string messageName, ulong bytesCount); | ||
|
|
||
| void TrackNamedMessageReceived(ulong senderClientId, string messageName, ulong bytesCount); | ||
|
|
||
| void TrackUnnamedMessageSent(ulong receiverClientId, ulong bytesCount); | ||
|
|
||
| void TrackUnnamedMessageSent(IReadOnlyCollection<ulong> receiverClientIds, ulong bytesCount); | ||
|
|
||
| void TrackUnnamedMessageReceived(ulong senderClientId, ulong bytesCount); | ||
|
|
||
| void DispatchFrame(); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
com.unity.multiplayer.mlapi/Runtime/Metrics/INetworkMetrics.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
com.unity.multiplayer.mlapi/Runtime/Metrics/NullNetworkMetrics.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace MLAPI.Metrics | ||
| { | ||
| public class NullNetworkMetrics : INetworkMetrics | ||
| { | ||
| public void TrackNetworkObject(NetworkObject networkObject) | ||
| { | ||
| } | ||
|
|
||
| public void TrackNamedMessageSent(ulong receiverClientId, string messageName, ulong bytesCount) | ||
| { | ||
| } | ||
|
|
||
| public void TrackNamedMessageSent(IReadOnlyCollection<ulong> receiverClientIds, string messageName, ulong bytesCount) | ||
| { | ||
| } | ||
|
|
||
| public void TrackNamedMessageReceived(ulong senderClientId, string messageName, ulong bytesCount) | ||
| { | ||
| } | ||
|
|
||
| public void TrackUnnamedMessageSent(ulong receiverClientId, ulong bytesCount) | ||
| { | ||
| } | ||
|
|
||
| public void TrackUnnamedMessageSent(IReadOnlyCollection<ulong> receiverClientIds, ulong bytesCount) | ||
| { | ||
| } | ||
|
|
||
| public void TrackUnnamedMessageReceived(ulong senderClientId, ulong bytesCount) | ||
| { | ||
| } | ||
|
|
||
| public void DispatchFrame() | ||
| { | ||
| } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
com.unity.multiplayer.mlapi/Runtime/Metrics/NullNetworkMetrics.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
com.unity.multiplayer.mlapi/Tests/Runtime/Metrics/MetricsTestBase.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| using System; | ||
| using System.Collections; | ||
| using System.Linq; | ||
| using NUnit.Framework; | ||
| using Unity.Multiplayer.NetStats.Dispatch; | ||
| using Unity.Multiplayer.NetStats.Metrics; | ||
| using UnityEngine; | ||
|
|
||
| namespace MLAPI.RuntimeTests.Metrics | ||
| { | ||
| #if true | ||
| public abstract class MetricsTestBase | ||
| { | ||
| protected static IEnumerator WaitForMetricsDispatch() | ||
| { | ||
| yield return new WaitForEndOfFrame(); | ||
| yield return new WaitForEndOfFrame(); | ||
| } | ||
|
|
||
| protected static IEnumerator WaitForAFewFrames() | ||
| { | ||
| yield return new WaitForSeconds(0.5f); | ||
| } | ||
|
|
||
| protected static IEventMetric<TEvent> AssertSingleMetricEventOfType<TEvent>(MetricCollection collection, string name) | ||
| { | ||
| var namedMessageSentMetric = collection.Metrics.SingleOrDefault(x => x.Name == name); | ||
|
bendoyon marked this conversation as resolved.
|
||
| Assert.NotNull(namedMessageSentMetric); | ||
|
|
||
| var typedMetric = namedMessageSentMetric as IEventMetric<TEvent>; | ||
| Assert.NotNull(typedMetric); | ||
| Assert.IsNotEmpty(typedMetric.Values); | ||
|
|
||
| return typedMetric; | ||
| } | ||
|
|
||
| protected class TestObserver : IMetricObserver | ||
| { | ||
| private readonly Action<MetricCollection> m_Assertion; | ||
|
|
||
| public TestObserver(Action<MetricCollection> assertion) | ||
| { | ||
| m_Assertion = assertion; | ||
| } | ||
|
|
||
| public void Observe(MetricCollection collection) | ||
| { | ||
| m_Assertion.Invoke(collection); | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
com.unity.multiplayer.mlapi/Tests/Runtime/Metrics/MetricsTestBase.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.