/// <summary> /// Create service bus event bus /// </summary> /// <param name="factory"></param> /// <param name="process"></param> /// <param name="logger"></param> public ServiceBusEventBus(IServiceBusClientFactory factory, ILogger logger, IProcessIdentity process = null) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _factory = factory ?? throw new ArgumentNullException(nameof(factory)); // TODO: If scaled out we need subscription ids for every instance! // Create subscription client _subscriptionClient = _factory.CreateOrGetSubscriptionClientAsync( ProcessEvent, ExceptionReceivedHandler, process?.ServiceId).Result; Try.Async(() => _subscriptionClient.RemoveRuleAsync( RuleDescription.DefaultRuleName)).Wait(); }
/// <summary> /// Constructor for generic host service which manages IHostProcess objects. /// </summary> /// <param name="hostEnvironment"></param> /// <param name="hostApplicationLifetime"></param> /// <param name="config"></param> /// <param name="serviceInfo"></param> /// <param name="hostProcesses"></param> /// <param name="logger"></param> public HostStarterService( IHostEnvironment hostEnvironment, IHostApplicationLifetime hostApplicationLifetime, Config config, IProcessIdentity serviceInfo, IEnumerable <IHostProcess> hostProcesses, ILogger logger ) { HostEnvironment = hostEnvironment ?? throw new ArgumentNullException(nameof(hostEnvironment)); HostApplicationLifetime = hostApplicationLifetime ?? throw new ArgumentNullException(nameof(hostApplicationLifetime)); Config = config ?? throw new ArgumentNullException(nameof(config)); ServiceInfo = serviceInfo ?? throw new ArgumentNullException(nameof(serviceInfo)); _hostProcesses = hostProcesses?.ToList() ?? throw new ArgumentNullException(nameof(hostProcesses)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Create controller /// </summary> /// <param name="process"></param> public StatusController(IProcessIdentity process) { _process = process; }
/// <summary> /// Constructor /// </summary> /// <param name="processIdentity"></param> public ApplicationInsightsTelemetryInitializer(IProcessIdentity processIdentity) { _processIdentity = processIdentity; }
/// <summary> /// Create container factory - the container name is the specified /// service id, which allows binding containers to service. /// </summary> /// <param name="server"></param> /// <param name="process"></param> public ItemContainerFactory(IDatabaseServer server, IProcessIdentity process) : this(server, null, process?.ServiceId) { }
/// <summary> /// Create container factory /// </summary> /// <param name="server"></param> /// <param name="config"></param> /// <param name="process"></param> public ItemContainerFactory(IDatabaseServer server, IItemContainerConfig config = null, IProcessIdentity process = null) : this(server, config?.DatabaseName, config?.ContainerName ?? process?.ServiceId) { }
/// <summary> /// Add dependency tracking for Application Insights. This method should be used for .NET /// Core applications. ASP.NET Core applicatoins should rely on AddApplicationInsightsTelemetry() /// extension method for IServiceCollection. /// </summary> /// <param name="builder"></param> /// <param name="diagnosticsConfig"></param> /// <param name="processIdentity"></param> /// <returns></returns> public static ContainerBuilder AddDependencyTracking(this ContainerBuilder builder, IDiagnosticsConfig diagnosticsConfig, IProcessIdentity processIdentity) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (diagnosticsConfig == null) { throw new ArgumentNullException(nameof(diagnosticsConfig)); } if (processIdentity == null) { throw new ArgumentNullException(nameof(processIdentity)); } var telemetryInitializer = new ApplicationInsightsTelemetryInitializer(processIdentity); var telemetryConfig = TelemetryConfiguration.CreateDefault(); telemetryConfig.InstrumentationKey = diagnosticsConfig.InstrumentationKey; telemetryConfig.TelemetryInitializers.Add(telemetryInitializer); var depModule = new DependencyTrackingTelemetryModule(); // Prevent Correlation Id to be sent to certain endpoints. depModule.ExcludeComponentCorrelationHttpHeadersOnDomains.Add("core.windows.net"); depModule.ExcludeComponentCorrelationHttpHeadersOnDomains.Add("core.chinacloudapi.cn"); depModule.ExcludeComponentCorrelationHttpHeadersOnDomains.Add("core.cloudapi.de"); depModule.ExcludeComponentCorrelationHttpHeadersOnDomains.Add("core.usgovcloudapi.net"); depModule.ExcludeComponentCorrelationHttpHeadersOnDomains.Add("localhost"); depModule.ExcludeComponentCorrelationHttpHeadersOnDomains.Add("127.0.0.1"); // Enable known dependency tracking, note that in future versions, we will extend this list. // Please check default settings in https://github.com/microsoft/ApplicationInsights-dotnet-server/blob/develop/WEB/Src/DependencyCollector/DependencyCollector/ApplicationInsights.config.install.xdt depModule.IncludeDiagnosticSourceActivities.Add("Microsoft.Azure.ServiceBus"); depModule.IncludeDiagnosticSourceActivities.Add("Microsoft.Azure.EventHubs"); // Initialize the module. depModule.Initialize(telemetryConfig); builder.RegisterInstance(depModule) .AsImplementedInterfaces() .SingleInstance(); return(builder); }