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