add jaeger support

This commit is contained in:
xxj
2022-08-19 17:42:25 +08:00
parent e73655c0ef
commit e1b97a73ca
8 changed files with 431 additions and 7 deletions

View File

@@ -0,0 +1 @@
{"buildTargets":["all","build","clear","gen","install","linux","mac","master","orm","run","source_install","windows"],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}}

5
example/.vscode/dryrun.log vendored Normal file
View File

@@ -0,0 +1,5 @@
make.exe --dry-run --always-make --keep-going --print-directory
make.exe: Entering directory 'f:/xxj/work/workspace/github/xxjwxc/gmsec/example'
make clear
make.exe: Leaving directory 'f:/xxj/work/workspace/github/xxjwxc/gmsec/example'

3
example/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"makefile.extensionOutputFolder": "./.vscode"
}

408
example/.vscode/targets.log vendored Normal file
View File

@@ -0,0 +1,408 @@
make.exe all --print-data-base --no-builtin-variables --no-builtin-rules --question
# GNU Make 4.2.1
# Built for x86_64-w64-mingw32
# Copyright (C) 1988-2016 Free Software Foundation, Inc.
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.
# Make data base, printed on Fri Aug 19 17:25:12 2022
# Variables
# 'override' directive
GNUMAKEFLAGS :=
# environment
POWERSHELL_DISTRIBUTION_CHANNEL = MSI:Windows 10 Enterprise
# automatic
?F = $(notdir $?)
# automatic
<D = $(patsubst %/,%,$(patsubst %\,%,$(dir $<)))
# default
.SHELLFLAGS := -c
# environment
PROVIDE_FULLSTACK_ACTION = true
# makefile
MAKEFLAGS = pqrR
# automatic
?D = $(patsubst %/,%,$(patsubst %\,%,$(dir $?)))
# automatic
@D = $(patsubst %/,%,$(patsubst %\,%,$(dir $@)))
# environment
HOMEDRIVE = C:
# automatic
@F = $(notdir $@)
# automatic
^D = $(patsubst %/,%,$(patsubst %\,%,$(dir $^)))
# makefile
CURDIR := f:/xxj/work/workspace/github/xxjwxc/gmsec/example
# default
SHELL := C:/cygwin64/bin/sh.exe
# environment
WINDIR = C:\WINDOWS
# environment
VSCODE_NLS_CONFIG = {"locale":"zh-cn","availableLanguages":{"*":"zh-cn"},"_languagePackId":"cc0490d1397af23dc5bf44a96fe15dbb.zh-cn","_translationsConfigFile":"C:\\Users\\xxj\\AppData\\Roaming\\Code\\clp\\cc0490d1397af23dc5bf44a96fe15dbb.zh-cn\\tcf.json","_cacheRoot":"C:\\Users\\xxj\\AppData\\Roaming\\Code\\clp\\cc0490d1397af23dc5bf44a96fe15dbb.zh-cn","_resolvedLanguagePackCoreLocation":"C:\\Users\\xxj\\AppData\\Roaming\\Code\\clp\\cc0490d1397af23dc5bf44a96fe15dbb.zh-cn\\e4503b30fc78200f846c62cf8091b76ff5547662","_corruptedFile":"C:\\Users\\xxj\\AppData\\Roaming\\Code\\clp\\cc0490d1397af23dc5bf44a96fe15dbb.zh-cn\\corrupted.info","_languagePackSupport":true}
# environment
VBOX_MSI_INSTALL_PATH = D:\Program Files\Oracle\VirtualBox\
# environment
ONEDRIVE = C:\Users\xxj\OneDrive
# environment
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
# makefile (from 'Makefile', line 1)
MAKEFILE_LIST := Makefile
# environment
FPS_BROWSER_USER_PROFILE_STRING = Default
# environment
GO111MODULE = auto
# environment
TMP = C:\Users\xxj\AppData\Local\Temp
# environment
VSCODE_AMD_ENTRYPOINT = vs/workbench/api/node/extensionHostProcess
# environment
PROGRAMW6432 = C:\Program Files
# environment
PROGRAMDATA = C:\ProgramData
# environment
VSCODE_CWD = F:\xxj\work\workspace\github\xxjwxc\gmsec
# environment
GOPROXY = https://goproxy.cn,direct
# default
MAKE_HOST := x86_64-w64-mingw32
# environment
PATH = C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;F:\xxj\work\path\goflow;D:\Program Files (x86)\NetSarang\Xshell 7\;D:\Program Files (x86)\NetSarang\Xftp 7\;D:\Program Files\Git\cmd;C:\cygwin64\bin;C:\mingw\mingw64\bin;C:\WINDOWS\System32\OpenSSH\;C:\xxj\work\path\bin;C:\Program Files\PowerShell\7-preview\preview;C:\Program Files\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin;C:\ProgramData\chocolatey\bin;C:\Users\xxj\AppData\Local\bin\NASM;C:\xxj\nodejs\;C:\xxj\nodejs\node_global;C:\Program Files\Pandoc\;C:\mingw\bin;C:\xxj\ffmpeg\bin;D:\Program Files\TortoiseSVN\bin;C:\Program Files\dotnet\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;D:\Program Files\Java\jdk1.8.0_271\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Graphviz\bin;C:\Users\xxj\AppData\Local\Microsoft\WindowsApps\;C:\Program Files\GitHub CLI\;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\dotnet\;C:\xxj\GO\bin;C:\Users\xxj\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\xxj\AppData\Local\Programs\Python\Python310\;C:\Users\xxj\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\xxj\AppData\Local\Programs\Python\Python39\;C:\Users\xxj\.windows-build-tools\python27\;C:\Users\xxj\.windows-build-tools\python27\;C:\Users\xxj\AppData\Local\hyper\app-3.0.2\resources\bin;C:\Users\xxj\AppData\Local\Microsoft\WindowsApps;C:\Users\xxj\AppData\Local\GitHubDesktop\bin;C:\Users\xxj\go\bin;C:\Users\xxj\AppData\Roaming\npm;C:\Users\xxj\.dotnet\tools;C:\Users\xxj\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\xxj\go\bin
# environment
COMMONPROGRAMW6432 = C:\Program Files\Common Files
# environment
ZES_ENABLE_SYSMAN = 1
# environment
GOLANG_EXECUTABLE = go
# environment
CHOCOLATEYLASTPATHUPDATE = 132520708830176095
# environment
PROCESSOR_ARCHITECTURE = AMD64
# environment
THREE_SCALE_USER_TOKEN = 207c527cfc2a6b8dcf4fa43ad7a976da
# environment
USERPROFILE = C:\Users\xxj
# environment
CHOCOLATEYINSTALL = C:\ProgramData\chocolatey
# environment
ALLUSERSPROFILE = C:\ProgramData
# environment
GOPATH = C:\xxj\work\path
# environment
NUMBER_OF_PROCESSORS = 6
# environment
ELECTRON_RUN_AS_NODE = 1
# default
.FEATURES := target-specific order-only second-expansion else-if shortest-stem undefine oneshell archives jobserver output-sync
# environment
UUID = b2f498a5-963d-4805-a7b0-24a67693c6ea
# automatic
%F = $(notdir $%)
# environment
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_12916_JJGMGMVLQRQPRGOM
# environment
COMPUTERNAME = DESKTOP-MKDBR7M
# environment
PROGRAMFILES = C:\Program Files
# default
.LOADED :=
# environment
DRIVERDATA = C:\Windows\System32\Drivers\DriverData
# environment
WORKON_HOME = C:\python27\.env
# environment
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
# environment
USERNAME = xxj
# environment
PUBLIC = C:\Users\Public
# environment
GOMODCACHE = C:\xxj\work\path\pkg\mod
# environment
VSCODE_CODE_CACHE_PATH = C:\Users\xxj\AppData\Roaming\Code\CachedData\e4503b30fc78200f846c62cf8091b76ff5547662
# environment
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = 1
# environment
COMMONPROGRAMFILES = C:\Program Files\Common Files
# environment
LOGONSERVER = \\DESKTOP-MKDBR7M
# environment
TELEMETRY_ID = 7e24775a-f59d-4015-ae09-c6b88667a981
# environment
VSCODE_HANDLES_UNCAUGHT_ERRORS = true
# environment
USERDOMAIN = DESKTOP-MKDBR7M
# environment
MAKELEVEL := 0
# default
MAKE = $(MAKE_COMMAND)
# default
MAKECMDGOALS := all
# environment
JAVA_HOME = D:\Program Files\Java\jdk1.8.0_271
# default
MAKE_VERSION := 4.2.1
# makefile
.DEFAULT_GOAL := all
# makefile (from 'Makefile', line 1)
NAME := example
# environment
CLASSPATH = .
# environment
PROGRAMFILES(X86) = C:\Program Files (x86)
# automatic
%D = $(patsubst %/,%,$(patsubst %\,%,$(dir $%)))
# environment
LOCALAPPDATA = C:\Users\xxj\AppData\Local
# environment
PSMODULEPATH = C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
# default
MAKE_COMMAND := make.exe
# environment
UTM_SOURCE = vscode
# default
.VARIABLES :=
# automatic
*F = $(notdir $*)
# environment
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
# environment
OS = Windows_NT
# environment
VSCODE_IPC_HOOK = \\.\pipe\9d32b475a0f4fe8e62a499d73e2eaae6-1.70.2-main-sock
# environment
WXDRIVE_START_ARGS = --wxdrive-setting=0 --disable-gpu --disable-software-rasterizer --enable-features=NetworkServiceInProcess
# environment
HOMEPATH = \Users\xxj
# environment
COMMONPROGRAMFILES(X86) = C:\Program Files (x86)\Common Files
# environment
PROMPT = $P$G
# environment
MFLAGS = -pqrR
# automatic
*D = $(patsubst %/,%,$(patsubst %\,%,$(dir $*)))
# environment
SYSTEMROOT = C:\WINDOWS
# automatic
+D = $(patsubst %/,%,$(patsubst %\,%,$(dir $+)))
# environment
RECOMMENDER_API_URL = https://gw.api.openshift.io//api/v2
# automatic
+F = $(notdir $+)
# environment
APPDATA = C:\Users\xxj\AppData\Roaming
# environment
__COMPAT_LAYER = DetectorsAppHealth
# environment
TEMP = C:\Users\xxj\AppData\Local\Temp
# environment
COMSPEC = C:\WINDOWS\system32\cmd.exe
# default
MAKEFILES :=
# automatic
<F = $(notdir $<)
# environment
LC_ALL = C
# automatic
^F = $(notdir $^)
# default
SUFFIXES :=
# environment
SYSTEMDRIVE = C:
# environment
SESSIONNAME = Console
# environment
PROCESSOR_REVISION = 9e0a
# environment
VS140COMNTOOLS = C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
# default
.RECIPEPREFIX :=
# environment
LANG = C
# environment
PROCESSOR_LEVEL = 6
# environment
FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
# environment
VSCODE_PID = 12916
# environment
USERDOMAIN_ROAMINGPROFILE = DESKTOP-MKDBR7M
# variable set hash-table stats:
# Load=110/1024=11%, Rehash=0, Collisions=19/134=14%
# Pattern-specific Variable Values
# No pattern-specific variable values.
# Directories
# . (key f:/xxj/work/workspace/github/xxjwxc/gmsec/example, mtime 1660822103): 17 files, no impossibilities.
# 17 files, no impossibilities in 1 directories.
# Implicit Rules
# No implicit rules.
# Files
clear:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 21):
test ! -d internal/model/ || rm -rf internal/model/*
test ! -d err/ || rm -rf err/
test ! -f $(NAME) || rm $(NAME)
test ! -f $(NAME).exe || rm $(NAME).exe
rm -rf ./prc/$(NAME)/*.go # 删除proto文件夹下所有go文件谨慎操作
mac:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 17):
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $(NAME) main.go
all:
# Command line target.
# Implicit rule search has not been done.
# Implicit/static pattern stem: ''
# File does not exist.
# File has been updated.
# Needs to be updated (-q is set).
# automatic
# @ := all
# automatic
# % :=
# automatic
# * :=
# automatic
# + :=
# automatic
# | :=
# automatic
# < :=
# automatic
# ^ :=
# automatic
# ? :=
# variable set hash-table stats:
# Load=8/32=25%, Rehash=0, Collisions=1/11=9%
# recipe to execute (from 'Makefile', line 3):
make clear
windows:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 15):
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o $(NAME).exe main.go
# Not a target:
.SUFFIXES:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# Not a target:
Makefile:
# Implicit rule search has been done.
# Last modified 2021-03-02 16:52:57
# File has been updated.
# Successfully updated.
gen:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 36):
# test -h rpc || ln -s ../rpc ./ # with linux/mac
test -d rpc || ln -s ../rpc ./
go generate
build:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 5):
make clear
./tools/gormt -o internal/model
go build -o $(NAME) main.go
./$(NAME) debug
source_install:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 45):
../proto_install.sh
orm:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 41):
./tools/gormt -o internal/model
# Not a target:
.DEFAULT:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
run:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 10):
# make clear
# ./tools/gormt -o internal/model
go build -o $(NAME) *.go
./$(NAME) debug
linux:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 19):
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(NAME) main.go
master:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 47):
go get -u github.com/xxjwxc/public@master
go get -u github.com/xxjwxc/ginrpc@master
go get -u github.com/gmsec/micro@master
go get -u github.com/gmsec/goplugins@master
install:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# recipe to execute (from 'Makefile', line 43):
../proto_install.sh
# files hash-table stats:
# Load=15/1024=1%, Rehash=0, Collisions=0/27=0%
# VPATH Search Paths
# No 'vpath' search paths.
# No general ('VPATH' variable) search path.
# strcache buffers: 1 (0) / strings = 31 / storage = 222 B / avg = 7 B
# current buf: size = 8162 B / used = 222 B / count = 31 / avg = 7 B
# strcache performance: lookups = 48 / hit rate = 35%
# hash-table stats:
# Load=31/8192=0%, Rehash=0, Collisions=1/48=2%
# Finished Make data base on Fri Aug 19 17:25:12 2022

View File

@@ -20,4 +20,5 @@ etcd_info:
timeout: 3
consul_addr: http://192.155.1.150:8500
consul_tag: dev
jaeger_addr: 192.155.1.150:6831
port: 82

View File

@@ -14,6 +14,7 @@ type Config struct {
Port string `yaml:"port" consul:"port"` // 端口号
ConsulAddr string `yaml:"consul_addr" consul:"consul_addr" ` // consul 地址
ConsulTag string `yaml:"consul_tag" consul:"consul_tag"`
JaegerAddr string `yaml:"jaeger_addr" consul:"jaeger_addr"`
}
// MysqlDbInfo mysql database information. mysql 数据库信息
@@ -98,3 +99,7 @@ func GetConsulTag() string {
return "service"
}
func GetJaegerAddr() string {
return _map.JaegerAddr
}

View File

@@ -50,8 +50,8 @@ func (dao *DaoCore) GetDBw() *mysqldb.MySqlDB {
func (dao *DaoCore) InitDao() {
runtime.SetFinalizer(dao, dao.Destroy) //析构时触发
dao.dbr = mysqldb.OnInitDBOrm(config.GetMysqlConStr())
dao.dbw = mysqldb.OnInitDBOrm(config.GetMysqlConStr())
dao.dbr = mysqldb.OnInitDBOrm(config.GetMysqlConStr(), true)
dao.dbw = mysqldb.OnInitDBOrm(config.GetMysqlConStr(), true)
}
// Destroy 释放

View File

@@ -12,6 +12,7 @@ import (
"github.com/gmsec/goplugins/plugin"
"github.com/gmsec/micro"
"github.com/gmsec/micro/registry"
"github.com/gmsec/micro/tracer"
"github.com/xxjwxc/public/mydoc/myswagger"
"github.com/xxjwxc/public/server"
_ "go.etcd.io/etcd/client/v3"
@@ -25,7 +26,7 @@ func CallBack() {
myswagger.SetBasePath("example")
myswagger.SetSchemes(true, false)
// -----end --
// tracer.WithTracer("192.155.1.150:6831") // 链路追踪
tracer.WithTracer(config.GetJaegerAddr()) // 链路追踪
reg := registry.NewDNSNamingRegistry()
// reg := etcdv3.NewEtcdv3NamingRegistry(v3.Config{
// Endpoints: config.GetEtcdInfo().Addrs,
@@ -43,10 +44,10 @@ func CallBack() {
// gin restful 相关
router := gin.Default()
router.Use(routers.Cors())
// trace := tracer.GetTracer()
// if trace != nil { // 链路追踪
// router.Use(routers.UseJager(trace))
// }
trace := tracer.GetTracer()
if trace != nil { // 链路追踪
router.Use(routers.UseJager(trace))
}
v1 := router.Group("/example/api/v1")
routers.OnInitRoot(service.Server(), v1) // 自定义初始化
// ------ end