Skip to content

Commit

Permalink
add httpClient properties
Browse files Browse the repository at this point in the history
  • Loading branch information
moberacker committed Feb 21, 2019
1 parent 57e9cab commit 11c39d4
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 439 deletions.
249 changes: 0 additions & 249 deletions Log4ALA/AlaTcpClient.cs

This file was deleted.

35 changes: 34 additions & 1 deletion Log4ALA/ConfigSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class ConfigSettings
private const string ALA_LOG_ANALYTICS_DNS_PROP = "logAnalyticsDNS";
private const string ALA_DEBUG_HTTP_REQ_URI_PROP = "debugHTTPReqURI";
private const string ALA_DISABLE_ANONYMOUS_PROPS_PREFIX_PROP = "disableAnonymousPropsPrefix";
private const string ALA_HTTP_CLIENT_TIMEOUT_PROP = "httpClientTimeout";
private const string ALA_HTTP_CLIENT_REQUEST_TIMEOUT_PROP = "httpClientRequestTimeout";



private const string ALA_ENABLE_PASSTHROUGH_TIMESTAMP_FIELD_PROP = "enablePassThroughTimeStampField";

Expand Down Expand Up @@ -82,7 +86,10 @@ public class ConfigSettings

public const bool DEFAULT_DISABLE_ANONYMOUS_PROPS_PREFIX = false;
public const bool DEFAULT_ENABLE_PASSTHROUGH_TIMESTAMP_FIELD = false;


public const int DEFAULT_HTTP_CLIENT_TIMEOUT = 10000;
public const int DEFAULT_HTTP_CLIENT_REQUEST_TIMEOUT = 10000;


public const int BATCH_SIZE_MAX = 31457280; //30 mb quota limit per post

Expand Down Expand Up @@ -529,6 +536,32 @@ public int? ALAMaxFieldNameLength
}
}

public int? ALAHttpClientTimeout
{
get
{
#if !NETSTANDARD2_0 && !NETCOREAPP2_0
string aLAHttpClientTimeout = CloudConfigurationManager.GetSetting($"{this.propPrefix}.{ALA_HTTP_CLIENT_TIMEOUT_PROP}");
#else
string aLAHttpClientTimeout = CloudConfigurationManager[$"{this.propPrefix}:{ALA_HTTP_CLIENT_TIMEOUT_PROP}"];
#endif
return (string.IsNullOrWhiteSpace(aLAHttpClientTimeout) ? (int?)null : int.Parse(aLAHttpClientTimeout));
}
}

public int? ALAHttpClientRequestTimeout
{
get
{
#if !NETSTANDARD2_0 && !NETCOREAPP2_0
string aLAHttpClientRequestTimeout = CloudConfigurationManager.GetSetting($"{this.propPrefix}.{ALA_HTTP_CLIENT_REQUEST_TIMEOUT_PROP}");
#else
string aLAHttpClientRequestTimeout = CloudConfigurationManager[$"{this.propPrefix}:{ALA_HTTP_CLIENT_REQUEST_TIMEOUT_PROP}"];
#endif
return (string.IsNullOrWhiteSpace(aLAHttpClientRequestTimeout) ? (int?)null : int.Parse(aLAHttpClientRequestTimeout));
}
}

public string ALACoreFieldNames
{
get
Expand Down
10 changes: 7 additions & 3 deletions Log4ALA/Log4ALA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@
<PackageReference Include="Microsoft.WindowsAzure.ConfigurationManager" Version="3.1.0" />
<PackageReference Include="log4net" Version="2.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452'">
<PackageReference Include="Microsoft.Azure.ConfigurationManager" Version="4.0.0" />
<PackageReference Include="log4net" Version="2.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
</ItemGroup>


Expand All @@ -76,6 +78,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
Expand Down Expand Up @@ -105,15 +108,16 @@
</EmbeddedResource>
</ItemGroup>


<ItemGroup>
<None Remove="log4net.config" />
<None Remove="log4net.config" />
</ItemGroup>

<ItemGroup>
<Content Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>


</Project>
11 changes: 11 additions & 0 deletions Log4ALA/Log4ALAAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class Log4ALAAppender : AppenderSkeleton
public int BatchWaitMaxInSec { get; set; } = ConfigSettings.DEFAULT_BATCH_WAIT_MAX_SECONDS;
public int MaxFieldByteLength { get; set; } = ConfigSettings.DEFAULT_MAX_FIELD_BYTE_LENGTH;
public int MaxFieldNameLength { get; set; } = ConfigSettings.DEFAULT_MAX_FIELD_NAME_LENGTH;
public int HttpClientTimeout { get; set; } = ConfigSettings.DEFAULT_HTTP_CLIENT_TIMEOUT;
public int HttpClientRequestTimeout { get; set; } = ConfigSettings.DEFAULT_HTTP_CLIENT_REQUEST_TIMEOUT;

public string KeyValueSeparator { get; set; } = ConfigSettings.DEFAULT_KEY_VALUE_SEPARATOR;
public string KeyValuePairSeparator { get; set; } = ConfigSettings.DEFAULT_KEY_VALUE_PAIR_SEPARATOR;
Expand Down Expand Up @@ -284,6 +286,15 @@ public override void ActivateOptions()
}
log.Inf($"[{this.Name}] - maxFieldNameLength:[{MaxFieldNameLength}]", true);


HttpClientTimeout = configSettings.ALAHttpClientTimeout == null ? HttpClientTimeout : (int)configSettings.ALAHttpClientTimeout;
log.Inf($"[{this.Name}] - httpClientTimeout:[{HttpClientTimeout}]", true);

HttpClientRequestTimeout = configSettings.ALAHttpClientRequestTimeout == null ? HttpClientRequestTimeout : (int)configSettings.ALAHttpClientRequestTimeout;
log.Inf($"[{this.Name}] - httpClientRequestTimeout:[{HttpClientRequestTimeout}]", true);



if (BatchSizeInBytes > 0 || BatchWaitInSec > 0)
{
BatchNumItems = 0;
Expand Down
Loading

0 comments on commit 11c39d4

Please sign in to comment.