缩短告警信息里面的时间显示
大石头 authored at 2022-02-23 22:24:23
4.20 KiB
Stardust
@model TraceViewModel
@using Stardust.Data.Monitors
@using NewLife;
@using NewLife.Web;
@using XCode;
@using XCode.Configuration;
@using XCode.Membership;
@using NewLife.Cube;
@using System.Web;
@using Stardust.Web.Models;
@{
    //Layout = NewLife.Cube.Setting.Current.Layout;

    var page = Model.Page;
    var list = Model.Data;
}
<div class="table-responsive">
    @if (!page["traceId"].IsNullOrEmpty() && list.Select(e => e.AppId).Distinct().Count() > 1)
    {
        await Html.RenderPartialAsync("_AppChain", list);
    }
    @if (list.Count > 0)
    {
        await Html.RenderPartialAsync("_CallChain", list);
    }
    <table class="table table-bordered table-hover table-striped table-condensed">
        <thead>
            <tr>
                <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("AppId"))">应用</a></th>
                <th class="text-center" title="操作名。接口名或埋点名"><a href="@Html.Raw(page.GetSortUrl("Name"))">操作名</a></th>
                <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Success"))">正常</a></th>
                <th class="text-center" style="min-width:134px;" title="开始时间。Unix毫秒"><a href="@Html.Raw(page.GetSortUrl("StartTime"))">开始时间</a></th>
                <th class="text-center" title="结束时间。Unix毫秒"><a href="@Html.Raw(page.GetSortUrl("EndTime"))">结束时间</a></th>
                <th class="text-center" title="耗时。毫秒"><a href="@Html.Raw(page.GetSortUrl("Cost"))">耗时</a></th>
                <th class="text-center" title="实例。应用可能多实例部署,ip@proccessid"><a href="@Html.Raw(page.GetSortUrl("ClientId"))">客户端实例</a></th>
                <th class="text-center" title="唯一标识。随线程上下文、Http、Rpc传递,作为内部片段的父级"><a href="@Html.Raw(page.GetSortUrl("SpanId"))">唯一标识</a></th>
                <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("ParentId"))">父级标识</a></th>
                <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("CreateIP"))">创建地址</a></th>
                <th class="text-center">操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var entity in list)
            {
                    var ti = entity.TraceItem;
                var url1 = $"/Monitors/appDayStat?appId={entity.AppId}";
                var url2 = $"/Monitors/traceDayStat?appid={entity.AppId}&itemId={entity.ItemId}";
                var color2 = "";
                if (ti.Kind.EqualIgnoreCase("db"))
                {
                    color2 = "orange";
                }
                else if (ti.Kind.EqualIgnoreCase("mq", "redismq", "mqtt", "mns", "emq"))
                {
                    color2 = "mediumpurple";
                }
                else if (ti.Kind.EqualIgnoreCase("redis"))
                {
                    color2 = "palevioletred";
                }
                    <tr>
                        <td class="text-center"><a href="@url1" title="应用最近的监控图表">@entity.AppName</a></td>
                        <td title="@entity.Tag" style="max-width:400px;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;"><a href="@url2" style="color: @color2">@entity.Name</a></td>
                        <td class="text-center">
                            <i class="glyphicon glyphicon-@(entity.Success ? "ok" : "remove")" style="color: @(entity.Success ? "green" : "red");"></i>
                        </td>
                        <td class="text-center" title="@entity.StartTime">@entity.Start.ToFullString("")</td>
                        <td class="text-center" title="@entity.EndTime">@entity.End.ToString("HH:mm:ss")</td>
                        <td class="text-right">@entity.Cost.ToString("n0")</td>
                        <td>@entity.ClientId</td>
                        <td>@entity.SpanId</td>
                        <td>@entity.ParentId</td>
                        <td>@entity.CreateIP</td>
                        <td class="text-center">
                            <a href="/monitors/sampledata/detail/@entity.Id">查看</a>
                        </td>
                    </tr>
            }
        </tbody>
    </table>
</div>