This commit is contained in:
ryan
2026-06-16 09:20:18 +08:00
parent bfa00ae6ac
commit c6df73e522
17 changed files with 183 additions and 25 deletions
+3 -2
View File
@@ -11,7 +11,8 @@ import (
"fmt"
"net/http"
"strings"
"time"
"github.com/Rain-kl/Wavelet/pkg/httppool"
)
func init() {
@@ -54,7 +55,7 @@ func (p *CustomPusher) Send(ctx context.Context, cfg Config, _ string, body map[
httpReq.Header.Set(strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1]))
}
client := &http.Client{Timeout: 10 * time.Second}
client := httppool.NewClient(defaultHTTPClientTimeout)
resp, err := client.Do(httpReq)
if err != nil {
return fmt.Errorf("custom: http request failed: %w", err)
+3 -1
View File
@@ -16,6 +16,8 @@ import (
"strconv"
"strings"
"time"
"github.com/Rain-kl/Wavelet/pkg/httppool"
)
func init() {
@@ -228,7 +230,7 @@ func (p *LarkPusher) Send(ctx context.Context, cfg Config, _ string, body map[st
}
httpReq.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 10 * time.Second}
client := httppool.NewClient(defaultHTTPClientTimeout)
resp, err := client.Do(httpReq)
if err != nil {
return fmt.Errorf("lark: http request failed: %w", err)
+4 -2
View File
@@ -8,11 +8,13 @@ import (
"context"
"fmt"
"sync"
"time"
)
const (
defaultTitle = "系统通知"
levelInfo = "INFO"
defaultTitle = "系统通知"
levelInfo = "INFO"
defaultHTTPClientTimeout = 10 * time.Second
)
// Config 基础通知渠道配置
+3 -2
View File
@@ -11,7 +11,8 @@ import (
"fmt"
"net/http"
"strings"
"time"
"github.com/Rain-kl/Wavelet/pkg/httppool"
)
func init() {
@@ -131,7 +132,7 @@ func (p *TelegramPusher) sendMessage(ctx context.Context, baseURL, token, chatID
}
httpReq.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 10 * time.Second}
client := httppool.NewClient(defaultHTTPClientTimeout)
resp, err := client.Do(httpReq)
if err != nil {
return fmt.Errorf("http request failed: %w", err)
+6 -1
View File
@@ -29,6 +29,7 @@ func init() {
type Config struct {
AppName string
SamplingRate float64
TracerName string
}
// Init 初始化 Tracer Provider 并关联全局 Tracer 实例
@@ -41,7 +42,11 @@ func Init(cfg Config) {
otel.SetTracerProvider(tracerProvider)
// 更新 Tracer
Tracer = tracerProvider.Tracer("github.com/Rain-kl/Wavelet")
tracerName := cfg.TracerName
if tracerName == "" {
tracerName = "github.com/Rain-kl/Wavelet"
}
Tracer = tracerProvider.Tracer(tracerName)
}
// Shutdown 关闭所有 Trace Provider