public void ProfiledCommandToSpanDataSetsDbTypeAttributeAsRedis() { var profiledCommand = new Mock <IProfiledCommand>(); var result = RedisProfilerEntryToSpanConverter.ProfiledCommandToSpanData(SpanContext.Invalid, "SET", SpanId.Invalid, profiledCommand.Object); Assert.Contains("db.type", result.Attributes.AttributeMap.Keys); Assert.Equal(AttributeValue.StringAttributeValue("redis"), result.Attributes.AttributeMap["db.type"]); }
public void ProfiledCommandToSpanDataUsesCommandAsDbStatementAttribute() { var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.Command).Returns("SET"); var result = RedisProfilerEntryToSpanConverter.ProfiledCommandToSpanData(SpanContext.Invalid, "another name", SpanId.Invalid, profiledCommand.Object); Assert.Contains("db.statement", result.Attributes.AttributeMap.Keys); Assert.Equal(AttributeValue.StringAttributeValue("SET"), result.Attributes.AttributeMap["db.statement"]); }
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.Invalid, "SET", SpanId.Invalid, profiledCommand.Object); Assert.Equal(Timestamp.FromMillis(now.ToUnixTimeMilliseconds()), result.StartTimestamp); }
public void ProfiledCommandToSpanDataUsesFlagsForFlagsAttribute() { var profiledCommand = new Mock <IProfiledCommand>(); var expectedFlags = StackExchange.Redis.CommandFlags.FireAndForget | StackExchange.Redis.CommandFlags.NoRedirect; profiledCommand.Setup(m => m.Flags).Returns(expectedFlags); var result = RedisProfilerEntryToSpanConverter.ProfiledCommandToSpanData(SpanContext.Invalid, "SET", SpanId.Invalid, profiledCommand.Object); Assert.Contains("redis.flags", result.Attributes.AttributeMap.Keys); Assert.Equal(AttributeValue.StringAttributeValue("None, FireAndForget, NoRedirect"), result.Attributes.AttributeMap["redis.flags"]); }