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

Metric Aggregation metadata is stored into a field instead of properties dictionary #929

Merged
merged 5 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
This changelog will be used to generate documentation on [release notes page](http://azure.microsoft.com/documentation/articles/app-insights-release-notes-dotnet/).

## Version 2.8.0
- [Perf Improvement - Use TimeSpan instead of String for durations to avoid conversions.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/927)
- Perf Improvements
https://github.com/Microsoft/ApplicationInsights-dotnet/issues/927
https://github.com/Microsoft/ApplicationInsights-dotnet/issues/930

## Version 2.8.0-beta2
- [TelemetryProcessors (sampling, autocollectedmetricaggregator), TelemetryChannel (ServerTelemetryChannel) added automatically to the default ApplicationInsights.config are moved under the default telemetry sink.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/907)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.ApplicationInsights.DataContracts
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.Extensibility.Implementation;
using Microsoft.ApplicationInsights.Extensibility.Implementation.External;

using Microsoft.ApplicationInsights.Extensibility.Implementation.Metrics;
using static System.Threading.LazyInitializer;

/// <summary>
Expand Down Expand Up @@ -254,8 +254,16 @@ public override bool? Success
/// <a href="https://go.microsoft.com/fwlink/?linkid=525722#properties">Learn more</a>
/// </summary>
public override IDictionary<string, string> Properties
{
get { return this.InternalData.properties; }
{
get
{
if (!string.IsNullOrEmpty(this.MetricExtractorInfo) && !this.InternalData.properties.ContainsKey(MetricTerms.Extraction.ProcessedByExtractors.Moniker.Key))
{
this.InternalData.properties[MetricTerms.Extraction.ProcessedByExtractors.Moniker.Key] = this.MetricExtractorInfo;
}

return this.InternalData.properties;
}
}

/// <summary>
Expand Down Expand Up @@ -295,6 +303,15 @@ public string DependencyKind
set { this.samplingPercentage = value; }
}

/// <summary>
/// Gets or sets the MetricExtractorInfo.
/// </summary>
internal string MetricExtractorInfo
{
get;
set;
}

/// <summary>
/// Gets the dependency operation details, if any.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.Extensibility.Implementation;
using Microsoft.ApplicationInsights.Extensibility.Implementation.External;
using Microsoft.ApplicationInsights.Extensibility.Implementation.Metrics;

/// <summary>
/// Encapsulates information about a web request handled by the application.
Expand Down Expand Up @@ -165,7 +166,15 @@ public override TimeSpan Duration
/// </summary>
public override IDictionary<string, string> Properties
{
get { return this.Data.properties; }
get
{
if (!string.IsNullOrEmpty(this.MetricExtractorInfo) && !this.Data.properties.ContainsKey(MetricTerms.Extraction.ProcessedByExtractors.Moniker.Key))
{
this.Data.properties[MetricTerms.Extraction.ProcessedByExtractors.Moniker.Key] = this.MetricExtractorInfo;
}

return this.Data.properties;
}
}

/// <summary>
Expand Down Expand Up @@ -226,6 +235,15 @@ public string Source
set { this.Data.source = value; }
}

/// <summary>
/// Gets or sets the MetricExtractorInfo.
/// </summary>
internal string MetricExtractorInfo
{
get;
set;
}

/// <summary>
/// Deeply clones a <see cref="RequestTelemetry"/> object.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,30 +190,31 @@ private static string GetExtractorInfo(ISpecificAutocollectedMetricsExtractor ex
/// <param name="item">The telemetry item to be tagged.</param>
/// <param name="extractorInfo">The string to be added to the item's properties.</param>
private static void AddExtractorInfo(ITelemetry item, string extractorInfo)
{
var itemWithProperties = item as ISupportProperties;
if (itemWithProperties == null)
{
if (item is RequestTelemetry)
{
return;
var req = item as RequestTelemetry;
req.MetricExtractorInfo = ExtractionPipelineInfo(req.MetricExtractorInfo, extractorInfo);
}
else if (item is DependencyTelemetry)
{
var dep = item as DependencyTelemetry;
dep.MetricExtractorInfo = ExtractionPipelineInfo(dep.MetricExtractorInfo, extractorInfo);
}
}

string extractionPipelineInfo;
bool hasPrevInfo = itemWithProperties.Properties.TryGetValue(MetricTerms.Extraction.ProcessedByExtractors.Moniker.Key, out extractionPipelineInfo);

if (false == hasPrevInfo)
private static string ExtractionPipelineInfo(string extractionPipelineInfo, string extractorInfo)
{
if (extractionPipelineInfo?.Length > 0)
{
extractionPipelineInfo = String.Empty;
extractionPipelineInfo = extractionPipelineInfo + "; ";
}
else
{
if (extractionPipelineInfo.Length > 0)
{
extractionPipelineInfo = extractionPipelineInfo + "; ";
}
extractionPipelineInfo = String.Empty;
Copy link
Contributor

Choose a reason for hiding this comment

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

is stylecop fine with String uppercased? I'm surprised

}

extractionPipelineInfo = extractionPipelineInfo + extractorInfo;
itemWithProperties.Properties[MetricTerms.Extraction.ProcessedByExtractors.Moniker.Key] = extractionPipelineInfo;

return extractionPipelineInfo + extractorInfo;
}

/// <summary>
Expand Down