@@ -106,34 +106,34 @@ type remoteReporter struct {
106
106
}
107
107
108
108
func (r * remoteReporter ) Report (snapshot * Snapshot ) {
109
- snapshot .DeploymentID = r .options .DeploymentID
109
+ go r .reportSync (snapshot )
110
+ }
110
111
111
- // Runs in a goroutine so it's non-blocking to callers!
112
- go func () {
113
- data , err := json .Marshal (snapshot )
114
- if err != nil {
115
- r .options .Logger .Error (r .ctx , "marshal snapshot: %w" , slog .Error (err ))
116
- return
117
- }
118
- req , err := http .NewRequestWithContext (r .ctx , "POST" , r .snapshotURL .String (), bytes .NewReader (data ))
119
- if err != nil {
120
- r .options .Logger .Error (r .ctx , "create request" , slog .Error (err ))
121
- return
122
- }
123
- req .Header .Set (VersionHeader , buildinfo .Version ())
124
- resp , err := http .DefaultClient .Do (req )
125
- if err != nil {
126
- // If the request fails it's not necessarily an error.
127
- // In an airgapped environment, it's fine if this fails!
128
- r .options .Logger .Debug (r .ctx , "submit" , slog .Error (err ))
129
- return
130
- }
131
- if resp .StatusCode != http .StatusAccepted {
132
- r .options .Logger .Debug (r .ctx , "bad response from telemetry server" , slog .F ("status" , resp .StatusCode ))
133
- return
134
- }
135
- r .options .Logger .Debug (r .ctx , "submitted snapshot" )
136
- }()
112
+ func (r * remoteReporter ) reportSync (snapshot * Snapshot ) {
113
+ snapshot .DeploymentID = r .options .DeploymentID
114
+ data , err := json .Marshal (snapshot )
115
+ if err != nil {
116
+ r .options .Logger .Error (r .ctx , "marshal snapshot: %w" , slog .Error (err ))
117
+ return
118
+ }
119
+ req , err := http .NewRequestWithContext (r .ctx , "POST" , r .snapshotURL .String (), bytes .NewReader (data ))
120
+ if err != nil {
121
+ r .options .Logger .Error (r .ctx , "create request" , slog .Error (err ))
122
+ return
123
+ }
124
+ req .Header .Set (VersionHeader , buildinfo .Version ())
125
+ resp , err := http .DefaultClient .Do (req )
126
+ if err != nil {
127
+ // If the request fails it's not necessarily an error.
128
+ // In an airgapped environment, it's fine if this fails!
129
+ r .options .Logger .Debug (r .ctx , "submit" , slog .Error (err ))
130
+ return
131
+ }
132
+ if resp .StatusCode != http .StatusAccepted {
133
+ r .options .Logger .Debug (r .ctx , "bad response from telemetry server" , slog .F ("status" , resp .StatusCode ))
134
+ return
135
+ }
136
+ r .options .Logger .Debug (r .ctx , "submitted snapshot" )
137
137
}
138
138
139
139
func (r * remoteReporter ) Close () {
@@ -203,7 +203,7 @@ func (r *remoteReporter) reportWithDeployment() {
203
203
r .options .Logger .Error (r .ctx , "create snapshot" , slog .Error (err ))
204
204
return
205
205
}
206
- r .Report (snapshot )
206
+ r .reportSync (snapshot )
207
207
}
208
208
209
209
// deployment collects host information and reports it to the telemetry server.
0 commit comments