Skip to content

Commit 6f0baf6

Browse files
author
marc
committed
resolve conflict
2 parents f01641f + 7b25381 commit 6f0baf6

File tree

7 files changed

+511
-77
lines changed

7 files changed

+511
-77
lines changed

Src/StackifyLib/Config.cs

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Reflection;
66
using Newtonsoft.Json.Linq;
7+
using System.Text.RegularExpressions;
78
using StackifyLib.Utils;
89

910
namespace StackifyLib
@@ -117,6 +118,26 @@ public static void LoadSettings()
117118
LoggingJsonMaxFields = maxFields;
118119
}
119120
}
121+
122+
var rumScriptUrl = Get("Stackify.Rum_Script_Url", "https://stckjs.stackify.com/stckjs.js");
123+
124+
if (Uri.IsWellFormedUriString(rumScriptUrl, UriKind.Absolute))
125+
{
126+
var uri = new Uri(rumScriptUrl);
127+
128+
var scheme = uri.Scheme;
129+
130+
if (string.Equals(scheme, "https", StringComparison.OrdinalIgnoreCase))
131+
{
132+
RumScriptUrl = rumScriptUrl;
133+
}
134+
}
135+
136+
var rumKey = Get("Stackify.Rum_Key");
137+
if (Regex.IsMatch(rumKey, "^[A-Za-z0-9_-]+$"))
138+
{
139+
RumKey = rumKey;
140+
}
120141
}
121142
catch (Exception ex)
122143
{
@@ -161,6 +182,10 @@ public static void LoadSettings()
161182

162183
public static bool? IsStackifyJsonLoaded { get; set; } = false;
163184

185+
public static string RumScriptUrl { get; set; }
186+
187+
public static string RumKey { get; set; }
188+
164189

165190
/// <summary>
166191
/// Attempts to fetch a setting value given the key.
@@ -189,8 +214,13 @@ internal static string Get(string key, string defaultValue = null)
189214
var key2 = key.Replace("Stackify.", string.Empty);
190215
var stackifyJson = _configuration.GetSection(key2);
191216
v = stackifyJson.Value;
217+
if (string.IsNullOrEmpty(v))
218+
{
219+
// Search in Retrace, but key will likely still be Stackify.name, not Retrace.name in the code
220+
var retraceAppSettings = _configuration.GetSection("Retrace");
221+
v = retraceAppSettings[key.Replace("Stackify.", string.Empty)];
222+
}
192223
}
193-
}
194224
#endif
195225

196226
#if NETFULL
@@ -200,9 +230,26 @@ internal static string Get(string key, string defaultValue = null)
200230
}
201231
#endif
202232

203-
if (string.IsNullOrEmpty(v))
204-
{
205-
v = System.Environment.GetEnvironmentVariable(key);
233+
if (string.IsNullOrEmpty(v))
234+
{
235+
v = System.Environment.GetEnvironmentVariable(key);
236+
}
237+
238+
if (string.IsNullOrEmpty(v))
239+
{
240+
v = System.Environment.GetEnvironmentVariable(key.ToUpperInvariant());
241+
}
242+
243+
if (string.IsNullOrEmpty(v))
244+
{
245+
// Linux systems do not allow period in an environment variable name
246+
v = System.Environment.GetEnvironmentVariable(key.Replace('.', '_').ToUpperInvariant());
247+
}
248+
249+
if (string.IsNullOrEmpty(v) && key.StartsWith("Stackify."))
250+
{
251+
v = System.Environment.GetEnvironmentVariable("RETRACE_" + key.Substring(9).Replace('.', '_').ToUpperInvariant());
252+
}
206253
}
207254
}
208255
}

Src/StackifyLib/Extensions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ public static void ConfigureStackifyLogging(this Microsoft.Extensions.Configurat
3838
//tell it to load all the settings since we now have the config
3939
Config.LoadSettings();
4040
}
41+
42+
public static void ConfigureStackifyLib(this Microsoft.Extensions.Configuration.IConfiguration configuration)
43+
{
44+
Config.SetConfiguration(configuration);
45+
//tell it to load all the settings since we now have the config
46+
Config.LoadSettings();
47+
}
4148
#endif
4249
}
4350
}

Src/StackifyLib/Internal/Logs/LogQueue.cs

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using System.Threading.Tasks;
1111

1212
#if NETFULL
13-
using System.Runtime.Remoting.Messaging;
1413
using StackifyLib.Web;
1514
using System.Web;
1615
#endif
@@ -106,27 +105,7 @@ public void QueueLogMessage(Models.LogMsg msg)
106105
#if NETFULL
107106
try
108107
{
109-
if (string.IsNullOrEmpty(msg.TransID))
110-
{
111-
var stackifyRequestID = CallContext.LogicalGetData("Stackify-RequestID");
112-
113-
if (stackifyRequestID != null)
114-
{
115-
msg.TransID = stackifyRequestID.ToString();
116-
}
117-
}
118-
119-
if (string.IsNullOrEmpty(msg.TransID))
120-
{
121-
//gets from Trace.CorrelationManager.ActivityId but doesnt assume it is guid since it technically doesn't have to be
122-
//not calling the CorrelationManager method because it blows up if it isn't a guid
123-
var correltionManagerId = CallContext.LogicalGetData("E2ETrace.ActivityID");
124-
125-
if (correltionManagerId != null && correltionManagerId is Guid && ((Guid)correltionManagerId) != Guid.Empty)
126-
{
127-
msg.TransID = correltionManagerId.ToString();
128-
}
129-
}
108+
msg.TransID = StackifyLib.Utils.HelperFunctions.GetRequestId();
130109

131110
if (string.IsNullOrEmpty(msg.TransID))
132111
{
@@ -186,27 +165,11 @@ public void QueueLogMessage(Models.LogMsg msg)
186165
// get RequestID
187166
if (string.IsNullOrEmpty(msg.TransID))
188167
{
189-
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
168+
string reqId = StackifyLib.Utils.HelperFunctions.GetRequestId();
190169

191-
var agentAssemblyQry = assemblies.Where(assembly => assembly.FullName.Contains("Stackify.Agent"));
192-
if(agentAssemblyQry.Count() > 0)
170+
if (reqId != null)
193171
{
194-
var middleware = agentAssemblyQry.First();
195-
var callContextType = middleware.GetType("Stackify.Agent.Threading.StackifyCallContext");
196-
if (callContextType != null)
197-
{
198-
var traceCtxType = middleware.GetType("Stackify.Agent.Tracing.ITraceContext");
199-
if(traceCtxType != null)
200-
{
201-
var traceContextProp = callContextType.GetProperty("TraceContext")?.GetValue(null);
202-
if (traceContextProp != null)
203-
{
204-
var reqIdProp = traceCtxType.GetProperty("RequestId")?.GetValue(traceContextProp)?.ToString();
205-
if(!string.IsNullOrEmpty(reqIdProp))
206-
msg.TransID = reqIdProp;
207-
}
208-
}
209-
}
172+
msg.TransID = reqId;
210173
}
211174
}
212175
#endif

Src/StackifyLib/Models/EnvironmentDetail.cs

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,17 @@ public static string GetDeviceName()
115115
return deviceName.Substring(0, deviceName.Length > 60 ? 60 : deviceName.Length);
116116
}
117117

118+
//WIN-230 - Set DeviceName to Environment.MachineName.
118119
deviceName = Environment.MachineName;
119120

120-
if (AzureConfig.InAzure && ((AzureConfig.IsWebsite) || (AzureConfig.InAzure && Environment.MachineName.StartsWith("RD"))))
121-
{
122-
deviceName = AzureConfig.AzureInstanceName;
123-
}
124-
else
125-
{
126-
var isDefaultDeviceNameEc2 = IsEc2MachineName(deviceName);
121+
var isDefaultDeviceNameEc2 = IsEc2MachineName(deviceName);
127122

128-
if (Config.IsEc2 == null || Config.IsEc2 == true || isDefaultDeviceNameEc2)
123+
if (Config.IsEc2 == null || Config.IsEc2 == true || isDefaultDeviceNameEc2)
124+
{
125+
var instanceID_task = GetEC2InstanceId();
126+
if (string.IsNullOrWhiteSpace(instanceID_task) == false)
129127
{
130-
var ec2InstanceId = GetEC2InstanceId();
131-
if (string.IsNullOrWhiteSpace(ec2InstanceId) == false)
132-
{
133-
deviceName = ec2InstanceId;
134-
}
128+
deviceName = instanceID_task;
135129
}
136130
}
137131

@@ -206,24 +200,18 @@ public static string GetDeviceName()
206200
return deviceName.Substring(0, deviceName.Length > 60 ? 60 : deviceName.Length);
207201
}
208202

203+
//WIN-230 - Set DeviceName to Environment.MachineName.
209204
deviceName = Environment.MachineName;
210205

211-
if (AzureConfig.InAzure && ((AzureConfig.IsWebsite) || (AzureConfig.InAzure && Environment.MachineName.StartsWith("RD"))))
212-
{
213-
deviceName = AzureConfig.AzureInstanceName;
214-
}
215-
else
216-
{
217-
var isDefaultDeviceNameEc2 = IsEc2MachineName(deviceName);
206+
var isDefaultDeviceNameEc2 = IsEc2MachineName(deviceName);
218207

219-
if (Config.IsEc2 == null || Config.IsEc2 == true || isDefaultDeviceNameEc2)
208+
if (Config.IsEc2 == null || Config.IsEc2 == true || isDefaultDeviceNameEc2)
209+
{
210+
var instanceID_task = GetEC2InstanceId();
211+
instanceID_task.Wait();
212+
if (string.IsNullOrWhiteSpace(instanceID_task.Result) == false)
220213
{
221-
var instanceID_task = GetEC2InstanceId();
222-
instanceID_task.Wait();
223-
if (string.IsNullOrWhiteSpace(instanceID_task.Result) == false)
224-
{
225-
deviceName = instanceID_task.Result;
226-
}
214+
deviceName = instanceID_task.Result;
227215
}
228216
}
229217

Src/StackifyLib/StackifyLib.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<AssemblyTitle>Stackify API</AssemblyTitle>
5-
<VersionPrefix>2.1.0</VersionPrefix>
5+
<VersionPrefix>2.2.2</VersionPrefix>
66
<TargetFrameworks>netstandard2.0;net40;net45;net451;net452;net46;net461;net462</TargetFrameworks>
77
<AssemblyName>StackifyLib</AssemblyName>
88
<PackageId>StackifyLib</PackageId>
@@ -13,15 +13,15 @@
1313
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
1414
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
1515
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
16-
<Version>2.1.8-beta</Version>
16+
<Version>2.2.2</Version>
1717
<Authors>StackifyLib</Authors>
1818
<PackageProjectUrl>https://github.com/stackify/stackify-api-dotnet</PackageProjectUrl>
1919
<PackageLicenseUrl>https://github.com/stackify/stackify-api-dotnet/blob/master/LICENSE</PackageLicenseUrl>
2020
<RepositoryUrl>https://github.com/stackify/stackify-api-dotnet</RepositoryUrl>
2121
<RepositoryType>git</RepositoryType>
2222
<PackageIconUrl>https://stackify.com/wp-content/uploads/2017/02/stk.png</PackageIconUrl>
23-
<AssemblyVersion>2.1.8.0</AssemblyVersion>
24-
<FileVersion>2.1.8.0</FileVersion>
23+
<AssemblyVersion>2.2.2.0</AssemblyVersion>
24+
<FileVersion>2.2.2.0</FileVersion>
2525
<PackageReleaseNotes>Remove default internal file logger</PackageReleaseNotes>
2626
</PropertyGroup>
2727

@@ -56,4 +56,4 @@
5656
<DefineConstants>NETFULL</DefineConstants>
5757
</PropertyGroup>
5858

59-
</Project>
59+
</Project>

0 commit comments

Comments
 (0)