/// <summary> /// Sends data to New Relic, unless in "collect only" mode. /// </summary> /// <param name="endpoint">SQL endpoint from which the metrics were harvested.</param> internal void SendComponentDataToCollector(ISqlEndpoint endpoint) { var platformData = endpoint.GeneratePlatformData(_agentData); // Allows a testing mode that does not send data to New Relic if (_settings.TestMode) { return; } try { _log.DebugFormat("Reporting metrics for {0} with duration {1}s", endpoint.Name, endpoint.Duration); // Record the report time as now. If SendData takes very long, the duration comes up short and the chart shows a drop out var reportTime = DateTime.Now; // Send the data to New Relic new SqlRequest(_settings.LicenseKey) {Data = platformData}.SendData(); // If send is error free, reset the last report date to calculate accurate duration endpoint.MetricReportSuccessful(reportTime); } catch (Exception e) { _log.Error("Error sending data to connector", e); } }
/// <summary> /// Sends data to New Relic, unless in "collect only" mode. /// </summary> /// <param name="endpoint">SQL endpoint from which the metrics were harvested.</param> internal void SendComponentDataToCollector(ISqlEndpoint endpoint) { var platformData = endpoint.GeneratePlatformData(_agentData); // Allows a testing mode that does not send data to New Relic if (_settings.TestMode) { return; } try { _log.DebugFormat("Reporting metrics for {0} with duration {1}s", endpoint.Name, endpoint.Duration); // Record the report time as now. If SendData takes very long, the duration comes up short and the chart shows a drop out var reportTime = DateTime.Now; // Send the data to New Relic new SqlRequest(_settings.LicenseKey) { Data = platformData }.SendData(); // If send is error free, reset the last report date to calculate accurate duration endpoint.MetricReportSuccessful(reportTime); } catch (Exception e) { _log.Error("Error sending data to connector", e); } }
internal static string PrepareCommandText <T>(string commandText, ISqlEndpoint endpoint) where T : IDatabaseMetric, new() { var metricInstance = (IDatabaseMetric) new T(); return(metricInstance.ParameterizeQuery(commandText, endpoint)); }
/// <summary> /// Never called directly, rather called via reflection. /// </summary> internal IEnumerable <T> DatabaseMetricQuery <T>(IDbConnection dbConnection, ISqlEndpoint endpoint) where T : IDatabaseMetric, new() { var commandText = PrepareCommandText <T>(CommandText, endpoint); // Pass the simple Id=1 anonymous object to support Dapper's hashing and caching of queries return(_dapperWrapper.Query <T>(dbConnection, commandText, new { Id = 1 })); }
public Settings(ISqlEndpoint[] endpoints) { Endpoints = endpoints; PollIntervalSeconds = 60; ServiceName = ServiceConstants.ServiceName; var identity = WindowsIdentity.GetCurrent(); if (identity != null) { var principal = new WindowsPrincipal(identity); IsProcessElevated = principal.IsInRole(WindowsBuiltInRole.Administrator); } }
public string ParameterizeQuery(string commandText, ISqlEndpoint endpoint) { return ParameterizeQuery(commandText, WhereClauseToken, DbNameForWhereClause, endpoint.IncludedDatabaseNames, endpoint.ExcludedDatabaseNames); }
public string ParameterizeQuery(string commandText, ISqlEndpoint endpoint) { return("zoinks"); }
/// <summary> /// Never called directly, rather called via reflection. /// </summary> internal IEnumerable <T> Query <T>(IDbConnection dbConnection, ISqlEndpoint endpoint) where T : class, new() { // Pass the simple Id=1 anonymous object to support Dapper's hashing and caching of queries return(_dapperWrapper.Query <T>(dbConnection, CommandText, new { Id = 1 })); }
/// <summary> /// Queries data from the database and returns the results. /// </summary> /// <param name="dbConnection">Open connection to the database.</param> /// <param name="endpoint">Settings for the endpoint that is queried.</param> /// <returns> /// An enumeration of a the type where the <see cref="SqlServerQueryAttribute" /> for this query object was found during initialization. /// </returns> public IEnumerable <object> Query(IDbConnection dbConnection, ISqlEndpoint endpoint) { return(((IEnumerable)_genericMethod.Invoke(this, new object[] { dbConnection, endpoint, })).Cast <object>()); }
public Settings(ISqlEndpoint[] endpoints) { Endpoints = endpoints; PollIntervalSeconds = 60; ServiceName = ServiceConstants.ServiceName; }
public string ParameterizeQuery(string commandText, ISqlEndpoint endpoint) { return "zoinks"; }
public string ParameterizeQuery(string commandText, ISqlEndpoint endpoint) { return(ParameterizeQuery(commandText, WhereClauseToken, DbNameForWhereClause, endpoint.IncludedDatabaseNames, endpoint.ExcludedDatabaseNames)); }