Fix issue with not populated location name (#10)
* Set sdkVersion and remove locationId/locationDisplayName fom configurable fields * Remove auto update for proj file * Fix missing location issue
This commit is contained in:
Родитель
c49fa65864
Коммит
aceea5a4a0
|
@ -0,0 +1,12 @@
|
|||
using Microsoft.Azure.AvailabilityMonitoring;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Azure.AvailabilityMonitoring
|
||||
{
|
||||
internal interface IAvailabilityTestInternalConfiguration
|
||||
{
|
||||
string TestDisplayName { get; }
|
||||
|
||||
string LocationDisplayName { get; }
|
||||
}
|
||||
}
|
|
@ -33,35 +33,18 @@ namespace Microsoft.Azure.AvailabilityMonitoring
|
|||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static Logging Log { get { return AvailabilityTest.Logging.SingeltonInstance; } }
|
||||
|
||||
|
||||
internal static AvailabilityTestScope StartNew(IAvailabilityTestConfiguration testConfig,
|
||||
TelemetryConfiguration telemetryConfig,
|
||||
bool flushOnDispose,
|
||||
ILogger log)
|
||||
{
|
||||
return StartNew(testConfig, telemetryConfig, flushOnDispose, log, logScope: null);
|
||||
}
|
||||
|
||||
internal static AvailabilityTestScope StartNew(IAvailabilityTestConfiguration testConfig,
|
||||
internal static AvailabilityTestScope StartNew(IAvailabilityTestInternalConfiguration testConfig,
|
||||
TelemetryConfiguration telemetryConfig,
|
||||
bool flushOnDispose,
|
||||
ILogger log,
|
||||
object logScope)
|
||||
{
|
||||
Validate.NotNull(testConfig, nameof(testConfig));
|
||||
return StartNew(testConfig.TestDisplayName, telemetryConfig, flushOnDispose, log, logScope);
|
||||
}
|
||||
|
||||
public static AvailabilityTestScope StartNew(string testDisplayName,
|
||||
TelemetryConfiguration telemetryConfig,
|
||||
bool flushOnDispose,
|
||||
ILogger log)
|
||||
|
||||
{
|
||||
return StartNew(testDisplayName, telemetryConfig, flushOnDispose, log, logScope: null);
|
||||
return StartNew(testConfig.TestDisplayName, testConfig.LocationDisplayName, telemetryConfig, flushOnDispose, log, logScope);
|
||||
}
|
||||
|
||||
public static AvailabilityTestScope StartNew(string testDisplayName,
|
||||
string locationDisplayName,
|
||||
TelemetryConfiguration telemetryConfig,
|
||||
bool flushOnDispose,
|
||||
ILogger log,
|
||||
|
@ -70,7 +53,7 @@ namespace Microsoft.Azure.AvailabilityMonitoring
|
|||
{
|
||||
log = AvailabilityTest.Log.CreateFallbackLogIfRequired(log);
|
||||
|
||||
var testScope = new AvailabilityTestScope(testDisplayName, telemetryConfig, flushOnDispose, log, logScope);
|
||||
var testScope = new AvailabilityTestScope(testDisplayName, locationDisplayName, telemetryConfig, flushOnDispose, log, logScope);
|
||||
testScope.Start();
|
||||
|
||||
return testScope;
|
||||
|
|
|
@ -57,6 +57,8 @@ namespace Microsoft.Azure.AvailabilityMonitoring
|
|||
|
||||
public string TestDisplayName { get; }
|
||||
|
||||
public string LocationDisplayName { get; }
|
||||
|
||||
public string ActivitySpanOperationName
|
||||
{
|
||||
get
|
||||
|
@ -85,12 +87,14 @@ namespace Microsoft.Azure.AvailabilityMonitoring
|
|||
}
|
||||
}
|
||||
|
||||
public AvailabilityTestScope(string testDisplayName, TelemetryConfiguration telemetryConfig, bool flushOnDispose, ILogger log, object logScope)
|
||||
public AvailabilityTestScope(string testDisplayName, string locationDisplayName, TelemetryConfiguration telemetryConfig, bool flushOnDispose, ILogger log, object logScope)
|
||||
{
|
||||
Validate.NotNullOrWhitespace(testDisplayName, nameof(testDisplayName));
|
||||
Validate.NotNullOrWhitespace(locationDisplayName, nameof(locationDisplayName));
|
||||
Validate.NotNull(telemetryConfig, nameof(telemetryConfig));
|
||||
|
||||
this.TestDisplayName = testDisplayName;
|
||||
this.LocationDisplayName = locationDisplayName;
|
||||
|
||||
_instrumentationKey = telemetryConfig.InstrumentationKey;
|
||||
_telemetryClient = new TelemetryClient(telemetryConfig);
|
||||
|
@ -267,7 +271,7 @@ namespace Microsoft.Azure.AvailabilityMonitoring
|
|||
|
||||
if (String.IsNullOrWhiteSpace(availabilityResult.Name))
|
||||
{
|
||||
availabilityResult.Name = TestDisplayName;
|
||||
availabilityResult.Name = this.TestDisplayName;
|
||||
}
|
||||
else if (! availabilityResult.Name.Equals(TestDisplayName, StringComparison.Ordinal))
|
||||
{
|
||||
|
@ -278,6 +282,19 @@ namespace Microsoft.Azure.AvailabilityMonitoring
|
|||
_activitySpanId, TestDisplayName, availabilityResult.Name);
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(availabilityResult.RunLocation))
|
||||
{
|
||||
availabilityResult.RunLocation = this.LocationDisplayName;
|
||||
}
|
||||
else if (!availabilityResult.RunLocation.Equals(LocationDisplayName, StringComparison.Ordinal))
|
||||
{
|
||||
_log?.LogDebug($"{nameof(AvailabilityTestScope)}.{nameof(Complete)} (SpanId=\"{{SpanId}}\") detected that the RunLocation of the"
|
||||
+ $" specified Availability Result is different from the corresponding value of this {nameof(AvailabilityTestScope)}."
|
||||
+ $" The value specified in the Availability Result takes precedence for tracking."
|
||||
+ " AvailabilityTestScope_LocationDisplayName=\"{AvailabilityTestScope_LocationDisplayName}\". AvailabilityResult_RunLocation=\"{AvailabilityResult_RunLocation}\"",
|
||||
_activitySpanId, LocationDisplayName, availabilityResult.RunLocation);
|
||||
}
|
||||
|
||||
// The user may or may not have set the ID of the availability result telemetry.
|
||||
// Either way, we must set it to the right value, otherwise distributed tracing will break:
|
||||
availabilityResult.Id = _activitySpanId;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
public const string LocationDisplayName2 = "Location";
|
||||
}
|
||||
|
||||
private class AvailabilityTestConfiguration : IAvailabilityTestConfiguration
|
||||
private class AvailabilityTestConfiguration : IAvailabilityTestInternalConfiguration
|
||||
{
|
||||
public string TestDisplayName { get; }
|
||||
public string LocationDisplayName { get; }
|
||||
|
@ -34,7 +34,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
_nameResolver = nameResolver;
|
||||
}
|
||||
|
||||
public IAvailabilityTestConfiguration Resolve(IAvailabilityTestConfiguration testConfig, string functionName)
|
||||
public IAvailabilityTestInternalConfiguration Resolve(IAvailabilityTestConfiguration testConfig, string functionName)
|
||||
{
|
||||
// Test Display Name:
|
||||
string testDisplayName = testConfig?.TestDisplayName;
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
AvailabilityTestInvocationState invocationState = _availabilityTestRegistry.Invocations.GetOrRegister(functionInstanceId, log);
|
||||
|
||||
// If test configuration makes reference to configuration, resolve the settings
|
||||
IAvailabilityTestConfiguration resolvedTestConfig = _availabilityTestScopeSettingsResolver.Resolve(testConfig, functionName);
|
||||
IAvailabilityTestInternalConfiguration resolvedTestConfig = _availabilityTestScopeSettingsResolver.Resolve(testConfig, functionName);
|
||||
|
||||
// Start the availability test scope (this will start timers and set up the activity span):
|
||||
AvailabilityTestScope testScope = AvailabilityTest.StartNew(resolvedTestConfig, _telemetryConfiguration, flushOnDispose: true, log, logScopeInfo);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<VersionDate>2020-04-09</VersionDate>
|
||||
|
||||
<!-- VersionPrerelease format examples: alpha.1, alpha.2, beta.1, beta.2; EMPTY for stable releases. -->
|
||||
<VersionPrerelease>alpha.2</VersionPrerelease>
|
||||
<VersionPrerelease>alpha.3</VersionPrerelease>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче