Files
zeekayandHanzo Dev a5c5cc019e Go 1.27.1, and the code it can say more simply
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]>
2026-09-16 22:42:15 -07:00

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")