diff --git a/bin/share.conf b/bin/share.conf index 35384d40..894743ca 100644 --- a/bin/share.conf +++ b/bin/share.conf @@ -144,7 +144,7 @@ set_env("QUANTA_DB_CACHE_FLUSH", "10") set_env("QUANTA_WEBHOOK_MODE", "log") --set_env("QUANTA_LARK_URL", "https://open.feishu.cn/open-apis/bot/v2/hook/9a6565bf-51b4-48ab-80f0-64caf4d58ab8") --set_env("QUANTA_DING_URL", "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a4c64781-adad-4ddc-a615-6bc232ce71ef") ---set_env("QUANTA_WECHAT_URL", "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ee6d97c5-477d-436f-83db-dd5361a5e8bd") +set_env("QUANTA_WECHAT_URL", "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=d7cd918c-f608-4762-87af-bb8c7fc51074") --graylog配置 ----------------------------------------------------- diff --git a/core/luabus/src/lua_socket_node.cpp b/core/luabus/src/lua_socket_node.cpp index a0267953..0a7aba03 100644 --- a/core/luabus/src/lua_socket_node.cpp +++ b/core/luabus/src/lua_socket_node.cpp @@ -118,7 +118,7 @@ int lua_socket_node::forward_transfer(lua_State* L, uint32_t session_id, uint32_ return 1; } -int lua_socket_node::forward_target(lua_State* L, uint32_t session_id, uint8_t flag, uint32_t target_id) { +int lua_socket_node::forward_target(lua_State* L, uint64_t session_id, uint8_t flag, uint32_t target_id) { if (m_codec) { size_t data_len = 0; char* data = (char*)m_codec->encode(L, 4, &data_len); @@ -142,7 +142,7 @@ int lua_socket_node::forward_target(lua_State* L, uint32_t session_id, uint8_t f return 1; } -int lua_socket_node::forward_hash(lua_State* L, uint32_t session_id, uint8_t flag, uint8_t service_id, uint16_t hash) { +int lua_socket_node::forward_hash(lua_State* L, uint64_t session_id, uint8_t flag, uint8_t service_id, uint16_t hash) { if (m_codec) { size_t data_len = 0; char* data = (char*)m_codec->encode(L, 5, &data_len); @@ -166,7 +166,7 @@ int lua_socket_node::forward_hash(lua_State* L, uint32_t session_id, uint8_t fla return 1; } -int lua_socket_node::transfer_call(lua_State* L, uint32_t session_id, uint32_t target_id) { +int lua_socket_node::transfer_call(lua_State* L, uint64_t session_id, uint32_t target_id) { char* data; size_t data_len = 0; if (lua_type(L, 3) == LUA_TTABLE) { @@ -194,7 +194,7 @@ int lua_socket_node::transfer_call(lua_State* L, uint32_t session_id, uint32_t t return 0; } -int lua_socket_node::transfer_hash(lua_State* L, uint32_t session_id, uint8_t service_id, uint16_t hash) { +int lua_socket_node::transfer_hash(lua_State* L, uint64_t session_id, uint8_t service_id, uint16_t hash) { if (m_codec) { size_t data_len = 0; char* data = (char*)m_codec->encode(L, 4, &data_len); diff --git a/script/driver/webhook.lua b/script/driver/webhook.lua index 9152f2bf..27005d05 100644 --- a/script/driver/webhook.lua +++ b/script/driver/webhook.lua @@ -5,9 +5,8 @@ local jencode = json.encode local sformat = string.format local WEBPATH = environ.get("QUANTA_WEBHOOK_PATH", "./webhooks/") -local log_dump = logfeature.dump("bilogs", WEBPATH, true) +local log_dump = logfeature.dump("webhooks", WEBPATH, true) -local event_mgr = quanta.get("event_mgr") local thread_mgr = quanta.get("thread_mgr") local http_client = quanta.get("http_client") @@ -24,17 +23,16 @@ prop:reader("hooks", {}) --webhook通知接口 prop:reader("notify_limit", {}) --控制同样消息的发送频率 function Webhook:__init() - self.title = sformat("%s | %s", HOST_IP, quanta.service_name) - --初始化hooks - self.hooks.lark_log = environ.get("QUANTA_LARK_URL") - self.hooks.ding_log = environ.get("QUANTA_DING_URL") - self.hooks.wechat_log = environ.get("QUANTA_WECHAT_URL") - -- 注册事件 - event_mgr:add_listener(self, "rpc_fire_webhook") - self.mode = environ.get("QUANTA_WEBHOOK_MODE") - if self.mode then + local mode = environ.get("QUANTA_WEBHOOK_MODE") + if mode then --添加webhook功能 + self.mode = mode logger.add_monitor(self) + self.title = sformat("%s | %s", HOST_IP, quanta.service_name) + --初始化hooks + self.hooks.lark_log = environ.get("QUANTA_LARK_URL") + self.hooks.ding_log = environ.get("QUANTA_DING_URL") + self.hooks.wechat_log = environ.get("QUANTA_WECHAT_URL") end end @@ -76,8 +74,8 @@ function Webhook:ding_log(url, context, at_mobiles, at_all) end --dispatch_log -function Webhook:dispatch_log(content, ...) - if next(self.hooks) then +function Webhook:dispatch_log(content) + if self.mode then local now = quanta.now local notify = self.notify_limit[content] if not notify then @@ -92,7 +90,7 @@ function Webhook:dispatch_log(content, ...) end notify.count = notify.count + 1 for hook_api, url in pairs(self.hooks) do - self[hook_api](self, url, content, ...) + self[hook_api](self, url, content) end end end diff --git a/script/driver/zipkin.lua b/script/driver/zipkin.lua index 320c54ab..4986aa58 100644 --- a/script/driver/zipkin.lua +++ b/script/driver/zipkin.lua @@ -76,9 +76,13 @@ function Zipkin:sub_span(name, parent_id) return self:general(name, trace_id, parent_id) end -function Zipkin:set_tag(span, tag, value) - span.tags[tag] = tostring(value) - span.duration = quanta.now_ms * 1000 - span.timestamp +function Zipkin:set_tag(span, ...) + local tags = { ... } + local n = #tags // 2 + for i = 1, n do + local tag = tags[i*2 - 1] + span.tags[tag] = tags[i*2] + end end function Zipkin:set_annotation(span, value) @@ -88,7 +92,6 @@ function Zipkin:set_annotation(span, value) } local annotations = span.annotations annotations[#annotations + 1] = annotation - span.duration = quanta.now_ms * 1000 - span.timestamp end function Zipkin:recovery_span(span) diff --git a/script/feature/worker.lua b/script/feature/worker.lua index 4e2c1567..bdb5a30d 100644 --- a/script/feature/worker.lua +++ b/script/feature/worker.lua @@ -70,6 +70,7 @@ end local function init_mainloop() import("kernel/timer_mgr.lua") import("kernel/update_mgr.lua") + import("driver/webhook.lua") event_mgr = quanta.get("event_mgr") thread_mgr = quanta.get("thread_mgr") update_mgr = quanta.get("update_mgr") diff --git a/script/kernel.lua b/script/kernel.lua index 99380ba5..54c358bc 100644 --- a/script/kernel.lua +++ b/script/kernel.lua @@ -65,6 +65,7 @@ local function init_mainloop() import("kernel/timer_mgr.lua") import("kernel/update_mgr.lua") import("feature/scheduler.lua") + import("driver/webhook.lua") update_mgr = quanta.get("update_mgr") scheduler = quanta.get("scheduler") end