public void ProfilerCommandToActivity_UsesTimestampAsStartTime() { var now = DateTimeOffset.Now; var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.CommandCreated).Returns(now.DateTime); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.Equal(now, result.StartTimeUtc); }
public void ProfilerCommandToActivity_SetsDbTypeAttributeAsRedis() { var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeDBSystem); Assert.Equal("redis", result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeDBSystem).Value); }
public void ProfilerCommandToActivity_SetsDbTypeAttributeAsRedis() { var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.NotNull(result.GetTagValue(SemanticConventions.AttributeDbSystem)); Assert.Equal("redis", result.GetTagValue(SemanticConventions.AttributeDbSystem)); }
public void ProfilerCommandToActivity_UsesCommandAsName() { var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow); profiledCommand.Setup(m => m.Command).Returns("SET"); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.Equal("SET", result.DisplayName); }
public void ProfilerCommandToActivity_UsesOtherEndPointAsEndPoint() { var unixEndPoint = new UnixDomainSocketEndPoint("https://opentelemetry.io/"); var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.EndPoint).Returns(unixEndPoint); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributePeerService); Assert.Equal(unixEndPoint.ToString(), result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributePeerService).Value); }
public void ProfilerCommandToActivity_UsesCommandAsDbStatementAttribute() { var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow); profiledCommand.Setup(m => m.Command).Returns("SET"); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.Contains(result.Tags, kvp => kvp.Key == SpanAttributeConstants.DatabaseStatementKey); Assert.Equal("SET", result.Tags.FirstOrDefault(kvp => kvp.Key == SpanAttributeConstants.DatabaseStatementKey).Value); }
public void ProfilerCommandToActivity_UsesCommandAsDbStatementAttribute() { var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow); profiledCommand.Setup(m => m.Command).Returns("SET"); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object, new StackExchangeRedisCallsInstrumentationOptions()); Assert.NotNull(result.GetTagValue(SemanticConventions.AttributeDbStatement)); Assert.Equal("SET", result.GetTagValue(SemanticConventions.AttributeDbStatement)); }
public void ProfilerCommandToActivity_UsesOtherEndPointAsEndPoint() { var unixEndPoint = new UnixDomainSocketEndPoint("https://opentelemetry.io/"); var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow); profiledCommand.Setup(m => m.EndPoint).Returns(unixEndPoint); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object, new StackExchangeRedisCallsInstrumentationOptions()); Assert.NotNull(result.GetTagValue(SemanticConventions.AttributePeerService)); Assert.Equal(unixEndPoint.ToString(), result.GetTagValue(SemanticConventions.AttributePeerService)); }
public void ProfilerCommandToActivity_UsesDnsEndPointAsEndPoint() { var dnsEndPoint = new DnsEndPoint("https://opentelemetry.io/", 443); var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.EndPoint).Returns(dnsEndPoint); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeNetPeerName); Assert.Equal(dnsEndPoint.Host, result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeNetPeerName).Value); Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeNetPeerPort); Assert.Equal(dnsEndPoint.Port.ToString(), result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeNetPeerPort).Value); }
public void ProfilerCommandToActivity_UsesFlagsForFlagsAttribute() { var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.CommandCreated).Returns(DateTime.UtcNow); var expectedFlags = CommandFlags.FireAndForget | CommandFlags.NoRedirect; profiledCommand.Setup(m => m.Flags).Returns(expectedFlags); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.Contains(result.Tags, kvp => kvp.Key == StackExchangeRedisCallsInstrumentation.RedisFlagsKeyName); Assert.Equal("PreferMaster, FireAndForget, NoRedirect", result.Tags.FirstOrDefault(kvp => kvp.Key == StackExchangeRedisCallsInstrumentation.RedisFlagsKeyName).Value); }
public void ProfilerCommandToActivity_UsesDnsEndPointAsEndPoint() { var dnsEndPoint = new DnsEndPoint("https://opentelemetry.io/", 443); var activity = new Activity("redis-profiler"); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.EndPoint).Returns(dnsEndPoint); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.NotNull(result.GetTagValue(SemanticConventions.AttributeNetPeerName)); Assert.Equal(dnsEndPoint.Host, result.GetTagValue(SemanticConventions.AttributeNetPeerName)); Assert.NotNull(result.GetTagValue(SemanticConventions.AttributeNetPeerPort)); Assert.Equal(dnsEndPoint.Port, result.GetTagValue(SemanticConventions.AttributeNetPeerPort)); }
public void ProfilerCommandToActivity_UsesIpEndPointAsEndPoint() { long address = 1; int port = 2; var activity = new Activity("redis-profiler"); IPEndPoint ipLocalEndPoint = new IPEndPoint(address, port); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.EndPoint).Returns(ipLocalEndPoint); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeNetPeerIP); Assert.Equal($"{address}.0.0.0", result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeNetPeerIP).Value); Assert.Contains(result.Tags, kvp => kvp.Key == SemanticConventions.AttributeNetPeerPort); Assert.Equal($"{port}", result.Tags.FirstOrDefault(kvp => kvp.Key == SemanticConventions.AttributeNetPeerPort).Value); }
public void ProfilerCommandToActivity_UsesIpEndPointAsEndPoint() { long address = 1; int port = 2; var activity = new Activity("redis-profiler"); IPEndPoint ipLocalEndPoint = new IPEndPoint(address, port); var profiledCommand = new Mock <IProfiledCommand>(); profiledCommand.Setup(m => m.EndPoint).Returns(ipLocalEndPoint); var result = RedisProfilerEntryToActivityConverter.ProfilerCommandToActivity(activity, profiledCommand.Object); Assert.NotNull(result.GetTagValue(SemanticConventions.AttributeNetPeerIp)); Assert.Equal($"{address}.0.0.0", result.GetTagValue(SemanticConventions.AttributeNetPeerIp)); Assert.NotNull(result.GetTagValue(SemanticConventions.AttributeNetPeerPort)); Assert.Equal(port, result.GetTagValue(SemanticConventions.AttributeNetPeerPort)); }