From 37548b4e6b1570e31b462f23b8a9afa7eb653dbe Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 16 Nov 2022 17:45:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=98=BF=E9=87=8C?= =?UTF-8?q?=E4=BA=91=20trace=20url=20(#241)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: fusikai --- api/apiv1/proxyintegrat/group.go | 4 +- api/apiv1/proxyintegrat/trace_url.go | 22 +++++++ app/adminengine/router_admin.go | 1 + .../components/ModalCreate/index.tsx | 1 + assets/src/pages/proxy/index.tsx | 2 +- assets/src/pages/proxy/proxyView/index.tsx | 62 +++++++++++++------ .../src/pages/proxy/services/proxyintegrat.ts | 5 ++ config/resource.yaml | 3 + .../aliyunlog/complete_log_search_url.go | 58 ++++++++++++++++- .../pkg/service/loggerplatform/default.go | 6 +- pkg/model/view/loggerplatform.go | 10 +-- 11 files changed, 143 insertions(+), 31 deletions(-) create mode 100644 api/apiv1/proxyintegrat/trace_url.go diff --git a/api/apiv1/proxyintegrat/group.go b/api/apiv1/proxyintegrat/group.go index 26ded5351..d84adaa16 100644 --- a/api/apiv1/proxyintegrat/group.go +++ b/api/apiv1/proxyintegrat/group.go @@ -2,9 +2,10 @@ package proxyintegrat import "github.com/labstack/echo/v4" -//Group api group +// Group api group func Group(g *echo.Group) { g.GET("/uilist", UIList) + g.GET("/traceURL", TraceURL) g.GET("/proxyMenuList", ProxyMenuList) g.POST("/proxyMenuCreateOrUpdate", ProxyMenuCreateOrUpdate) g.POST("/proxyMenuDelete", ProxyMenuDelete) @@ -12,4 +13,5 @@ func Group(g *echo.Group) { g.GET("/proxyManageList", ProxyManageList) g.POST("/proxyManageCreateOrUpdate", ProxyManageCreateOrUpdate) g.POST("/proxyManageDelete", ProxyManageDelete) + } diff --git a/api/apiv1/proxyintegrat/trace_url.go b/api/apiv1/proxyintegrat/trace_url.go new file mode 100644 index 000000000..1b76d50e4 --- /dev/null +++ b/api/apiv1/proxyintegrat/trace_url.go @@ -0,0 +1,22 @@ +package proxyintegrat + +import ( + "github.com/douyu/juno/internal/pkg/packages/contrib/output" + "github.com/douyu/juno/internal/pkg/service/aliyunlog" + "github.com/douyu/juno/internal/pkg/service/user" + "github.com/labstack/echo/v4" +) + +// TraceUrl 阿里云trace地址获取 +func TraceURL(c echo.Context) (err error) { + u := user.GetUser(c) + toURL := c.QueryParam("toURL") + data, err := aliyunlog.Instance.CompleteTraceSearchUrl(c.Request().Context(), &aliyunlog.CompleteTraceSearchUrlRequest{ + Region: "华北2(北京)", + ToURL: toURL, + }, u) + if err != nil { + return output.JSON(c, output.MsgErr, err.Error()) + } + return output.JSON(c, output.MsgOk, "", map[string]interface{}{"url": data}) +} diff --git a/app/adminengine/router_admin.go b/app/adminengine/router_admin.go index 929a6ae5d..74ea83ef9 100644 --- a/app/adminengine/router_admin.go +++ b/app/adminengine/router_admin.go @@ -413,4 +413,5 @@ func apiAdmin(server *xecho.Server) { { loggerGroup.GET("/logstore", core.Handle(loggerplatform.LogStore)) } + } diff --git a/assets/src/pages/analysis/proxy/proxymenu/components/ModalCreate/index.tsx b/assets/src/pages/analysis/proxy/proxymenu/components/ModalCreate/index.tsx index 992823455..8ed631229 100644 --- a/assets/src/pages/analysis/proxy/proxymenu/components/ModalCreate/index.tsx +++ b/assets/src/pages/analysis/proxy/proxymenu/components/ModalCreate/index.tsx @@ -20,6 +20,7 @@ export interface ModalCreateResourceInterface { export const PanelTypes = [ { title: 'Grafana', val: 'grafana' }, { title: 'Pyroscope', val: 'pyroscope' }, + { title: 'AliTrace', val: 'alitrace' }, ]; function ModalCreateResource(props: ModalCreateResourceInterface) { diff --git a/assets/src/pages/proxy/index.tsx b/assets/src/pages/proxy/index.tsx index 18e66ecc2..51874ec67 100644 --- a/assets/src/pages/proxy/index.tsx +++ b/assets/src/pages/proxy/index.tsx @@ -24,7 +24,7 @@ const renderPanel = (config) => { case 'welcome': return ; default: - return ; + return ; } }; diff --git a/assets/src/pages/proxy/proxyView/index.tsx b/assets/src/pages/proxy/proxyView/index.tsx index 757424ebb..431684e11 100644 --- a/assets/src/pages/proxy/proxyView/index.tsx +++ b/assets/src/pages/proxy/proxyView/index.tsx @@ -1,25 +1,51 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; +import { traceURL } from "../services/proxyintegrat" -export default class Proxy extends React.Component { - render() { - const { proxyURL } = this.props; - return ( -
{ + traceURL({ toURL: proxyURL }).then((res) => { + if (res.code == 0) { + updateDynamicUrl(res.data && res.data.url); + } + }) + }, []) + return dynamicUrl !== '' ?
+