private void AggregationAndAggregationDataMismatch(IView view, IDictionary <TagValues, IAggregationData> entries) { // CumulativeData cumulativeData = // CumulativeData.Create(Timestamp.fromMillis(1000), Timestamp.fromMillis(2000)); // thrown.expect(IllegalArgumentException); // thrown.expectMessage("Aggregation and AggregationData types mismatch. "); Assert.Throws <ArgumentException>(() => ViewData.Create(view, entries, Timestamp.FromMillis(1000), Timestamp.FromMillis(2000))); }
public void TestCumulativeViewData() { IView view = View.Create(NAME, DESCRIPTION, MEASURE_DOUBLE, DISTRIBUTION, TAG_KEYS); ITimestamp start = Timestamp.FromMillis(1000); ITimestamp end = Timestamp.FromMillis(2000); IViewData viewData = ViewData.Create(view, ENTRIES, start, end); Assert.Equal(view, viewData.View); Assert.Equal(ENTRIES, viewData.AggregationMap); }
public void ProfiledCommandToSpanDataUsesTimestampAsStartTime() { var profiledCommand = new Mock <IProfiledCommand>(); var now = DateTimeOffset.Now; profiledCommand.Setup(m => m.CommandCreated).Returns(now.DateTime); var result = RedisProfilerEntryToSpanConverter.ProfiledCommandToSpanData(SpanContext.Blank, "SET", SpanId.Invalid, profiledCommand.Object); Assert.Equal(Timestamp.FromMillis(now.ToUnixTimeMilliseconds()), result.StartTimestamp); }
public void CanCreateFromMillis() { Timestamp timestamp = Timestamp.FromMillis(1565620091536); DateTimeOffset date = timestamp.ToDateTimeOffset(); Assert.AreEqual(12, date.Day); Assert.AreEqual(8, date.Month); Assert.AreEqual(2019, date.Year); Assert.AreEqual(14, date.Hour); Assert.AreEqual(28, date.Minute); Assert.AreEqual(11, date.Second); }
public void CanCreateFromMillis() { Timestamp timestamp = Timestamp.FromMillis(1565620091536); DateTimeOffset date = timestamp.ToDateTimeOffset(); date.Should().HaveDay(12); date.Should().HaveMonth(8); date.Should().HaveYear(2019); date.Should().HaveHour(14); date.Should().HaveMinute(28); date.Should().HaveSecond(11); }
public void TestViewDataEquals() { IView cumulativeView = View.Create(NAME, DESCRIPTION, MEASURE_DOUBLE, DISTRIBUTION, TAG_KEYS); // View intervalView = // View.Create(NAME, DESCRIPTION, MEASURE_DOUBLE, DISTRIBUTION, TAG_KEYS, INTERVAL_HOUR); // new EqualsTester() // .addEqualityGroup( IViewData data1 = ViewData.Create( cumulativeView, ENTRIES, Timestamp.FromMillis(1000), Timestamp.FromMillis(2000)); IViewData data2 = ViewData.Create( cumulativeView, ENTRIES, Timestamp.FromMillis(1000), Timestamp.FromMillis(2000)); Assert.Equal(data1, data2); // .addEqualityGroup( IViewData data3 = ViewData.Create( cumulativeView, ENTRIES, Timestamp.FromMillis(1000), Timestamp.FromMillis(3000)); Assert.NotEqual(data1, data3); Assert.NotEqual(data2, data3); // .addEqualityGroup( // IViewData data4 = ViewData.Create(intervalView, ENTRIES, IntervalData.Create(Timestamp.fromMillis(2000))), // IViewData data5 = ViewData.Create(intervalView, ENTRIES, IntervalData.Create(Timestamp.fromMillis(2000)))) // .addEqualityGroup( // ViewData.Create( // intervalView, // Collections.< List<TagValue>, AggregationData > emptyMap(), // IntervalData.Create(Timestamp.fromMillis(2000)))) // .testEquals(); }
public void TimestampFromMillis_Negative() { Assert.Equal(Timestamp.Create(-1, 999000000), Timestamp.FromMillis(-1)); Assert.Equal(Timestamp.Create(-1, 1000000), Timestamp.FromMillis(-999)); Assert.Equal(Timestamp.Create(-4, 544000000), Timestamp.FromMillis(-3456)); }
public void TimestampFromMillis() { Assert.Equal(Timestamp.Create(0, 0), Timestamp.FromMillis(0)); Assert.Equal(Timestamp.Create(0, 987000000), Timestamp.FromMillis(987)); Assert.Equal(Timestamp.Create(3, 456000000), Timestamp.FromMillis(3456)); }
internal static ISpanData ProfiledCommandToSpanData(ISpanContext context, string name, ISpanId parentSpanId, IProfiledCommand command) { var hasRemoteParent = false; // use https://github.com/opentracing/specification/blob/master/semantic_conventions.md for now // Timing example: // command.CommandCreated; //2019-01-10 22:18:28Z // command.CreationToEnqueued; // 00:00:32.4571995 // command.EnqueuedToSending; // 00:00:00.0352838 // command.SentToResponse; // 00:00:00.0060586 // command.ResponseToCompletion; // 00:00:00.0002601 // Total: // command.ElapsedTime; // 00:00:32.4988020 // TODO: make timestamp with the better precision Timestamp startTimestamp = Timestamp.FromMillis(new DateTimeOffset(command.CommandCreated).ToUnixTimeMilliseconds()); var timestamp = new DateTimeOffset(command.CommandCreated).Add(command.CreationToEnqueued); var events = TimedEvents <IEvent> .Create( new List <ITimedEvent <IEvent> >() { TimedEvent <IEvent> .Create(Timestamp.FromMillis(timestamp.ToUnixTimeMilliseconds()), Event.Create("Enqueued")), TimedEvent <IEvent> .Create(Timestamp.FromMillis((timestamp = timestamp.Add(command.EnqueuedToSending)).ToUnixTimeMilliseconds()), Event.Create("Sent")), TimedEvent <IEvent> .Create(Timestamp.FromMillis((timestamp = timestamp.Add(command.SentToResponse)).ToUnixTimeMilliseconds()), Event.Create("ResponseRecieved")), }, droppedEventsCount : 0); Timestamp endTimestamp = Timestamp.FromMillis(new DateTimeOffset(command.CommandCreated.Add(command.ElapsedTime)).ToUnixTimeMilliseconds()); // TODO: deal with the re-transmission // command.RetransmissionOf; // command.RetransmissionReason; var attributesMap = new Dictionary <string, IAttributeValue>() { // TODO: pre-allocate constant attribute and reuse { "db.type", AttributeValue.StringAttributeValue("redis") }, // Example: "redis.flags": None, DemandMaster { "redis.flags", AttributeValue.StringAttributeValue(command.Flags.ToString()) }, }; if (command.Command != null) { // Example: "db.statement": SET; attributesMap.Add("db.statement", AttributeValue.StringAttributeValue(command.Command)); } if (command.EndPoint != null) { // Example: "db.instance": Unspecified/localhost:6379[0] attributesMap.Add("db.instance", AttributeValue.StringAttributeValue(command.EndPoint.ToString() + "[" + command.Db + "]")); } var attributes = Attributes.Create(attributesMap, 0); ILinks links = null; int? childSpanCount = 0; // TODO: this is strange that IProfiledCommand doesn't give the result Status status = Status.Ok; SpanKind kind = SpanKind.Client; return(SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp)); }