Skip to content

Commit

Permalink
Merge pull request #628 from WideSpectrumComputing/master
Browse files Browse the repository at this point in the history
Hot fix of Telemetry with NetExtensions and RollbarMiddleware
  • Loading branch information
akornich authored Mar 31, 2022
2 parents b244fea + 148a54b commit d47ded8
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 41 deletions.
9 changes: 6 additions & 3 deletions Rollbar.NetCore.AspNet/RollbarMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@ RequestDelegate nextRequestProcessor
this._logger = loggerFactory.CreateLogger<RollbarMiddleware>();
this._rollbarOptions = rollbarOptions.Value;

RollbarConfigurationUtil.DeduceRollbarTelemetryConfig(configuration);
RollbarInfrastructure.Instance?.TelemetryCollector?.StartAutocollection();
RollbarConfigurationUtil.DeduceRollbarConfig(configuration);
if (!RollbarInfrastructure.Instance.IsInitialized)
{
RollbarConfigurationUtil.DeduceRollbarTelemetryConfig(configuration);
RollbarInfrastructure.Instance?.TelemetryCollector?.StartAutocollection();
RollbarConfigurationUtil.DeduceRollbarConfig(configuration);
}
}

/// <summary>
Expand Down
11 changes: 3 additions & 8 deletions Rollbar.NetPlatformExtensions/RollbarLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,12 @@ public RollbarLoggerProvider(
{
if(configuration != null)
{
this._rollbarInfrastructureConfig = RollbarConfigurationUtil.DeduceRollbarConfig(configuration);
if(RollbarInfrastructure.Instance.IsInitialized)
{
RollbarInfrastructure.Instance.Config.Reconfigure(this._rollbarInfrastructureConfig);
}
else
if (!RollbarInfrastructure.Instance.IsInitialized)
{
this._rollbarInfrastructureConfig = RollbarConfigurationUtil.DeduceRollbarConfig(configuration);
RollbarInfrastructure.Instance.Init(this._rollbarInfrastructureConfig);
}
RollbarConfigurationUtil.DeduceRollbarTelemetryConfig(configuration);
_ = Rollbar.RollbarInfrastructure.Instance?.TelemetryCollector?.StartAutocollection();
this._rollbarInfrastructureConfig = RollbarInfrastructure.Instance.Config;
}

if(options != null)
Expand Down
126 changes: 126 additions & 0 deletions Rollbar/Config/_Config.cd
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1" MembersFormat="FullSignature">
<Class Name="Rollbar.HttpProxyOptions">
<Position X="24.25" Y="11.75" Width="7.25" />
<TypeIdentifier>
<HashCode>AAAAACAAAAAAAAAAAAAAgAACAAIAAAACAAAAEAAAAAA=</HashCode>
<FileName>Config\HttpProxyOptions.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarDataSecurityOptions">
<Position X="15.25" Y="12.5" Width="5.75" />
<TypeIdentifier>
<HashCode>AAAAACBACAIAAQAAAAAAgAAAAgAAAAAAIAAAAAAAAAA=</HashCode>
<FileName>Config\RollbarDataSecurityOptions.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarDestinationOptions">
<Position X="21" Y="0.5" Width="10.5" />
<Compartments>
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Enum Name="Rollbar.RollbarDestinationOptions.RollbarDestinationOptionsValidationRule">
<TypeIdentifier>
<NewMemberFileName>Config\RollbarDestinationOptions.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
</NestedTypes>
<TypeIdentifier>
<HashCode>AAAAACACAAAASAAAAAAAgAAAEAAgAAAAAAAAAAAAAIA=</HashCode>
<FileName>Config\RollbarDestinationOptions.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarDeveloperOptions">
<Position X="21" Y="6.5" Width="10.5" />
<TypeIdentifier>
<HashCode>AAAAACgAIAAAAICABAAAwAAEAAAAAAIIBAAEBAQAAAA=</HashCode>
<FileName>Config\RollbarDeveloperOptions.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarInfrastructureConfig">
<Position X="0.5" Y="0.5" Width="9.5" />
<NestedTypes>
<Enum Name="Rollbar.RollbarInfrastructureConfig.RollbarInfrastructureConfigValidationRule" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>Config\RollbarInfrastructureConfig.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
</NestedTypes>
<TypeIdentifier>
<HashCode>AEAAASAABAAABAAAEgAAgAAiAAAAAAAIAAAAAAAAAAA=</HashCode>
<FileName>Config\RollbarInfrastructureConfig.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarInfrastructureOptions">
<Position X="1" Y="16" Width="20.25" />
<TypeIdentifier>
<HashCode>AAgACCAAACAAAAAAAABA2AAAAABAAAAIAAAAAAAAAAQ=</HashCode>
<FileName>Config\RollbarInfrastructureOptions.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarLoggerConfig">
<Position X="12.75" Y="0.5" Width="8" />
<NestedTypes>
<Enum Name="Rollbar.RollbarLoggerConfig.RollbarLoggerConfigValidationRule" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>Config\RollbarLoggerConfig.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
</NestedTypes>
<TypeIdentifier>
<HashCode>CAAAAWgQQAIBAQAACAwAwAAAIAAAAAAgDAAgAAAIABg=</HashCode>
<FileName>Config\RollbarLoggerConfig.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarOfflineStoreOptions">
<Position X="11.25" Y="8.25" Width="9.5" />
<TypeIdentifier>
<HashCode>ABACACAAAAAAAICAAAAAgAAAAAAAAAAQAACAAACAEAA=</HashCode>
<FileName>Config\RollbarOfflineStoreOptions.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarPayloadAdditionOptions">
<Position X="0.5" Y="5.25" Width="10.25" />
<Compartments>
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Enum Name="Rollbar.RollbarPayloadAdditionOptions.RollbarPayloadAdditionOptionsValidationRule">
<TypeIdentifier>
<NewMemberFileName>Config\RollbarPayloadAdditionOptions.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
</NestedTypes>
<TypeIdentifier>
<HashCode>AIAACDAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAgAEAAA=</HashCode>
<FileName>Config\RollbarPayloadAdditionOptions.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarPayloadManipulationOptions">
<Position X="0.5" Y="12.75" Width="11.5" />
<TypeIdentifier>
<HashCode>AAACACAAAAAAAAAAAAAAgAUCAAAAAAAQAAAAAAAAAAA=</HashCode>
<FileName>Config\RollbarPayloadManipulationOptions.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarTelemetryOptions">
<Position X="22.75" Y="15" Width="8" />
<TypeIdentifier>
<HashCode>AAAIACAAAAAAAFAAAAAigAAAAAAAAAAAAAACABAAAAI=</HashCode>
<FileName>Config\RollbarTelemetryOptions.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>
24 changes: 24 additions & 0 deletions Rollbar/DTOs/Notifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public static class ReservedProperties
/// The configuration
/// </summary>
public static readonly string Configuration = "configured_options";
/// <summary>
/// The Rollbar Infrastructure configuration
/// </summary>
public static readonly string InfrastructureConfiguration = "infrastructure_options";
}

/// <summary>
Expand Down Expand Up @@ -85,6 +89,21 @@ public IRollbarLoggerConfig? Configuration
get { return this[ReservedProperties.Configuration] as IRollbarLoggerConfig; }
set { this[ReservedProperties.Configuration] = value; }
}
/// <summary>
/// Gets or sets the Rollbar Infrastructure configuration.
/// </summary>
/// <value>The configuration.</value>
public IRollbarInfrastructureConfig? InfrastructureConfiguration
{
get
{
return this[ReservedProperties.InfrastructureConfiguration] as IRollbarInfrastructureConfig;
}
private set
{
this[ReservedProperties.InfrastructureConfiguration] = value;
}
}

/// <summary>
/// Initializes a new instance of the <see cref="Notifier"/> class.
Expand All @@ -103,6 +122,11 @@ public Notifier(IDictionary<string, object?>? arbitraryKeyValuePairs)
{
this.Name = Notifier.notifierName;
this.Version = Notifier.notifierAssemblyVersion;

if (RollbarInfrastructure.Instance.IsInitialized)
{
this.InfrastructureConfiguration = RollbarInfrastructure.Instance.Config;
}
}
}
}
17 changes: 11 additions & 6 deletions Rollbar/Telemetry/RollbarTelemetryCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Diagnostics;
using System.Threading;

using Rollbar;
using Rollbar.DTOs;

/// <summary>
Expand Down Expand Up @@ -37,6 +36,8 @@ public static RollbarTelemetryCollector? Instance
internal RollbarTelemetryCollector()
{
traceSource.TraceInformation($"Creating the {typeof(RollbarTelemetryCollector).Name}...");

this._telemetryQueue.QueueDepth = 0; // since we do not have valid telemetry config assigned yet...
}

#endregion singleton implementation
Expand All @@ -51,12 +52,19 @@ internal void Init(IRollbarTelemetryOptions options)
}

this._config = options;
if(this._config != null)

if (this._config != null)
{
// let's resync with relevant config settings:
this._telemetryQueue.QueueDepth = this._config.TelemetryQueueDepth;

this._config.Reconfigured += _config_Reconfigured;
this.StartAutocollection();
}
else
{
this._telemetryQueue.QueueDepth = 0;
}
}

/// <summary>
Expand Down Expand Up @@ -142,9 +150,6 @@ public IRollbarTelemetryCollector StartAutocollection()
return this; // this, essentially, means the auto-collection is off...
}

// let's resync with relevant config settings:
this._telemetryQueue.QueueDepth = this.Config.TelemetryQueueDepth;

lock (_syncRoot)
{
if (this._telemetryThread == null)
Expand Down
4 changes: 2 additions & 2 deletions Rollbar/_Rollbar.cd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Enum Name="Rollbar.Infrastructure.RollbarQueueController.PayloadTraceSources" Collapsed="true">
<Enum Name="Rollbar.Infrastructure.RollbarQueueController.PayloadTraceSources">
<TypeIdentifier>
<NewMemberFileName>Infrastructure\RollbarQueueController.cs</NewMemberFileName>
</TypeIdentifier>
Expand Down Expand Up @@ -86,7 +86,7 @@
<Lollipop Position="0.2" />
</Class>
<Interface Name="Rollbar.IRollbar">
<Position X="0.5" Y="11.5" Width="5.5" />
<Position X="0.5" Y="11" Width="5.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAgIAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>IRollbar.cs</FileName>
Expand Down
25 changes: 16 additions & 9 deletions Rollbar/_RollbarConfig.cd
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1" MembersFormat="FullSignature">
<Interface Name="Rollbar.IHttpProxyOptions">
<Position X="0.75" Y="8.25" Width="2.75" />
<Position X="0.5" Y="12.5" Width="4.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAACAAIAAAACAAAAAAAAAAA=</HashCode>
<FileName>IHttpProxyOptions.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarDataSecurityOptions">
<Position X="0.5" Y="12.5" Width="4.5" />
<Position X="0.5" Y="16.5" Width="4.5" />
<TypeIdentifier>
<HashCode>AAAAAABACAAAAQAAAAAAAAAAAgAAAAAAIAAAAAAAAAA=</HashCode>
<FileName>IRollbarDataSecurityOptions.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarDestinationOptions">
<Position X="0.75" Y="6.5" Width="2.5" />
<Position X="0.75" Y="6" Width="4.5" />
<TypeIdentifier>
<HashCode>AAAAAAACAAAAQAAAAAAAAAAAEAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>IRollbarDestinationOptions.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarDeveloperOptions">
<Position X="0.5" Y="10.25" Width="3.5" />
<Position X="0.5" Y="10" Width="4.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAIAAAAAAAAAAAAAAAAIIAAAEBAQAAAA=</HashCode>
<FileName>IRollbarDeveloperOptions.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarInfrastructureOptions">
<Position X="6.25" Y="8" Width="2.75" />
<Position X="6.5" Y="7.75" Width="5" />
<TypeIdentifier>
<HashCode>AAAACAAAAAAAAAAAAAAAEAAAAABAAAAIAAAAAAAAAAA=</HashCode>
<FileName>IRollbarInfrastructureOptions.cs</FileName>
Expand All @@ -43,14 +43,14 @@
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarPayloadAdditionOptions">
<Position X="4.5" Y="10.25" Width="2.5" />
<Position X="0.5" Y="14.5" Width="5" />
<TypeIdentifier>
<HashCode>AIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA=</HashCode>
<FileName>IRollbarPayloadAdditionOptions.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarPayloadManipulationOptions">
<Position X="5.25" Y="12.5" Width="3.25" />
<Position X="0.5" Y="8" Width="5.25" />
<TypeIdentifier>
<HashCode>AAACAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>IRollbarPayloadManipulationOptions.cs</FileName>
Expand All @@ -64,14 +64,14 @@
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarInfrastructureConfig">
<Position X="6" Y="3.25" Width="4.5" />
<Position X="6.5" Y="3.25" Width="4.5" />
<TypeIdentifier>
<HashCode>AAAAAAAABAAABAAAAAAAAAAgAAAAAAAIAAAAAAAAAAA=</HashCode>
<FileName>IRollbarInfrastructureConfig.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarOfflineStoreOptions">
<Position X="6.25" Y="6" Width="3.75" />
<Position X="6.5" Y="5.75" Width="5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAICAAAAAAAAAAAAAAAAAAAAAAACAAAA=</HashCode>
<FileName>IRollbarOfflineStoreOptions.cs</FileName>
Expand All @@ -91,6 +91,13 @@
<FileName>Common\IReconfigurable.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarTelemetryOptions">
<Position X="6.5" Y="10.25" Width="4" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAABAAAAACAAAAAAAAAAAAAAACABAAAAA=</HashCode>
<FileName>IRollbarTelemetryOptions.cs</FileName>
</TypeIdentifier>
</Interface>
<Enum Name="Rollbar.ErrorLevel">
<Position X="9" Y="0.75" Width="1.25" />
<TypeIdentifier>
Expand Down
Loading

0 comments on commit d47ded8

Please sign in to comment.