Skip to content

Commit 314c4d2

Browse files
committed
Adding Sentry logging and doing major code cleanup.
1 parent f390f97 commit 314c4d2

File tree

8 files changed

+1051
-1273
lines changed

8 files changed

+1051
-1273
lines changed

eFormAPI/Plugins/OuterInnerResource.Pn/OuterInnerResource.Pn/EformOuterInnerResourcePlugin.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
*/
2424

25+
using System.Runtime.InteropServices;
2526
using System.Text.RegularExpressions;
2627
using Castle.MicroKernel.Registration;
2728
using Castle.Windsor;
29+
using Sentry;
2830

2931
namespace OuterInnerResource.Pn
3032
{
@@ -103,6 +105,49 @@ public void ConfigureOptionsServices(
103105

104106
public void ConfigureDbContext(IServiceCollection services, string connectionString)
105107
{
108+
SentrySdk.Init(options =>
109+
{
110+
// A Sentry Data Source Name (DSN) is required.
111+
// See https://docs.sentry.io/product/sentry-basics/dsn-explainer/
112+
// You can set it in the SENTRY_DSN environment variable, or you can set it in code here.
113+
options.Dsn = "https://9bf9ba91ddb235518478803b2b202fc8@o4506241219428352.ingest.us.sentry.io/4508266875781120";
114+
115+
// When debug is enabled, the Sentry client will emit detailed debugging information to the console.
116+
// This might be helpful, or might interfere with the normal operation of your application.
117+
// We enable it here for demonstration purposes when first trying Sentry.
118+
// You shouldn't do this in your applications unless you're troubleshooting issues with Sentry.
119+
options.Debug = false;
120+
121+
// This option is recommended. It enables Sentry's "Release Health" feature.
122+
options.AutoSessionTracking = true;
123+
124+
// This option is recommended for client applications only. It ensures all threads use the same global scope.
125+
// If you're writing a background service of any kind, you should remove this.
126+
options.IsGlobalModeEnabled = true;
127+
128+
// This option will enable Sentry's tracing features. You still need to start transactions and spans.
129+
options.EnableTracing = true;
130+
});
131+
132+
string pattern = @"Database=(\d+)_eform-angular-outer-inner-resource-plugin;";
133+
Match match = Regex.Match(connectionString!, pattern);
134+
135+
if (match.Success)
136+
{
137+
string numberString = match.Groups[1].Value;
138+
int number = int.Parse(numberString);
139+
SentrySdk.ConfigureScope(scope =>
140+
{
141+
scope.SetTag("customerNo", number.ToString());
142+
Console.WriteLine("customerNo: " + number);
143+
scope.SetTag("osVersion", Environment.OSVersion.ToString());
144+
Console.WriteLine("osVersion: " + Environment.OSVersion);
145+
scope.SetTag("osArchitecture", RuntimeInformation.OSArchitecture.ToString());
146+
Console.WriteLine("osArchitecture: " + RuntimeInformation.OSArchitecture);
147+
scope.SetTag("osName", RuntimeInformation.OSDescription);
148+
Console.WriteLine("osName: " + RuntimeInformation.OSDescription);
149+
});
150+
}
106151
_connectionString = connectionString;
107152
services.AddDbContext<OuterInnerResourcePnDbContext>(o =>
108153
o.UseMySql(connectionString, new MariaDbServerVersion(

eFormAPI/Plugins/OuterInnerResource.Pn/OuterInnerResource.Pn/OuterInnerResource.Pn.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<PackageReference Include="Microting.eFormOuterInnerResourceBase" Version="8.0.0" />
3030
<PackageReference Include="OtpSharp.Core" Version="1.0.0" />
3131
<PackageReference Include="Microting.eForm" Version="8.0.68" />
32+
<PackageReference Include="Sentry" Version="4.13.0" />
3233
</ItemGroup>
3334

3435
</Project>

eFormAPI/Plugins/OuterInnerResource.Pn/OuterInnerResource.Pn/Services/ExcelService.cs

Lines changed: 226 additions & 354 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)