Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ClientRuntime library #1

Merged
merged 7 commits into from
Feb 23, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions ClientRuntime.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Microsoft.Rest", "Microsoft.Rest", "{868850B4-1073-41A1-ABA8-A3B465880148}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{7C044DD1-F76B-49A7-A8DF-A5DEEE748EBB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "git", "git", "{EAC2DE24-42C6-4B7F-ACAB-73C0E113FC40}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientRuntime", "Microsoft.Rest\ClientRuntime\ClientRuntime.csproj", "{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientRuntime.Etw", "Microsoft.Rest\ClientRuntime.Etw\ClientRuntime.Etw.csproj", "{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientRuntime.Log4Net", "Microsoft.Rest\ClientRuntime.Log4Net\ClientRuntime.Log4Net.csproj", "{2EFD6648-39B4-476A-B302-8BC236F5F1B8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientRuntime.Tracing.Test", "Microsoft.Rest\ClientRuntime.Tracing.Test\ClientRuntime.Tracing.Test.csproj", "{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientRuntime.Test", "Microsoft.Rest\ClientRuntime.Test\ClientRuntime.Test.csproj", "{CB18ACEB-2825-4884-91FA-05C31AC779FE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Net40-Debug|Any CPU = Net40-Debug|Any CPU
Net40-Release|Any CPU = Net40-Release|Any CPU
Net45-Debug|Any CPU = Net45-Debug|Any CPU
Net45-Release|Any CPU = Net45-Release|Any CPU
Portable-Debug|Any CPU = Portable-Debug|Any CPU
Portable-Release|Any CPU = Portable-Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Net40-Debug|Any CPU.ActiveCfg = Net40-Debug|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Net40-Debug|Any CPU.Build.0 = Net40-Debug|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Net40-Release|Any CPU.ActiveCfg = Net40-Release|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Net40-Release|Any CPU.Build.0 = Net40-Release|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Net45-Debug|Any CPU.ActiveCfg = Net45-Debug|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Net45-Debug|Any CPU.Build.0 = Net45-Debug|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Net45-Release|Any CPU.ActiveCfg = Net45-Release|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Net45-Release|Any CPU.Build.0 = Net45-Release|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Portable-Debug|Any CPU.ActiveCfg = Portable-Debug|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Portable-Debug|Any CPU.Build.0 = Portable-Debug|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Portable-Release|Any CPU.ActiveCfg = Portable-Release|Any CPU
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4}.Portable-Release|Any CPU.Build.0 = Portable-Release|Any CPU
{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}.Net40-Debug|Any CPU.ActiveCfg = Net40-Debug|Any CPU
{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}.Net40-Release|Any CPU.ActiveCfg = Net40-Release|Any CPU
{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}.Net45-Debug|Any CPU.ActiveCfg = Net45-Debug|Any CPU
{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}.Net45-Debug|Any CPU.Build.0 = Net45-Debug|Any CPU
{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}.Net45-Release|Any CPU.ActiveCfg = Net45-Release|Any CPU
{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}.Net45-Release|Any CPU.Build.0 = Net45-Release|Any CPU
{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}.Portable-Debug|Any CPU.ActiveCfg = Portable-Debug|Any CPU
{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}.Portable-Release|Any CPU.ActiveCfg = Portable-Release|Any CPU
{2EFD6648-39B4-476A-B302-8BC236F5F1B8}.Net40-Debug|Any CPU.ActiveCfg = Net40-Debug|Any CPU
{2EFD6648-39B4-476A-B302-8BC236F5F1B8}.Net40-Release|Any CPU.ActiveCfg = Net40-Release|Any CPU
{2EFD6648-39B4-476A-B302-8BC236F5F1B8}.Net45-Debug|Any CPU.ActiveCfg = Net45-Debug|Any CPU
{2EFD6648-39B4-476A-B302-8BC236F5F1B8}.Net45-Debug|Any CPU.Build.0 = Net45-Debug|Any CPU
{2EFD6648-39B4-476A-B302-8BC236F5F1B8}.Net45-Release|Any CPU.ActiveCfg = Net45-Release|Any CPU
{2EFD6648-39B4-476A-B302-8BC236F5F1B8}.Net45-Release|Any CPU.Build.0 = Net45-Release|Any CPU
{2EFD6648-39B4-476A-B302-8BC236F5F1B8}.Portable-Debug|Any CPU.ActiveCfg = Portable-Debug|Any CPU
{2EFD6648-39B4-476A-B302-8BC236F5F1B8}.Portable-Release|Any CPU.ActiveCfg = Portable-Release|Any CPU
{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}.Net40-Debug|Any CPU.ActiveCfg = Net40-Debug|Any CPU
{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}.Net40-Release|Any CPU.ActiveCfg = Net40-Release|Any CPU
{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}.Net45-Debug|Any CPU.ActiveCfg = Net45-Debug|Any CPU
{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}.Net45-Debug|Any CPU.Build.0 = Net45-Debug|Any CPU
{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}.Net45-Release|Any CPU.ActiveCfg = Net45-Release|Any CPU
{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}.Net45-Release|Any CPU.Build.0 = Net45-Release|Any CPU
{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}.Portable-Debug|Any CPU.ActiveCfg = Portable-Debug|Any CPU
{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7}.Portable-Release|Any CPU.ActiveCfg = Portable-Release|Any CPU
{CB18ACEB-2825-4884-91FA-05C31AC779FE}.Net40-Debug|Any CPU.ActiveCfg = Net40-Debug|Any CPU
{CB18ACEB-2825-4884-91FA-05C31AC779FE}.Net40-Release|Any CPU.ActiveCfg = Net40-Release|Any CPU
{CB18ACEB-2825-4884-91FA-05C31AC779FE}.Net45-Debug|Any CPU.ActiveCfg = Net45-Debug|Any CPU
{CB18ACEB-2825-4884-91FA-05C31AC779FE}.Net45-Debug|Any CPU.Build.0 = Net45-Debug|Any CPU
{CB18ACEB-2825-4884-91FA-05C31AC779FE}.Net45-Release|Any CPU.ActiveCfg = Net45-Release|Any CPU
{CB18ACEB-2825-4884-91FA-05C31AC779FE}.Net45-Release|Any CPU.Build.0 = Net45-Release|Any CPU
{CB18ACEB-2825-4884-91FA-05C31AC779FE}.Portable-Debug|Any CPU.ActiveCfg = Portable-Debug|Any CPU
{CB18ACEB-2825-4884-91FA-05C31AC779FE}.Portable-Release|Any CPU.ActiveCfg = Portable-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7F524559-93F9-4F3F-9E2C-AF41A0C2E6F4} = {868850B4-1073-41A1-ABA8-A3B465880148}
{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E} = {868850B4-1073-41A1-ABA8-A3B465880148}
{2EFD6648-39B4-476A-B302-8BC236F5F1B8} = {868850B4-1073-41A1-ABA8-A3B465880148}
{B2FAA0E6-2643-4011-8CFE-BA28BDFFC7E7} = {7C044DD1-F76B-49A7-A8DF-A5DEEE748EBB}
{CB18ACEB-2825-4884-91FA-05C31AC779FE} = {7C044DD1-F76B-49A7-A8DF-A5DEEE748EBB}
EndGlobalSection
EndGlobal
63 changes: 63 additions & 0 deletions Microsoft.Rest/ClientRuntime.Etw/ClientRuntime.Etw.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<LibraryFxTarget Condition="'$(LibraryFxTarget)' == ''">net45</LibraryFxTarget>
<ProjectGuid>{50B0A8CE-D290-4EB7-8C6C-16EAAB75225E}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Rest.Common.Tracing.Etw</RootNamespace>
<AssemblyName>Microsoft.Rest.ClientRuntime.Etw</AssemblyName>
<OutputType>Library</OutputType>
<RestorePackages>true</RestorePackages>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NuGetPackageImportStamp>644881db</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Net45-Debug'">
<DocumentationFile>bin\Net45-Debug\Microsoft.Rest.ClientRuntime.Etw.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Net45-Release'">
<DocumentationFile>bin\Net45-Release\Microsoft.Rest.ClientRuntime.Etw.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Net40-Debug'">
<DocumentationFile>bin\Net40-Debug\Microsoft.Rest.ClientRuntime.Etw.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Net40-Release'">
<DocumentationFile>bin\Net40-Release\Microsoft.Rest.ClientRuntime.Etw.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Portable-Debug'">
<DocumentationFile>bin\Portable-Debug\Microsoft.Rest.ClientRuntime.Etw.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Portable-Release'">
<DocumentationFile>bin\Portable-Release\Microsoft.Rest.ClientRuntime.Etw.xml</DocumentationFile>
</PropertyGroup>
<Import Project="$(SolutionDir)\tools\AutoRest.Settings.targets" />
<ItemGroup>
<Compile Include="HttpOperationEventSource.cs" />
<Compile Include="EtwTracingInterceptor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GlobalSuppressions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Microsoft.Rest.ClientRuntime.Etw.nuget.proj" />
<None Include="Microsoft.Rest.ClientRuntime.Etw.nuspec">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClientRuntime\ClientRuntime.csproj">
<Project>{7f524559-93f9-4f3f-9e2c-af41a0c2e6f4}</Project>
<Name>ClientRuntime</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="..\..\tools\CustomDictionary.xml">
<Link>CustomDictionary.xml</Link>
</CodeAnalysisDictionary>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
112 changes: 112 additions & 0 deletions Microsoft.Rest/ClientRuntime.Etw/EtwTracingInterceptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Net.Http;

namespace Microsoft.Rest.Tracing.Etw
{
/// <summary>
/// Implementation for ICloudTracingInterceptor that raises ETW events.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We say it implements ICloudTracingInterceptor but the actual name is IServiceClientTracingInterceptor. This needs to be changed to IServiceClientTracingInterceptor in a lot of places.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/// </summary>
/// <remarks>
/// To use ETW with the Microsoft AutoRest generated client:
/// 1. Register the logger.
/// 2. Use tools such as PerfView to capture events under the
/// Microsoft.Rest provider.
/// </remarks>
/// <example>
/// This shows how to hook up the tracing interceptor.
/// <code>
/// TracingAdapter.AddTracingInterceptor(
/// new EtwTracingInterceptor());
/// </code>
/// </example>
public class EtwTracingInterceptor : IServiceClientTracingInterceptor
{
/// <summary>
/// Trace information.
/// </summary>
/// <param name="message">The information to trace.</param>
public void Information(string message)
{
HttpOperationEventSource.Log.Information(message);
}

/// <summary>
/// Probe configuration for the value of a setting.
/// </summary>
/// <param name="source">The configuration source.</param>
/// <param name="name">The name of the setting.</param>
/// <param name="value">The value of the setting in the source.</param>
public void Configuration(string source, string name, string value)
{
HttpOperationEventSource.Log.Configuration(source, name, value);
}

/// <summary>
/// Enter a method.
/// </summary>
/// <param name="invocationId">Method invocation identifier.</param>
/// <param name="instance">The instance with the method.</param>
/// <param name="method">Name of the method.</param>
/// <param name="parameters">Method parameters.</param>
public void Enter(string invocationId, object instance, string method, IDictionary<string, object> parameters)
{
string instanceAsString = instance == null ? string.Empty : instance.ToString();
string parametersAsString = parameters == null ? string.Empty : parameters.AsFormattedString();

HttpOperationEventSource.Log.Enter(invocationId, instanceAsString, method, parametersAsString);
}

/// <summary>
/// Send an HTTP request.
/// </summary>
/// <param name="invocationId">Method invocation identifier.</param>
/// <param name="request">The request about to be sent.</param>
public virtual void SendRequest(string invocationId, HttpRequestMessage request)
{
string requestAsString = request == null ? string.Empty : request.AsFormattedString();

HttpOperationEventSource.Log.SendRequest(invocationId, requestAsString);
}

/// <summary>
/// Receive an HTTP response.
/// </summary>
/// <param name="invocationId">Method invocation identifier.</param>
/// <param name="response">The response instance.</param>
public virtual void ReceiveResponse(string invocationId, HttpResponseMessage response)
{
string responseAsString = response == null ? string.Empty : response.AsFormattedString();

HttpOperationEventSource.Log.ReceiveResponse(invocationId, responseAsString);
}

/// <summary>
/// Raise an error.
/// </summary>
/// <param name="invocationId">Method invocation identifier.</param>
/// <param name="exception">The error.</param>
public void Error(string invocationId, Exception exception)
{
string exceptionAsString = exception == null ? string.Empty : exception.ToString();

HttpOperationEventSource.Log.Error(invocationId, exceptionAsString);
}

/// <summary>
/// Exit a method. Note: Exit will not be called in the event of an
/// error.
/// </summary>
/// <param name="invocationId">Method invocation identifier.</param>
/// <param name="returnValue">Method return value.</param>
public void Exit(string invocationId, object returnValue)
{
string returnValueAsString = returnValue == null ? string.Empty : returnValue.ToString();

HttpOperationEventSource.Log.Exit(invocationId, returnValueAsString);
}
}
}
8 changes: 8 additions & 0 deletions Microsoft.Rest/ClientRuntime.Etw/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these necessary if the words are now in CustomDictionary.xml ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

// Licensed under the MIT License. See License.txt in the project root for license information.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Etw", Justification = "ETW is a well known acronym in this context.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Etw", Scope = "namespace", Target = "Microsoft.Rest.Tracing.Etw", Justification = "ETW is a well known acronym in this context.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Etw", Scope = "type", Target = "Microsoft.Rest.Tracing.Etw.EtwTracingInterceptor", Justification = "ETW is a well known acronym in this context.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "AutoRest")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "AutoRest", Scope = "namespace", Target = "Microsoft.Rest.Tracing.Etw")]
Loading