/// <summary> /// Initializes the IFx session /// </summary> /// <param name="sessionName">Name of the IFx session</param> /// <param name="monitoringAccountName">Name of the IFx monitoring account</param> /// <param name="traceDirectory">Directory to store the trace files</param> public static void Initialize(string sessionName, string monitoringAccountName, string traceDirectory = null) { if (sessionName == null) { throw new ArgumentNullException(nameof(sessionName)); } if (monitoringAccountName == null) { throw new ArgumentNullException(nameof(monitoringAccountName)); } var instrumentationSpec = new InstrumentationSpecification(); var auditSpec = new AuditSpecification(); instrumentationSpec.EmitIfxMetricsEvents = true; instrumentationSpec.MonitoringAccountName = monitoringAccountName; if (traceDirectory != null) { instrumentationSpec.WriteIfxTracerDiskLogs = true; instrumentationSpec.TraceDirectory = traceDirectory; } instrumentationSpec.MaxSizeTraceFileInKb = DefaultMaxTraceFileSizeInKB; instrumentationSpec.MaxSizeCompletedTraceFilesInMb = DefaultMaxCompletedTraceFileSizeInMB; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { IfxInitializer.IfxInitialize( sessionName, instrumentationSpec, auditSpec); } }
public IEnumerable <WeatherForecast> Get() { System.Console.WriteLine("Came to Weather Forecast Api"); // MDM based APIs do not need Ifx initialization. IfxUtil.MdmSample(); // Health based APIs do not need Ifx initialization. IfxUtil.HealthSample(); // Prior to invoking any Ifx APIs we first initialize Ifx. // For init with session name, Read this SO answer: http://stackoverflow.microsoft.com/a/6855/748 IfxInitializer.Initialize("saianu", "unifiedtestmetrics", "SAI-WORK-PC"); IfxUtil.IfxObjectSamples(); IfxUtil.TracingSample(); IfxUtil.OperationsSample(); IfxUtil.ExtendedOperationsSample(); IfxUtil.PartADerivedEventSample(); var rng = new Random(); return(Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateTime.Now.AddDays(index), TemperatureC = rng.Next(-20, 55), Summary = Summaries[rng.Next(Summaries.Length)] }) .ToArray()); }
public static LoggerConfiguration GenevaWarmPath(this LoggerSinkConfiguration loggerConfiguration, string tenant, string role, string roleInstance, string currentDirectory, string outputTemplate = DefaultOutputTemplate, IFormatProvider formatProvider = null, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, bool writeInBatches = false, TimeSpan?period = null, int?batchPostingLimit = null) { if (loggerConfiguration == null) { throw new ArgumentNullException("loggerConfiguration"); } if (tenant == null || role == null || roleInstance == null) { throw new Exception("invalid Ifx Identity property"); } if (outputTemplate == null) { throw new ArgumentNullException("outputTemplate"); } IfxInitializer.Initialize(tenant, role, roleInstance, currentDirectory); var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider); var sink = writeInBatches ? (ILogEventSink) new GenevaWarmPathBatchingSink( formatter, batchPostingLimit ?? DefaultBatchPostingLimit, period ?? DefaultPeriod) : new GenevaWarmPathSink( formatter); return(loggerConfiguration.Sink(sink, restrictedToMinimumLevel)); }
static void Main(string[] args) { EmitMetrics(); // IFx initialization is a required step for emitting logs IfxInitializer.Initialize("ifxsession"); EmitOperations(); EmitLogs(); }
static void Main(string[] args) { EmitMetrics(); // IFx initialization is a required step for emitting logs IfxInitializer.Initialize( "cloudAgentTenantIdentity", "cloudAgentRoleIdentity", "cloudAgentRoleInstanceIdentity"); EmitLogs(); }
private static void InitializeIfx() { IPAddress[] addresses = Dns.GetHostAddresses(Environment.MachineName); string ipAddress = null; foreach (var addr in addresses) { if (addr.ToString() == "127.0.0.1") { continue; } else if (addr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { ipAddress = addr.ToString(); break; } } IfxInitializer.IfxInitialize("gua", "guatest", ipAddress); }
private IfxMetricsReporter() { #if CLOUDINSTRUMENTATION try { this._mdmAccountName = GetCloudConfigurationSettingWithValue(SettingNames.MdmAccountName); this._mdmNamespace = GetCloudConfigurationSettingWithValue(SettingNames.MdmNamespace); this._geo = GetCloudConfigurationSettingWithValue(SettingNames.Geo); this._tenant = GetCloudConfigurationSettingWithValue(SettingNames.Tenant); this._role = GetCloudConfigurationSettingWithValue(SettingNames.Role); this._roleInstance = GetCloudConfigurationSettingWithValue(SettingNames.RoleInstance); this._org = GetCloudConfigurationSettingWithValue(SettingNames.Org); this._portalType = GetCloudConfigurationSettingWithValue(SettingNames.PortalType); this._portalId = GetCloudConfigurationSettingWithValue(SettingNames.PortalId); this._portalApp = GetCloudConfigurationSettingWithValue(SettingNames.PortalApp); this._portalUrl = GetCloudConfigurationSettingWithValue(SettingNames.PortalUrl); this._portalVersion = GetCloudConfigurationSettingWithValue(SettingNames.PortalVersion); if (IfxInitializer.IfxInitializeStatus == IfxInitializer.IfxInitState.IfxUninitalized) { IfxInitializer.Initialize(this._tenant, this._role, this._roleInstance, "NO_DISK_LOGS"); } this._initializationFailed = false; } catch (Exception ex) { if (ex is OutOfMemoryException || ex is ThreadAbortException) { throw; } MetricsReportingEvents.Instance.MetricInitializationFailed(ex.ToString()); this._initializationFailed = true; } #endif }
public static void Main(string[] args) { MdmSample(); HealthSample(); CreateWebHostBuilder(args) .ConfigureLogging((hostingContext, logging) => { logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); logging.AddDebug(); logging.AddEventSourceLogger(); }) .Build() .Run(); //EmitMetrics(); // IFx initialization is a required step for emitting logs IfxInitializer.Initialize( "cloudAgentTenantIdentity", "cloudAgentRoleIdentity", "cloudAgentRoleInstanceIdentity"); }
private static void InitializeLocalIfx() { IfxInitializer.IfxInitialize("saianu", "unifiedtestmetrics", "SAI-WORK-PC"); }