fork of indigo with slightly nicer lexgen

Wrap robust HTTP client with OTEL

Changed files
+5 -11
models
util
+2 -11
models/models.go
··· 2 2 3 3 import ( 4 4 "database/sql" 5 - "net/http" 6 5 "time" 7 6 8 - "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" 9 7 "gorm.io/gorm" 10 8 11 9 bsky "github.com/bluesky-social/indigo/api/bsky" ··· 124 122 } 125 123 126 124 func ClientForPds(pds *PDS) *xrpc.Client { 127 - c := http.Client{ 128 - Transport: otelhttp.NewTransport(http.DefaultTransport), 129 - Timeout: time.Minute * 5, 130 - } 131 - 132 125 if pds.SSL { 133 126 return &xrpc.Client{ 134 - Client: &c, 135 - Host: "https://" + pds.Host, 127 + Host: "https://" + pds.Host, 136 128 } 137 129 } 138 130 139 131 return &xrpc.Client{ 140 - Client: &c, 141 - Host: "http://" + pds.Host, 132 + Host: "http://" + pds.Host, 142 133 } 143 134 } 144 135
+3
util/http.go
··· 6 6 "net/http" 7 7 "time" 8 8 9 + "github.com/hashicorp/go-cleanhttp" 9 10 "github.com/hashicorp/go-retryablehttp" 11 + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" 10 12 ) 11 13 12 14 type LeveledSlog struct { ··· 45 47 46 48 logger := LeveledSlog{inner: slog.Default().With("subsystem", "RobustHTTPClient")} 47 49 retryClient := retryablehttp.NewClient() 50 + retryClient.HTTPClient.Transport = otelhttp.NewTransport(cleanhttp.DefaultPooledTransport()) 48 51 retryClient.RetryMax = 3 49 52 retryClient.RetryWaitMin = 1 * time.Second 50 53 retryClient.RetryWaitMax = 10 * time.Second