MCPcopy Create free account
hub / github.com/cli/cli / BeginTelemetry

Function BeginTelemetry

internal/attachments/telemetry.go:15–36  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

13// use a no-op service when telemetry is disabled.
14// Call immediately before Flag.UserAssets so invalid and over-limit inputs count.
15func 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.

Callers 11

Test_createRunFunction · 0.92
NewCmdCreateFunction · 0.92
Test_editRunFunction · 0.92
NewCmdEditFunction · 0.92
CommentablePreRunFunction · 0.92
Test_createRunFunction · 0.92
NewCmdCreateFunction · 0.92
Test_editRunFunction · 0.92
NewCmdEditFunction · 0.92
TestAttachmentTelemetryFunction · 0.85

Calls 2

SetSampleRateMethod · 0.65
BeginMethod · 0.65

Tested by 6

Test_createRunFunction · 0.74
Test_editRunFunction · 0.74
Test_createRunFunction · 0.74
Test_editRunFunction · 0.74
TestAttachmentTelemetryFunction · 0.68