Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            EmitMetrics();

            // IFx initialization is a required step for emitting logs
            IfxInitializer.Initialize(
                "cloudAgentTenantIdentity",
                "cloudAgentRoleIdentity",
                "cloudAgentRoleInstanceIdentity");

            EmitLogs();
        }
        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
        }
Esempio n. 6
0
        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");
        }