BeginTelemetry starts an attachment event at full sampling for the raw supplied count. A zero count returns nil without changing sampling. recorder is required; use a no-op service when telemetry is disabled. Call immediately before Flag.UserAssets so invalid and over-limit inputs count.
(recorder ghtelemetry.InvocationRecorder, command string, attachCount int)
| 13 | // use a no-op service when telemetry is disabled. |
| 14 | // Call immediately before Flag.UserAssets so invalid and over-limit inputs count. |
| 15 | func BeginTelemetry(recorder ghtelemetry.InvocationRecorder, command string, attachCount int) *TelemetryEvent { |
| 16 | if attachCount == 0 { |
| 17 | return nil |
| 18 | } |
| 19 | |
| 20 | recorder.SetSampleRate(ghtelemetry.SAMPLE_ALL) |
| 21 | pendingEvent := recorder.Begin(ghtelemetry.Event{ |
| 22 | Type: "attachment_invocation", |
| 23 | Dimensions: ghtelemetry.Dimensions{ |
| 24 | "command": command, |
| 25 | }, |
| 26 | Measures: ghtelemetry.Measures{ |
| 27 | "attach_count": int64(attachCount), |
| 28 | "append_ops_count": 0, |
| 29 | "replace_ops_count": 0, |
| 30 | }, |
| 31 | }) |
| 32 | |
| 33 | return &TelemetryEvent{ |
| 34 | pendingEvent: pendingEvent, |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // RecordOperations replaces, rather than adds to, the completed operation counts. |
| 39 | // Pass partial results before handling an upload error so successful work is retained. |