mirror of
https://github.com/hanzoai/gateway.git
synced 2026-10-30 15:04:44 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
35 lines
922 B
Go
35 lines
922 B
Go
package zipkin
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net"
|
|
|
|
"contrib.go.opencensus.io/exporter/zipkin"
|
|
opencensus "github.com/hanzoai/gateway/v2/internal/plugin/opencensus"
|
|
"github.com/openzipkin/zipkin-go/model"
|
|
httpreporter "github.com/openzipkin/zipkin-go/reporter/http"
|
|
)
|
|
|
|
func init() {
|
|
opencensus.RegisterExporterFactories(func(ctx context.Context, cfg opencensus.Config) (any, error) {
|
|
return Exporter(ctx, cfg)
|
|
})
|
|
}
|
|
|
|
func Exporter(_ context.Context, cfg opencensus.Config) (*zipkin.Exporter, error) {
|
|
if cfg.Exporters.Zipkin == nil {
|
|
return nil, errDisabled
|
|
}
|
|
return zipkin.NewExporter(
|
|
httpreporter.NewReporter(cfg.Exporters.Zipkin.CollectorURL),
|
|
&model.Endpoint{
|
|
ServiceName: cfg.Exporters.Zipkin.ServiceName,
|
|
IPv4: net.ParseIP(cfg.Exporters.Zipkin.IP),
|
|
Port: uint16(cfg.Exporters.Zipkin.Port),
|
|
},
|
|
), nil
|
|
}
|
|
|
|
var errDisabled = errors.New("opencensus zipkin exporter disabled")
|