Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

Commit

Permalink
updating packages to latest rc1 dev build
Browse files Browse the repository at this point in the history
  • Loading branch information
alhardy committed Feb 10, 2017
1 parent 97ccbb7 commit e015d47
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/App.Metrics.Extensions.Reporting.Console/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"copyright": "Allan Hardy 2016",

"dependencies": {
"App.Metrics": "1.0.0-beta5-2",
"App.Metrics": "1.0.0-rc1-build00284",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"StyleCop.Analyzers": {
"version": "1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -15,7 +14,7 @@ public class LineProtocolPoint
public LineProtocolPoint(
string measurement,
IReadOnlyDictionary<string, object> fields,
MetricTags tags = null,
MetricTags tags,
DateTime? utcTimestamp = null)
{
if (string.IsNullOrEmpty(measurement))
Expand All @@ -33,14 +32,6 @@ public class LineProtocolPoint
throw new ArgumentException("Fields must have non-empty names");
}

if (tags != null)
{
if (tags.Any(t => string.IsNullOrEmpty(t.Key)))
{
throw new ArgumentException("Tags must have non-empty names");
}
}

if (utcTimestamp != null && utcTimestamp.Value.Kind != DateTimeKind.Utc)
{
throw new ArgumentException("Timestamps must be specified as UTC");
Expand All @@ -56,7 +47,7 @@ public class LineProtocolPoint

public string Measurement { get; }

public ConcurrentDictionary<string, string> Tags { get; }
public MetricTags Tags { get; }

public DateTime? UtcTimestamp { get; }

Expand All @@ -69,19 +60,16 @@ public void Format(TextWriter textWriter)

textWriter.Write(LineProtocolSyntax.EscapeName(Measurement));

if (Tags != null)
if (Tags.Count > 0)
{
foreach (var t in Tags.OrderBy(t => t.Key))
{
if (string.IsNullOrEmpty(t.Value))
{
continue;
}
Array.Sort(Tags.Keys);

for (var i = 0; i < Tags.Count; i++)
{
textWriter.Write(',');
textWriter.Write(LineProtocolSyntax.EscapeName(t.Key));
textWriter.Write(LineProtocolSyntax.EscapeName(Tags.Keys[i]));
textWriter.Write('=');
textWriter.Write(LineProtocolSyntax.EscapeName(t.Value));
textWriter.Write(LineProtocolSyntax.EscapeName(Tags.Values[i]));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,27 @@ public async Task<bool> EndAndFlushReportRunAsync(IMetrics metrics)
healthStatusValue = 1;
}

_payloadBuilder.Pack("health", healthStatusValue, new MetricTags(globalTags));
var tags = new MetricTags(globalTags.Select(t => t.Key).ToArray(), globalTags.Select(t => t.Value).ToArray());

_payloadBuilder.Pack("health", healthStatusValue, tags);

var checks = unhealthy.Concat(degraded).Concat(healthyChecks);

foreach (var healthCheck in checks)
{
var tags = new MetricTags(globalTags).With("health_check", healthCheck.Name);
var allTags = MetricTags.Concat(tags, new MetricTags("health_check", healthCheck.Name));

if (healthCheck.Check.Status == HealthCheckStatus.Unhealthy)
{
_payloadBuilder.Pack("health_checks__unhealhty", healthCheck.Check.Message, tags);
_payloadBuilder.Pack("health_checks__unhealhty", healthCheck.Check.Message, allTags);
}
else if (healthCheck.Check.Status == HealthCheckStatus.Healthy)
{
_payloadBuilder.Pack("health_checks__healthy", healthCheck.Check.Message, tags);
_payloadBuilder.Pack("health_checks__healthy", healthCheck.Check.Message, allTags);
}
else if (healthCheck.Check.Status == HealthCheckStatus.Degraded)
{
_payloadBuilder.Pack("health_checks__degraded", healthCheck.Check.Message, tags);
_payloadBuilder.Pack("health_checks__degraded", healthCheck.Check.Message, allTags);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/App.Metrics.Extensions.Reporting.InfluxDB/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"copyright": "Allan Hardy 2016",

"dependencies": {
"App.Metrics": "1.0.0-beta5-2",
"App.Metrics": "1.0.0-rc1-build00284",
"Polly": "5.0.5",
"StyleCop.Analyzers": {
"version": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/App.Metrics.Extensions.Reporting.TextFile/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"copyright": "Allan Hardy 2016",

"dependencies": {
"App.Metrics": "1.0.0-beta5-2",
"App.Metrics": "1.0.0-rc1-build00284",
"StyleCop.Analyzers": {
"version": "1.0.0",
"type": "build"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public LineProtocolClientTests()
_payload = new LineProtocolPayload();
var fieldsOne = new Dictionary<string, object> { { "key", "value" } };
var timestampOne = new DateTime(2017, 1, 1, 1, 1, 1, DateTimeKind.Utc);
var pointOne = new LineProtocolPoint("measurement", fieldsOne, MetricTags.None, timestampOne);
var pointOne = new LineProtocolPoint("measurement", fieldsOne, MetricTags.Empty, timestampOne);
_payload.Add(pointOne);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void can_format_payload()
var payload = new LineProtocolPayload();
var fieldsOne = new Dictionary<string, object> { { "key", "value" } };
var timestampOne = new DateTime(2017, 1, 1, 1, 1, 1, DateTimeKind.Utc);
var pointOne = new LineProtocolPoint("measurement", fieldsOne, MetricTags.None, timestampOne);
var pointOne = new LineProtocolPoint("measurement", fieldsOne, MetricTags.Empty, timestampOne);

var fieldsTwo = new Dictionary<string, object>
{
Expand All @@ -29,7 +29,7 @@ public void can_format_payload()
{ "field3key", false }
};
var timestampTwo = new DateTime(2017, 1, 2, 1, 1, 1, DateTimeKind.Utc);
var pointTwo = new LineProtocolPoint("measurement", fieldsTwo, MetricTags.None, timestampTwo);
var pointTwo = new LineProtocolPoint("measurement", fieldsTwo, MetricTags.Empty, timestampTwo);

payload.Add(pointOne);
payload.Add(pointTwo);
Expand All @@ -56,7 +56,7 @@ public void when_null_text_writer_ignore_and_dont_throw()
{
var payload = new LineProtocolPayload();
var fields = new Dictionary<string, object> { { "key", "value" } };
var pointOne = new LineProtocolPoint("measurement", fields, MetricTags.None);
var pointOne = new LineProtocolPoint("measurement", fields, MetricTags.Empty);

Action action = () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void at_least_one_field_is_required()
var fields = new Dictionary<string, object>();
Action action = () =>
{
var point = new LineProtocolPoint("measurement", fields, MetricTags.None);
var point = new LineProtocolPoint("measurement", fields, MetricTags.Empty);
};

action.ShouldThrow<ArgumentException>();
Expand All @@ -31,7 +31,7 @@ public void can_format_payload_correctly()
var textWriter = new StringWriter();
var fields = new Dictionary<string, object> { { "key", "value" } };
var timestamp = new DateTime(2017, 1, 1, 1, 1, 1, DateTimeKind.Utc);
var point = new LineProtocolPoint("measurement", fields, MetricTags.None, timestamp);
var point = new LineProtocolPoint("measurement", fields, MetricTags.Empty, timestamp);

point.Format(textWriter);

Expand All @@ -43,7 +43,7 @@ public void can_format_payload_correctly_without_providing_timestamp()
{
var textWriter = new StringWriter();
var fields = new Dictionary<string, object> { { "key", "value" } };
var point = new LineProtocolPoint("measurement", fields, MetricTags.None);
var point = new LineProtocolPoint("measurement", fields, MetricTags.Empty);

point.Format(textWriter);

Expand All @@ -61,7 +61,7 @@ public void can_format_payload_with_multiple_fields_correctly()
{ "field3key", false }
};
var timestamp = new DateTime(2017, 1, 1, 1, 1, 1, DateTimeKind.Utc);
var point = new LineProtocolPoint("measurement", fields, MetricTags.None, timestamp);
var point = new LineProtocolPoint("measurement", fields, MetricTags.Empty, timestamp);

point.Format(textWriter);

Expand All @@ -74,7 +74,7 @@ public void can_format_payload_with_tags_correctly()
{
var textWriter = new StringWriter();
var fields = new Dictionary<string, object> { { "key", "value" } };
var tags = new MetricTags().With("tagkey", "tagvalue");
var tags = new MetricTags("tagkey", "tagvalue");
var timestamp = new DateTime(2017, 1, 1, 1, 1, 1, DateTimeKind.Utc);
var point = new LineProtocolPoint("measurement", fields, tags, timestamp);

Expand All @@ -89,7 +89,7 @@ public void field_key_cannot_be_empty()
var fields = new Dictionary<string, object> { { string.Empty, "value" } };
Action action = () =>
{
var point = new LineProtocolPoint("measurement", fields, MetricTags.None);
var point = new LineProtocolPoint("measurement", fields, MetricTags.Empty);
};

action.ShouldThrow<ArgumentException>();
Expand All @@ -101,21 +101,7 @@ public void measurement_is_required()
var fields = new Dictionary<string, object> { { "key", "value" } };
Action action = () =>
{
var point = new LineProtocolPoint(string.Empty, fields, MetricTags.None);
};

action.ShouldThrow<ArgumentException>();
}

[Fact]
public void tag_key_cannot_be_empty()
{
var fields = new Dictionary<string, object> { { "key", "value" } };
var tags = new MetricTags().With(string.Empty, "value");

Action action = () =>
{
var point = new LineProtocolPoint("measurement", fields, tags);
var point = new LineProtocolPoint(string.Empty, fields, MetricTags.Empty);
};

action.ShouldThrow<ArgumentException>();
Expand All @@ -132,7 +118,7 @@ public void time_stamp_should_be_utc(DateTimeKind dateTimeKind, bool expected)

Action action = () =>
{
var point = new LineProtocolPoint("measurement", fields, MetricTags.None, timestamp);
var point = new LineProtocolPoint("measurement", fields, MetricTags.Empty, timestamp);
};

if (!expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public void can_clear_payload()
var metricsMock = new Mock<IMetrics>();
var clock = new TestClock();
var meter = new DefaultMeterMetric(clock);
meter.Mark(new MetricItem().With("item1", "value1"), 1);
meter.Mark(new MetricItem().With("item2", "value2"), 1);
meter.Mark(new MetricSetItem("item1", "value1"), 1);
meter.Mark(new MetricSetItem("item2", "value2"), 1);
var meterValueSource = new MeterValueSource(
"test meter",
ConstantValue.Provider(meter.Value),
Unit.None,
TimeUnit.Milliseconds,
MetricTags.None);
MetricTags.Empty);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);

Expand All @@ -69,7 +69,7 @@ public void can_report_apdex()
var apdexValueSource = new ApdexValueSource(
"test apdex",
ConstantValue.Provider(gauge.Value),
MetricTags.None,
MetricTags.Empty,
false);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);
Expand All @@ -85,13 +85,13 @@ public void can_report_counter_with_items()
{
var metricsMock = new Mock<IMetrics>();
var counter = new DefaultCounterMetric();
counter.Increment(new MetricItem().With("item1", "value1"), 1);
counter.Increment(new MetricItem().With("item2", "value2"), 1);
counter.Increment(new MetricSetItem("item1", "value1"), 1);
counter.Increment(new MetricSetItem("item2", "value2"), 1);
var counterValueSource = new CounterValueSource(
"test counter",
ConstantValue.Provider(counter.Value),
Unit.None,
MetricTags.None);
MetricTags.Empty);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);

Expand All @@ -109,13 +109,13 @@ public void can_report_counter_with_items_with_option_not_to_report_percentage()
{
var metricsMock = new Mock<IMetrics>();
var counter = new DefaultCounterMetric();
counter.Increment(new MetricItem().With("item1", "value1"), 1);
counter.Increment(new MetricItem().With("item2", "value2"), 1);
counter.Increment(new MetricSetItem("item1", "value1"), 1);
counter.Increment(new MetricSetItem("item2", "value2"), 1);
var counterValueSource = new CounterValueSource(
"test counter",
ConstantValue.Provider(counter.Value),
Unit.None,
MetricTags.None,
MetricTags.Empty,
reportItemPercentages: false);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);
Expand All @@ -139,7 +139,7 @@ public void can_report_counters()
"test counter",
ConstantValue.Provider(counter.Value),
Unit.None,
MetricTags.None);
MetricTags.Empty);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);

Expand All @@ -158,7 +158,7 @@ public void can_report_gauges()
"test gauge",
ConstantValue.Provider(gauge.Value),
Unit.None,
MetricTags.None);
MetricTags.Empty);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);

Expand Down Expand Up @@ -208,7 +208,7 @@ public void can_report_histograms()
"test histogram",
ConstantValue.Provider(histogram.Value),
Unit.None,
MetricTags.None);
MetricTags.Empty);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);

Expand All @@ -233,7 +233,7 @@ public void can_report_meters()
ConstantValue.Provider(meter.Value),
Unit.None,
TimeUnit.Milliseconds,
MetricTags.None);
MetricTags.Empty);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);

Expand All @@ -249,14 +249,14 @@ public void can_report_meters_with_items()
var metricsMock = new Mock<IMetrics>();
var clock = new TestClock();
var meter = new DefaultMeterMetric(clock);
meter.Mark(new MetricItem().With("item1", "value1"), 1);
meter.Mark(new MetricItem().With("item2", "value2"), 1);
meter.Mark(new MetricSetItem("item1", "value1"), 1);
meter.Mark(new MetricSetItem("item2", "value2"), 1);
var meterValueSource = new MeterValueSource(
"test meter",
ConstantValue.Provider(meter.Value),
Unit.None,
TimeUnit.Milliseconds,
MetricTags.None);
MetricTags.Empty);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);

Expand All @@ -282,7 +282,7 @@ public void can_report_timers()
Unit.None,
TimeUnit.Milliseconds,
TimeUnit.Milliseconds,
MetricTags.None);
MetricTags.Empty);
var payloadBuilder = new LineProtocolPayloadBuilder();
var reporter = CreateReporter(payloadBuilder);

Expand Down

0 comments on commit e015d47

Please sign in to comment.