Skip to content

Commit

Permalink
Update dependencies and fix log option
Browse files Browse the repository at this point in the history
  • Loading branch information
marcschier committed Apr 16, 2024
1 parent 92b6b7c commit 8a15273
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 34 deletions.
10 changes: 5 additions & 5 deletions e2e-tests/IIoTPlatform-E2E-Tests/IIoTPlatform-E2E-Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
<None Remove="TestResults\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.39.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="SSH.NET" Version="2023.0.1" />
<PackageReference Include="SSH.NET" Version="2024.0.0" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
<None Remove="TestResults\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.10.0" />
<PackageReference Include="Azure.Identity" Version="1.11.0" />
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.11.2" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.38.1" />
<PackageReference Include="Azure.ResourceManager" Version="1.10.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Azure.ResourceManager" Version="1.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.39.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="SSH.NET" Version="2023.0.1" />
<PackageReference Include="SSH.NET" Version="2024.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion samples/Http/Parameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public HttpClient CreateHttpClientWithAuth()
=> cert != null && Certificate?.Thumbprint == cert?.Thumbprint
});
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", ApiKey);
new AuthenticationHeaderValue("ApiKey", ApiKey);
return httpClient;
}

Expand Down
2 changes: 1 addition & 1 deletion samples/IoTHub/MonitorMessages/MonitorMessages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.10.0" />
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.11.2" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.39.1" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ public override void PostConfigure(string? name, PublisherOptions options)
{
options.DebugLogNotificationsFilter =
GetStringOrDefault(DebugLogNotificationsFilterKey);
options.DebugLogNotifications ??= (options.DebugLogNotificationsFilter != null);
options.DebugLogNotifications ??=
(options.DebugLogNotificationsFilter != null ? true : null);
}

if (options.DebugLogNotificationsWithHeartbeat == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,13 @@ private OpcUaSubscription(OpcUaSubscription subscription, bool copyEventHandlers
_sequenceNumber = subscription._sequenceNumber;

_goodMonitoredItems = subscription._goodMonitoredItems;
_missingKeepAlives = subscription._missingKeepAlives;
_badMonitoredItems = subscription._badMonitoredItems;
_reportingItems = subscription._reportingItems;
_disabledItems = subscription._disabledItems;
_samplingItems = subscription._samplingItems;
_notAppliedItems = subscription._notAppliedItems;

_missingKeepAlives = subscription._missingKeepAlives;
_unassignedNotifications = subscription._unassignedNotifications;

_additionallyMonitored = subscription._additionallyMonitored;
Expand Down Expand Up @@ -321,7 +326,7 @@ public async ValueTask SyncWithSessionAsync(ISession session, CancellationToken
"Failed to apply state to Subscription {Subscription} in session {Session}...",
this, session);

// Retry in 2 seconds
// Retry in 1 minute if not automatically retried
TriggerSubscriptionManagementCallbackIn(
_options.Value.SubscriptionErrorRetryDelay, kDefaultErrorRetryDelay);
}
Expand Down Expand Up @@ -490,6 +495,11 @@ private async Task CloseCurrentSubscriptionAsync()
_goodMonitoredItems = 0;
_badMonitoredItems = 0;

_reportingItems = 0;
_disabledItems = 0;
_samplingItems = 0;
_notAppliedItems = 0;

await Try.Async(
() => SetPublishingModeAsync(false)).ConfigureAwait(false);
await Try.Async(
Expand Down Expand Up @@ -836,8 +846,6 @@ private async Task<bool> SynchronizeMonitoredItemsAsync(
invalidItems++;
}
}

Debug.Assert(remove.All(m => !m.Valid), "All removed items should be invalid now");
var set = desiredMonitoredItems.Where(m => m.Valid).ToList();
_logger.LogDebug(
"Completed {Count} valid and {Invalid} invalid items in subscription {Subscription}...",
Expand Down Expand Up @@ -952,22 +960,42 @@ private async Task<bool> SynchronizeMonitoredItemsAsync(
}

// Cleanup all items that are not in the currently monitoring list
previouslyMonitored
var dispose = previouslyMonitored
.Except(set)
.ToList()
.ForEach(m => m.Dispose());
.ToList();
dispose.ForEach(m => m.Dispose());

// Update subscription state
_additionallyMonitored = set
.Where(m => !m.AttachedToSubscription)
.ToFrozenDictionary(m => m.ClientHandle, m => m);

_badMonitoredItems = invalidItems;
_goodMonitoredItems = set.Count - invalidItems;

_logger.LogInformation(
"Now monitoring {Count} (Good:{Good}/Bad:{Bad}) nodes in subscription {Subscription}.",
set.Count, _goodMonitoredItems, _badMonitoredItems, this);
_goodMonitoredItems = set
.Count - invalidItems;
_reportingItems = set
.Count(r => r.Status?.MonitoringMode == Opc.Ua.MonitoringMode.Reporting);
_disabledItems = set
.Count(r => r.Status?.MonitoringMode == Opc.Ua.MonitoringMode.Disabled);
_samplingItems = set
.Count(r => r.Status?.MonitoringMode == Opc.Ua.MonitoringMode.Sampling);
_notAppliedItems = set
.Count(r => r.Status?.MonitoringMode != r.MonitoringMode);

_logger.LogInformation(@"{Subscription} - Now monitoring {Count} nodes:
# Good/Bad: {Good}/{Bad}
# Reporting: {Reporting}
# Sampling: {Sampling}
# Disabled: {Disabled}
# Not applied: {NotApplied}
# Removed: {Disposed}",
this, set.Count,
_goodMonitoredItems, _badMonitoredItems,
_reportingItems,
_samplingItems,
_disabledItems,
_notAppliedItems,
dispose.Count);

// Refresh condition
if (set.OfType<OpcUaMonitoredItem.Condition>().Any())
Expand Down Expand Up @@ -1294,8 +1322,8 @@ private void TriggerSubscriptionManagementCallbackIn(TimeSpan? delay,
}
if (delay != Timeout.InfiniteTimeSpan)
{
_logger.LogDebug(
"Setting up trigger to reapply state to {Subscription} in {Timeout}",
_logger.LogInformation(
"Setting up trigger to reapply state to {Subscription} in {Timeout}...",
this, delay);
}
_timer.Change(delay.Value, Timeout.InfiniteTimeSpan);
Expand Down Expand Up @@ -1784,11 +1812,12 @@ private void OnKeepAliveMissing(object? state)
/// </summary>
/// <param name="subscription"></param>
/// <param name="e"></param>
/// <exception cref="NotImplementedException"></exception>
private void OnPublishStatusChange(Subscription subscription, PublishStateChangedEventArgs e)
{
if (_disposed)
{
// Debug.Fail("Should not be called after dispose");
// This currently happens because the stack caches the callbacks!
return;
}

Expand Down Expand Up @@ -1837,6 +1866,8 @@ private void OnStateChange(Subscription subscription, SubscriptionStateChangedEv
{
if (_disposed)
{
// Debug.Fail("Should not be called after dispose");
// This currently happens because the stack caches the callbacks!
return;
}

Expand Down Expand Up @@ -2227,15 +2258,27 @@ public void InitializeMetrics()
_meter.CreateObservableCounter("iiot_edge_publisher_unassigned_notification_count",
() => new Measurement<long>(_unassignedNotifications, _metrics.TagList),
description: "Number of notifications that could not be assigned.");
_meter.CreateObservableUpDownCounter("iiot_edge_publisher_monitored_items",
() => new Measurement<long>(TotalMonitoredItems, _metrics.TagList),
description: "Total monitored item count.");
_meter.CreateObservableUpDownCounter("iiot_edge_publisher_good_nodes",
() => new Measurement<long>(_goodMonitoredItems, _metrics.TagList),
description: "Monitored items successfully created.");
_meter.CreateObservableUpDownCounter("iiot_edge_publisher_bad_nodes",
() => new Measurement<long>(_badMonitoredItems, _metrics.TagList),
description: "Monitored items with errors.");
_meter.CreateObservableUpDownCounter("iiot_edge_publisher_monitored_items",
() => new Measurement<long>(TotalMonitoredItems, _metrics.TagList),
description: "Total monitored item count.");
_meter.CreateObservableUpDownCounter("iiot_edge_publisher_reporting_nodes",
() => new Measurement<long>(_reportingItems, _metrics.TagList),
description: "Monitored items reporting.");
_meter.CreateObservableUpDownCounter("iiot_edge_publisher_sampling_nodes",
() => new Measurement<long>(_samplingItems, _metrics.TagList),
description: "Monitored items with sampling enabled.");
_meter.CreateObservableUpDownCounter("iiot_edge_publisher_disabled_nodes",
() => new Measurement<long>(_disabledItems, _metrics.TagList),
description: "Monitored items with monitoring mode disabled.");
_meter.CreateObservableUpDownCounter("iiot_edge_publisher_nodes_monitoring_mode_inconsistent",
() => new Measurement<long>(_notAppliedItems, _metrics.TagList),
description: "Monitored items with monitoring mode not applied.");

_meter.CreateObservableUpDownCounter("iiot_edge_publisher_publish_requests_per_subscription",
() => new Measurement<double>(Ratio(State.OutstandingRequestCount, State.SubscriptionCount),
Expand Down Expand Up @@ -2275,6 +2318,10 @@ public void InitializeMetrics()
private static uint _lastIndex;
private uint _currentSequenceNumber;
private int _goodMonitoredItems;
private int _reportingItems;
private int _disabledItems;
private int _samplingItems;
private int _notAppliedItems;
private int _badMonitoredItems;
private int _missingKeepAlives;
private int _continuouslyMissingKeepAlives;
Expand Down

0 comments on commit 8a15273

Please sign in to comment.