tangled
alpha
login
or
join now
arabica.social
/
arabica
7
fork
atom
Coffee journaling on ATProto (alpha)
alpha.arabica.social
coffee
7
fork
atom
overview
issues
pulls
pipelines
feat: improved otel tracing
pdewey.com
1 week ago
73988b80
2a8774c7
verified
This commit was signed with the committer's
known signature
.
pdewey.com
SSH Key Fingerprint:
SHA256:ePOVkJstqVLchGK8m9/OGQG+aFNHD5XN3xjvW9wKCA4=
+20
-1
2 changed files
expand all
collapse all
unified
split
internal
atproto
client.go
public_client.go
+16
internal/atproto/client.go
···
4
4
"context"
5
5
"errors"
6
6
"fmt"
7
7
+
"net/http"
7
8
8
9
"arabica/internal/metrics"
9
10
"arabica/internal/tracing"
···
11
12
"github.com/bluesky-social/indigo/atproto/atclient"
12
13
"github.com/bluesky-social/indigo/atproto/syntax"
13
14
"github.com/rs/zerolog/log"
15
15
+
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
14
16
)
15
17
16
18
// ErrSessionExpired is returned when the OAuth session cannot be resumed,
···
41
43
// Get the authenticated API client from the session
42
44
// This client automatically handles DPOP signing and token refresh
43
45
apiClient := session.APIClient()
46
46
+
47
47
+
// Wrap the HTTP transport with OpenTelemetry instrumentation so outbound PDS
48
48
+
// HTTP calls appear as child spans under the existing pds.* semantic spans.
49
49
+
// We create a new http.Client rather than mutating the shared session client.
50
50
+
baseTransport := apiClient.Client.Transport
51
51
+
if baseTransport == nil {
52
52
+
baseTransport = http.DefaultTransport
53
53
+
}
54
54
+
apiClient.Client = &http.Client{
55
55
+
Transport: otelhttp.NewTransport(baseTransport),
56
56
+
Timeout: apiClient.Client.Timeout,
57
57
+
CheckRedirect: apiClient.Client.CheckRedirect,
58
58
+
Jar: apiClient.Client.Jar,
59
59
+
}
44
60
45
61
return apiClient, nil
46
62
}
+4
-1
internal/atproto/public_client.go
···
12
12
"strings"
13
13
"sync"
14
14
"time"
15
15
+
16
16
+
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
15
17
)
16
18
17
19
const (
···
100
102
return &PublicClient{
101
103
baseURL: PublicAPIBaseURL,
102
104
httpClient: &http.Client{
103
103
-
Timeout: 30 * time.Second,
105
105
+
Timeout: 30 * time.Second,
106
106
+
Transport: otelhttp.NewTransport(http.DefaultTransport),
104
107
},
105
108
pdsCache: make(map[string]string),
106
109
}