Coffee journaling on ATProto (alpha) alpha.arabica.social
coffee

feat: improved otel tracing #18

merged opened by pdewey.com targeting main from push-yxlyzwontrtr
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:hm5f3dnm6jdhrc55qp2npdja/sh.tangled.repo.pull/3mgcwjfy6p622
+20 -1
Diff #0
+16
internal/atproto/client.go
··· 4 "context" 5 "errors" 6 "fmt" 7 8 "arabica/internal/metrics" 9 "arabica/internal/tracing" ··· 11 "github.com/bluesky-social/indigo/atproto/atclient" 12 "github.com/bluesky-social/indigo/atproto/syntax" 13 "github.com/rs/zerolog/log" 14 ) 15 16 // ErrSessionExpired is returned when the OAuth session cannot be resumed, ··· 42 // This client automatically handles DPOP signing and token refresh 43 apiClient := session.APIClient() 44 45 return apiClient, nil 46 } 47
··· 4 "context" 5 "errors" 6 "fmt" 7 + "net/http" 8 9 "arabica/internal/metrics" 10 "arabica/internal/tracing" ··· 12 "github.com/bluesky-social/indigo/atproto/atclient" 13 "github.com/bluesky-social/indigo/atproto/syntax" 14 "github.com/rs/zerolog/log" 15 + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" 16 ) 17 18 // ErrSessionExpired is returned when the OAuth session cannot be resumed, ··· 44 // This client automatically handles DPOP signing and token refresh 45 apiClient := session.APIClient() 46 47 + // Wrap the HTTP transport with OpenTelemetry instrumentation so outbound PDS 48 + // HTTP calls appear as child spans under the existing pds.* semantic spans. 49 + // We create a new http.Client rather than mutating the shared session client. 50 + baseTransport := apiClient.Client.Transport 51 + if baseTransport == nil { 52 + baseTransport = http.DefaultTransport 53 + } 54 + apiClient.Client = &http.Client{ 55 + Transport: otelhttp.NewTransport(baseTransport), 56 + Timeout: apiClient.Client.Timeout, 57 + CheckRedirect: apiClient.Client.CheckRedirect, 58 + Jar: apiClient.Client.Jar, 59 + } 60 + 61 return apiClient, nil 62 } 63
+4 -1
internal/atproto/public_client.go
··· 12 "strings" 13 "sync" 14 "time" 15 ) 16 17 const ( ··· 100 return &PublicClient{ 101 baseURL: PublicAPIBaseURL, 102 httpClient: &http.Client{ 103 - Timeout: 30 * time.Second, 104 }, 105 pdsCache: make(map[string]string), 106 }
··· 12 "strings" 13 "sync" 14 "time" 15 + 16 + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" 17 ) 18 19 const ( ··· 102 return &PublicClient{ 103 baseURL: PublicAPIBaseURL, 104 httpClient: &http.Client{ 105 + Timeout: 30 * time.Second, 106 + Transport: otelhttp.NewTransport(http.DefaultTransport), 107 }, 108 pdsCache: make(map[string]string), 109 }

History

1 round 0 comments
sign up or login to add to the discussion
pdewey.com submitted #0
1 commit
expand
feat: improved otel tracing
expand 0 comments
pull request successfully merged