public void LogOperation( OperationData operationData, string dataCenter, OperationResult operationResult, ErrorLevel errorLevel, DateTime startTime, IDictionary <string, object> propertyBag, string message, string errorSignature, int durationMs, string exception = "", string httpStatusCode = "", string tenantId = "") { Debug.WriteLine($"Operation: {operationData.OperationName}. Component: {operationData.Component}. Result: {operationResult}"); }
internal Operation( OperationData operationData, string dataCenterName, IOperationLogger operationLogger) { this.operationData = operationData; this.startTime = DateTime.UtcNow; this.propertyBag = new Dictionary <string, object>(); this.operationLogger = operationLogger; this.errorLevel = ErrorLevel.None; this.dataCenter = dataCenterName; // Until explicitly marked as Failure, the operation result is always a Success this.operationResult = OperationResult.Success; // Only failure will have exception this.exception = string.Empty; }
public static ServiceInstanceListener CreateHttpListener <TStartup>( ICodePackageActivationContext activationContext, string component) where TStartup : class { using (var operation = Logger.StartOperation(OperationData.CreateGeneric(component, "CreateServiceInstanceListeners"))) { return(operation.Run(() => { var urls = activationContext.GetEndpoints() .Where(e => e.Protocol == EndpointProtocol.Http || e.Protocol == EndpointProtocol.Https) .Select(e => GetListenerUrl(e)).ToArray(); var endpointName = activationContext.GetEndpoints() .Where(endpoint => endpoint.Protocol == EndpointProtocol.Http || endpoint.Protocol == EndpointProtocol.Https).Single().Name; return new ServiceInstanceListener(serviceContext => new HttpSysCommunicationListener( serviceContext, endpointName, (url, listener) => { return new WebHostBuilder() .UseHttpSys() .ConfigureServices( services => services.AddSingleton(serviceContext)) .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup <TStartup>() .UseUrls(urls) .ConfigureAppConfiguration(builder => { foreach (string configurationPackageName in serviceContext .CodePackageActivationContext .GetConfigurationPackageNames()) { builder.AddServiceFabricConfiguration(configurationPackageName); } }) .Build(); })); })); } }
public static void LogFailure( OperationData operationData, string message, ErrorLevel errorLevel, Exception exception = null, IDictionary <string, object> propertyBag = null) { operationLogger.LogOperation( operationData, dataCenter, OperationResult.Failure, errorLevel, DateTime.UtcNow, propertyBag, message, exception?.GetType().Name ?? string.Empty, 0, exception?.ToString() ?? string.Empty, string.Empty, string.Empty); }