Added ad-hoc console logging to debug interop with JavaScript,
This commit is contained in:
Родитель
e0e484d8ba
Коммит
812c3f50c9
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.Azure.WebJobs.Host;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
@ -10,15 +11,16 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring.Extensions
|
|||
{
|
||||
Validate.NotNull(builder, nameof(builder));
|
||||
|
||||
builder.AddExtension<AvailabilityMonitoringExtensionConfigProvider>();
|
||||
IServiceCollection serviceCollection = builder.Services;
|
||||
|
||||
serviceCollection.AddSingleton<INameResolver, AvailabilityMonitoringNameResolver>();
|
||||
//serviceCollection.AddSingleton<ITelemetryInitializer, AvailabilityMonitoringTelemetryInitializer>();
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete (Filter-related types are obsolete, but we want to use them)
|
||||
serviceCollection.AddSingleton<IFunctionFilter, FunctionInvocationManagementFilter>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete (Filter-related types are obsolete, but we want to use them)
|
||||
|
||||
builder.AddExtension<AvailabilityMonitoringExtensionConfigProvider>();
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,13 +79,21 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
// ["Microsoft.Azure.AvailabilityMonitoring.FunctionInstanceId"] = Format.Guid(context.FunctionInstanceId),
|
||||
//});
|
||||
|
||||
Console.WriteLine($"CreateAndRegisterInvocation. FunctionInstanceId: \"{context.FunctionInstanceId}\".");
|
||||
|
||||
//try
|
||||
//{
|
||||
//_log?.LogInformation($"Creating an Availability Test parameter of type \"{functionParameterType.Name}\" from an"
|
||||
// + $" {nameof(AvailabilityTestAttribute)}("
|
||||
// + $"{nameof(AvailabilityTestAttribute.TestDisplayName)}=\"{Format.NotNullOrWord(attribute.TestDisplayName)}\","
|
||||
// + $"{nameof(AvailabilityTestAttribute.LocationDisplayName)}=\"{Format.NotNullOrWord(attribute.LocationDisplayName)}\","
|
||||
// + $"{nameof(AvailabilityTestAttribute.LocationId)}=\"{Format.NotNullOrWord(attribute.LocationId)}\").");
|
||||
//_log?.LogInformation($"Creating an Availability Test parameter of type \"{functionParameterType.Name}\" from an"
|
||||
// + $" {nameof(AvailabilityTestAttribute)}("
|
||||
// + $"{nameof(AvailabilityTestAttribute.TestDisplayName)}=\"{Format.NotNullOrWord(attribute.TestDisplayName)}\","
|
||||
// + $"{nameof(AvailabilityTestAttribute.LocationDisplayName)}=\"{Format.NotNullOrWord(attribute.LocationDisplayName)}\","
|
||||
// + $"{nameof(AvailabilityTestAttribute.LocationId)}=\"{Format.NotNullOrWord(attribute.LocationId)}\").");
|
||||
|
||||
Console.WriteLine($"Creating an Availability Test parameter of type \"{functionParameterType.Name}\" from an"
|
||||
+ $" {nameof(AvailabilityTestAttribute)}("
|
||||
+ $"{nameof(AvailabilityTestAttribute.TestDisplayName)}=\"{Format.NotNullOrWord(attribute.TestDisplayName)}\","
|
||||
+ $"{nameof(AvailabilityTestAttribute.LocationDisplayName)}=\"{Format.NotNullOrWord(attribute.LocationDisplayName)}\","
|
||||
+ $"{nameof(AvailabilityTestAttribute.LocationId)}=\"{Format.NotNullOrWord(attribute.LocationId)}\").");
|
||||
|
||||
AvailabilityTestInfo availabilityTestInfo = CreateAvailabilityTestInfo(attribute, context);
|
||||
|
||||
|
@ -96,7 +104,12 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
// + $" {nameof(AvailabilityTestInfo.LocationDisplayName)}=\"{Format.NotNullOrWord(availabilityTestInfo.LocationDisplayName)}\","
|
||||
// + $" {nameof(AvailabilityTestInfo.LocationId)}=\"{Format.NotNullOrWord(availabilityTestInfo.LocationId)}\".");
|
||||
|
||||
return availabilityTestInfo;
|
||||
Console.WriteLine($"Resolved settings and created a {nameof(AvailabilityTestInfo)}:"
|
||||
+ $" {nameof(AvailabilityTestInfo.TestDisplayName)}=\"{Format.NotNullOrWord(availabilityTestInfo.TestDisplayName)}\","
|
||||
+ $" {nameof(AvailabilityTestInfo.LocationDisplayName)}=\"{Format.NotNullOrWord(availabilityTestInfo.LocationDisplayName)}\","
|
||||
+ $" {nameof(AvailabilityTestInfo.LocationId)}=\"{Format.NotNullOrWord(availabilityTestInfo.LocationId)}\".");
|
||||
|
||||
return availabilityTestInfo;
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using Microsoft.ApplicationInsights.Channel;
|
||||
using Microsoft.ApplicationInsights.DataContracts;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
|
||||
namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
||||
{
|
||||
internal class AvailabilityMonitoringTelemetryInitializer : ITelemetryInitializer
|
||||
{
|
||||
public void Initialize(ITelemetry telemetryItem)
|
||||
{
|
||||
Console.WriteLine();
|
||||
|
||||
const string prefix = "*********** Availability Monitoring Telemetry Processor";
|
||||
Console.WriteLine($"{prefix}: Item type: {Format.NotNullOrWord(telemetryItem?.GetType()?.Name)}");
|
||||
|
||||
if (telemetryItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine($"{prefix}: Operation.Id: {Format.NotNullOrWord(telemetryItem.Context.Operation.Id)}");
|
||||
Console.WriteLine($"{prefix}: Operation.Name: {Format.NotNullOrWord(telemetryItem.Context.Operation.Name)}");
|
||||
Console.WriteLine($"{prefix}: Operation.ParentId: {Format.NotNullOrWord(telemetryItem.Context.Operation.ParentId)}");
|
||||
Console.WriteLine($"{prefix}: Operation.SyntheticSource:{Format.NotNullOrWord(telemetryItem.Context.Operation.SyntheticSource)}");
|
||||
|
||||
if (telemetryItem is TraceTelemetry traceTelemetry)
|
||||
{
|
||||
Console.WriteLine($"{prefix}: Message: {Format.NotNullOrWord(traceTelemetry.Message)}");
|
||||
}
|
||||
|
||||
if (telemetryItem is RequestTelemetry requestTelemetry)
|
||||
{
|
||||
Console.WriteLine($"{prefix}: Name: {Format.NotNullOrWord(requestTelemetry.Name)}");
|
||||
Console.WriteLine($"{prefix}: Id: {Format.NotNullOrWord(requestTelemetry.Id)}");
|
||||
}
|
||||
|
||||
if (telemetryItem is DependencyTelemetry dependencyTelemetry)
|
||||
{
|
||||
Console.WriteLine($"{prefix}: Name: {Format.NotNullOrWord(dependencyTelemetry.Name)}");
|
||||
Console.WriteLine($"{prefix}: Id: {Format.NotNullOrWord(dependencyTelemetry.Id)}");
|
||||
}
|
||||
|
||||
if (telemetryItem is AvailabilityTelemetry availabilityTelemetry)
|
||||
{
|
||||
Console.WriteLine($"{prefix}: Name: {Format.NotNullOrWord(availabilityTelemetry.Name)}");
|
||||
Console.WriteLine($"{prefix}: Id: {Format.NotNullOrWord(availabilityTelemetry.Id)}");
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,12 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
public Task OnExecutingAsync(FunctionExecutingContext executingContext, CancellationToken cancelControl)
|
||||
#pragma warning restore CS0618 // Type or member is obsolete (Filter-related types are obsolete, but we want to use them)
|
||||
{
|
||||
Console.WriteLine("Filter Entry Point: OnExecutingAsync");
|
||||
|
||||
Process proc = Process.GetCurrentProcess();
|
||||
Console.WriteLine($"Process name: \"{proc.ProcessName}\", Process Id: \"{proc.Id}\".");
|
||||
Console.WriteLine($"FunctionInstanceId: \"{executingContext.FunctionInstanceId}\".");
|
||||
|
||||
Validate.NotNull(executingContext, nameof(executingContext));
|
||||
|
||||
// Check that the functionInstanceId is registered.
|
||||
|
@ -37,6 +43,9 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
bool isAvailabilityTest = FunctionInvocationStateCache.SingeltonInstance.TryStartFunctionInvocation(
|
||||
executingContext.FunctionInstanceId,
|
||||
out FunctionInvocationState invocationState);
|
||||
|
||||
Console.WriteLine($"isAvailabilityTest: \"{isAvailabilityTest}\".");
|
||||
|
||||
if (! isAvailabilityTest)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
|
@ -45,6 +54,9 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
ILogger log = executingContext.Logger;
|
||||
string activitySpanId;
|
||||
|
||||
Console.WriteLine($"invocationState.CurrentStage: \"{invocationState.CurrentStage}\".");
|
||||
Console.WriteLine($"Log Type: \"{Format.NotNullOrWord(log?.GetType()?.Name)}\".");
|
||||
|
||||
IDisposable logScope = log?.BeginScope(new Dictionary<string, string>()
|
||||
{
|
||||
["Microsoft.Azure.AvailabilityMonitoring.FunctionInstanceId"] = Format.Guid(executingContext.FunctionInstanceId),
|
||||
|
@ -52,6 +64,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
try
|
||||
{
|
||||
log?.LogInformation("Coded Availability Test setup started.");
|
||||
Console.WriteLine("Coded Availability Test setup started.");
|
||||
|
||||
IdentifyManagedParameters(invocationState, executingContext.Arguments, log);
|
||||
|
||||
|
@ -127,6 +140,8 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
public Task OnExecutedAsync(FunctionExecutedContext executedContext, CancellationToken cancelControl)
|
||||
#pragma warning restore CS0618 // Type or member is obsolete (Filter-related types are obsolete, but we want to use them)
|
||||
{
|
||||
Console.WriteLine("Filter Entry Point: OnExecutedAsync");
|
||||
|
||||
Validate.NotNull(executedContext, nameof(executedContext));
|
||||
|
||||
// Check that the functionInstanceId is registered.
|
||||
|
@ -157,6 +172,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring
|
|||
try
|
||||
{
|
||||
log?.LogInformation("Coded Availability Test completed. Processing results.");
|
||||
Console.WriteLine("Coded Availability Test completed. Processing results.");
|
||||
|
||||
// Stop activity:
|
||||
string activitySpadId = invocationState.ActivitySpan.SpanId.ToHexString();
|
||||
|
|
Загрузка…
Ссылка в новой задаче