Permalink
Browse files

Added inspection for TableOperation.EchoContent to Glimpse.WindowsAzu…

…re.Storage
  • Loading branch information...
1 parent 39f18e3 commit 792f9af20525c8c56ae2f0def0c923574610910d @maartenba maartenba committed Dec 4, 2013
@@ -21,6 +21,7 @@
<s:Boolean x:Key="/Default/CodeStyle/IntroduceVariableUseVar/UseVarForIntroduceVariableRefactoring/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
+ <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
@@ -71,6 +71,7 @@
<Compile Include="Infrastructure\Inspections\GeneralBestPracticesInspector.cs" />
<Compile Include="Infrastructure\Inspections\IWindowsAzureStorageInspector.cs" />
<Compile Include="Infrastructure\Inspections\TableStorageQueryIndexInspector.cs" />
+ <Compile Include="Infrastructure\Inspections\TableStorageEchoContentInspector.cs" />
<Compile Include="Infrastructure\Inspections\WindowsAzureStorageInspectorBase.cs" />
<Compile Include="Infrastructure\IOperationContextFactory.cs" />
<Compile Include="Infrastructure\LongExtensions.cs" />
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Web;
+using Microsoft.Data.Edm;
+using Microsoft.Data.Edm.Library;
+using Microsoft.Data.OData;
+using Microsoft.Data.OData.Query;
+using Microsoft.WindowsAzure.Storage;
+
+namespace Glimpse.WindowsAzure.Storage.Infrastructure.Inspections
+{
+ public class TableStorageEchoContentInspector
+ : WindowsAzureStorageInspectorBase
+ {
+ public override IEnumerable<string> Inspect(WindowsAzureStorageTimelineMessage message)
+ {
+ if (message.ServiceName == "Table" &&
+ (message.ServiceOperation == "PUT" || message.ServiceOperation == "POST" || message.ServiceOperation == "MERGE" || message.ServiceOperation == "PATCH"))
+ {
+ var preferHeader = message.RequestHeaders["Prefer"];
+ var dataServiceVersionHeader = message.RequestHeaders["DataServiceVersion"];
+ if (preferHeader != null && dataServiceVersionHeader != null && dataServiceVersionHeader.Contains("3.0") && preferHeader.ToLowerInvariant() != "return-no-content")
+ {
+ // We're on Storage SDK 3.0 and it's an insert/update/merge
+ return new string[] { "Disable the echocontent feature on the TableOperation instance or set the HTTP header Prefer:return-no-content. This will ensure the message payload isn't unnecessarily being returned in the operation response." };
+ }
+ }
+ return new string[] { };
+ }
+ }
+}
@@ -5,7 +5,6 @@
using Microsoft.Data.Edm.Library;
using Microsoft.Data.OData;
using Microsoft.Data.OData.Query;
-using Microsoft.WindowsAzure.Storage;
namespace Glimpse.WindowsAzure.Storage.Infrastructure.Inspections
{
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+using System.Net;
using System.Reflection;
using System.Web;
using Glimpse.Core.Message;
@@ -43,10 +45,12 @@ public WindowsAzureStorageTimelineMessage(string serviceName, string serviceOper
ResponseSize += header.Length + 2 + string.Join(";", requestEventArgs.Response.Headers.GetValues(header)).Length;
}
+ RequestHeaders = requestEventArgs.Request.Headers;
+ ResponseHeaders = requestEventArgs.Request.Headers;
+
EventSubText = string.Format("out: {0}/in: {1}", RequestSize.ToBytesHuman(), ResponseSize.ToBytesHuman());
}
-
public Guid Id { get; private set; }
public string Url { get; set; }
public int ResponseCode { get; set; }
@@ -58,8 +62,9 @@ public WindowsAzureStorageTimelineMessage(string serviceName, string serviceOper
public string EventSubText { get; set; }
public string ServiceOperation { get; set; }
public string ServiceName { get; set; }
-
public long RequestSize { get; set; }
public long ResponseSize { get; set; }
+ public WebHeaderCollection ResponseHeaders { get; set; }
+ public WebHeaderCollection RequestHeaders { get; set; }
}
}
@@ -85,7 +85,8 @@ private List<StorageWarningModel> AnalyzeMessagesForWarnings(IEnumerable<Windows
var inspectors = new IWindowsAzureStorageInspector[]
{
new GeneralBestPracticesInspector(),
- new TableStorageQueryIndexInspector()
+ new TableStorageQueryIndexInspector(),
+ new TableStorageEchoContentInspector()
};
foreach (var inspector in inspectors)
{

0 comments on commit 792f9af

Please sign in to comment.