public void ProfiledCommandToSpanSetsDbTypeAttributeAsRedis()
        {
            var profiledCommand = new Mock <IProfiledCommand>();

            profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow);
            var result = ((SpanSdk)RedisProfilerEntryToSpanConverter.ProfilerCommandToSpan(this.tracer, null, profiledCommand.Object));

            Assert.Contains(result.Attributes, kvp => kvp.Key == "db.type");
            Assert.Equal("redis", result.Attributes.GetValue("db.type"));
        }
        public void ProfiledCommandToSpanUsesTimestampAsStartTime()
        {
            var profiledCommand = new Mock <IProfiledCommand>();
            var now             = DateTimeOffset.Now;

            profiledCommand.Setup(m => m.CommandCreated).Returns(now.DateTime);
            var result = ((SpanSdk)RedisProfilerEntryToSpanConverter.ProfilerCommandToSpan(this.tracer, null, profiledCommand.Object));

            Assert.Equal(now, result.StartTimestamp);
        }
        public void ProfiledCommandToSpanUsesCommandAsDbStatementAttribute()
        {
            var profiledCommand = new Mock <IProfiledCommand>();

            profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow);
            profiledCommand.Setup(m => m.Command).Returns("SET");
            var result = (SpanSdk)RedisProfilerEntryToSpanConverter.ProfilerCommandToSpan(this.tracer, null, profiledCommand.Object);

            Assert.Contains(result.Attributes, kvp => kvp.Key == "db.statement");
            Assert.Equal("SET", result.Attributes.GetValue("db.statement"));
        }
        public void DrainSessionUsesCommandAsName()
        {
            var profiledCommand = new Mock <IProfiledCommand>();

            profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow);
            profiledCommand.Setup(m => m.Command).Returns("SET");

            var result = (SpanSdk)RedisProfilerEntryToSpanConverter.ProfilerCommandToSpan(this.tracer, null, profiledCommand.Object);

            Assert.Equal("SET", result.Name);
        }
        public void ProfiledCommandToSpanUsesFlagsForFlagsAttribute()
        {
            var profiledCommand = new Mock <IProfiledCommand>();

            profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow);
            var expectedFlags = StackExchange.Redis.CommandFlags.FireAndForget |
                                StackExchange.Redis.CommandFlags.NoRedirect;

            profiledCommand.Setup(m => m.Flags).Returns(expectedFlags);
            var result = (SpanSdk)RedisProfilerEntryToSpanConverter.ProfilerCommandToSpan(this.tracer, null, profiledCommand.Object);

            Assert.Contains(result.Attributes, kvp => kvp.Key == "redis.flags");
            Assert.Equal("None, FireAndForget, NoRedirect", result.Attributes.GetValue("redis.flags"));
        }