66 "strings"
77 "time"
88
9- "github.com/getlantern/golog "
9+ "github.com/sagernet/sing-box/log "
1010 sdkotel "go.opentelemetry.io/otel"
1111 "go.opentelemetry.io/otel/attribute"
1212 "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
@@ -16,10 +16,6 @@ import (
1616 semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
1717)
1818
19- var (
20- log = golog .LoggerFor ("otel" )
21- )
22-
2319type Opts struct {
2420 Endpoint string
2521 Headers map [string ]string
@@ -62,7 +58,7 @@ func InitGlobalMeterProvider(opts *Opts) (func(), error) {
6258
6359 // If endpoint doesn't use port 443, assume insecure (HTTP not HTTPS)
6460 if ! strings .Contains (opts .Endpoint , ":443" ) {
65- log .Debugf ("Using insecure connection for OTEL metrics endpoint %v" , opts .Endpoint )
61+ log .Debug ("Using insecure connection for OTEL metrics endpoint %v" , opts .Endpoint )
6662 metricOpts = append (metricOpts , otlpmetrichttp .WithInsecure ())
6763 }
6864
@@ -85,7 +81,7 @@ func InitGlobalMeterProvider(opts *Opts) (func(), error) {
8581 defer cancel ()
8682 err := mp .Shutdown (ctx )
8783 if err != nil {
88- log .Errorf ("error shutting down meter provider: %v" , err )
84+ log .Error ("error shutting down meter provider: %v" , err )
8985 }
9086 }, nil
9187}
@@ -101,19 +97,19 @@ func (opts *Opts) buildResource() *resource.Resource {
10197 attributes = append (attributes , attribute .String ("track" , opts .Track ))
10298 }
10399 if opts .ProxyName != "" {
104- log .Debugf ("Will report with proxy.name %v" , opts .ProxyName )
100+ log .Debug ("Will report with proxy.name %v" , opts .ProxyName )
105101 attributes = append (attributes , attribute .String ("proxy.name" , opts .ProxyName ))
106102 }
107103 if opts .Provider != "" {
108- log .Debugf ("Will report with provider %v" , opts .Provider )
104+ log .Debug ("Will report with provider %v" , opts .Provider )
109105 attributes = append (attributes , attribute .String ("provider" , opts .Provider ))
110106 }
111107 if opts .DC != "" {
112- log .Debugf ("Will report with dc %v" , opts .DC )
108+ log .Debug ("Will report with dc %v" , opts .DC )
113109 attributes = append (attributes , attribute .String ("dc" , opts .DC ))
114110 }
115111 if opts .FrontendProvider != "" {
116- log .Debugf ("Will report frontend provider %v in dc %v" , opts .FrontendProvider , opts .FrontendDC )
112+ log .Debug ("Will report frontend provider %v in dc %v" , opts .FrontendProvider , opts .FrontendDC )
117113 attributes = append (attributes , attribute .String ("frontend.provider" , opts .FrontendProvider ))
118114 attributes = append (attributes , attribute .String ("frontend.dc" , opts .FrontendDC ))
119115 }
0 commit comments