Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Fixes issue seen be several users where column names were missing fro…
Browse files Browse the repository at this point in the history
…m the sys.databases schema. Uses 'SELECT *' to fail gracefully.
  • Loading branch information
edchapel committed Sep 24, 2013
1 parent c401954 commit 400a528
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
-- Retrieves relevant data about each database
-- Assists support when a user reports a problem


SELECT
d.[name] AS DatabaseName,
SELECT d.[name] AS DatabaseName,
* -- Use * as differnt databases seem to have different columns. This isn't critical data so we must fail gracefully.
/*
d.[database_id],
d.[source_database_id],
d.[create_date],
Expand Down Expand Up @@ -70,5 +70,6 @@ SELECT
d.[containment],
d.[containment_desc],
d.[target_recovery_time_in_seconds]
*/
FROM sys.databases d
/*{WHERE}*/
20 changes: 6 additions & 14 deletions src/NewRelic.Microsoft.SqlServer.Plugin/SqlEndpointBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ namespace NewRelic.Microsoft.SqlServer.Plugin
public abstract class SqlEndpointBase : ISqlEndpoint
{
/// <summary>
/// Metrics with a Duration greater than this value will be rejected by the server (400)
/// Metrics with a Duration greater than this value will be rejected by the server (400)
/// </summary>
private const int MaximumAllowedDuration = 1800;

private static readonly ILog _ErrorDetailOutputLogger = LogManager.GetLogger(Constants.ErrorDetailLogger);
private static readonly ILog _VerboseSqlOutputLogger = LogManager.GetLogger(Constants.VerboseSqlLogger);

Expand Down Expand Up @@ -171,10 +172,7 @@ protected IEnumerable<IQueryContext> ExecuteQueries(SqlQuery[] queries, string c
protected static void LogVerboseSqlResults(ISqlQuery query, IEnumerable<object> results)
{
// This could be slow, so only proceed if it actually gets logged
if (!_VerboseSqlOutputLogger.IsInfoEnabled)
{
return;
}
if (!_VerboseSqlOutputLogger.IsInfoEnabled) return;

var verboseLogging = new StringBuilder();
verboseLogging.AppendFormat("Executed {0}", query.ResourceName).AppendLine();
Expand Down Expand Up @@ -261,10 +259,7 @@ internal object[] CalculateSqlDmlActivityIncrease(object[] inputResults, ILog lo
increase = a.Value.ExecutionCount - previous.ExecutionCount;

// Only record positive deltas, though theoretically impossible here
if (increase <= 0)
{
return;
}
if (increase <= 0) return;
}
else
{
Expand Down Expand Up @@ -300,17 +295,14 @@ internal object[] CalculateSqlDmlActivityIncrease(object[] inputResults, ILog lo
{
Reads = reads,
Writes = writes,
}
},
};
}

private void LogErrorSummary(ILog log, Exception e, ISqlQuery query)
{
var sqlException = e.InnerException as SqlException;
if (sqlException == null)
{
return;
}
if (sqlException == null) return;

log.LogSqlException(sqlException, query, ConnectionString);
}
Expand Down

0 comments on commit 400a528

Please sign in to comment.