@@ -38,20 +38,20 @@ type investigationRequest struct {
38
38
}
39
39
40
40
// Interesting: The analysis complete with results that indicate a probable cause for failure.
41
- type AnalysisResult struct {
41
+ type analysisResult struct {
42
42
Successful bool `json:"successful"`
43
43
Interesting bool `json:"interesting"`
44
44
Message string `json:"message"`
45
45
Details map [string ]interface {} `json:"details"`
46
46
}
47
47
48
- type AnalysisMeta struct {
49
- Items []Analysis `json:"items"`
48
+ type analysisMeta struct {
49
+ Items []analysis `json:"items"`
50
50
}
51
51
52
- // An Analysis struct provides the status and results
52
+ // An analysis struct provides the status and results
53
53
// of running a specific type of check.
54
- type Analysis struct {
54
+ type analysis struct {
55
55
ID uuid.UUID `json:"id"`
56
56
CreatedAt time.Time `json:"created"`
57
57
UpdatedAt time.Time `json:"modified"`
@@ -65,7 +65,7 @@ type Analysis struct {
65
65
// Name is the name of the check that this analysis represents.
66
66
Name string `json:"name"`
67
67
Title string `json:"title"`
68
- Result AnalysisResult `json:"result"`
68
+ Result analysisResult `json:"result"`
69
69
}
70
70
71
71
type Investigation struct {
@@ -88,7 +88,7 @@ type Investigation struct {
88
88
// investigation failed.
89
89
FailureReason string `json:"failureReason,omitempty"`
90
90
91
- Analyses AnalysisMeta `json:"analyses"`
91
+ Analyses analysisMeta `json:"analyses"`
92
92
}
93
93
94
94
// siftClient represents a client for interacting with the Sift API.
@@ -167,7 +167,7 @@ type GetSiftAnalysisParams struct {
167
167
}
168
168
169
169
// getSiftAnalysis retrieves a specific analysis from an investigation
170
- func getSiftAnalysis (ctx context.Context , args GetSiftAnalysisParams ) (* Analysis , error ) {
170
+ func getSiftAnalysis (ctx context.Context , args GetSiftAnalysisParams ) (* analysis , error ) {
171
171
client , err := siftClientFromContext (ctx )
172
172
if err != nil {
173
173
return nil , fmt .Errorf ("creating Sift client: %w" , err )
@@ -241,7 +241,7 @@ type FindErrorPatternLogsParams struct {
241
241
}
242
242
243
243
// findErrorPatternLogs creates an investigation with ErrorPatternLogs check, waits for it to complete, and returns the analysis
244
- func findErrorPatternLogs (ctx context.Context , args FindErrorPatternLogsParams ) (* Analysis , error ) {
244
+ func findErrorPatternLogs (ctx context.Context , args FindErrorPatternLogsParams ) (* analysis , error ) {
245
245
client , err := siftClientFromContext (ctx )
246
246
if err != nil {
247
247
return nil , fmt .Errorf ("creating Sift client: %w" , err )
@@ -275,7 +275,7 @@ func findErrorPatternLogs(ctx context.Context, args FindErrorPatternLogsParams)
275
275
}
276
276
277
277
// Find the ErrorPatternLogs analysis
278
- var errorPatternLogsAnalysis * Analysis
278
+ var errorPatternLogsAnalysis * analysis
279
279
for i := range analyses {
280
280
if analyses [i ].Name == string (checkTypeErrorPatternLogs ) {
281
281
errorPatternLogsAnalysis = & analyses [i ]
@@ -307,7 +307,7 @@ type FindSlowRequestsParams struct {
307
307
}
308
308
309
309
// findSlowRequests creates an investigation with SlowRequests check, waits for it to complete, and returns the analysis
310
- func findSlowRequests (ctx context.Context , args FindSlowRequestsParams ) (* Analysis , error ) {
310
+ func findSlowRequests (ctx context.Context , args FindSlowRequestsParams ) (* analysis , error ) {
311
311
client , err := siftClientFromContext (ctx )
312
312
if err != nil {
313
313
return nil , fmt .Errorf ("creating Sift client: %w" , err )
@@ -341,7 +341,7 @@ func findSlowRequests(ctx context.Context, args FindSlowRequestsParams) (*Analys
341
341
}
342
342
343
343
// Find the SlowRequests analysis
344
- var slowRequestsAnalysis * Analysis
344
+ var slowRequestsAnalysis * analysis
345
345
for i := range analyses {
346
346
if analyses [i ].Name == string (checkTypeSlowRequests ) {
347
347
slowRequestsAnalysis = & analyses [i ]
@@ -492,7 +492,7 @@ func (c *siftClient) createSiftInvestigation(ctx context.Context, investigation
492
492
}
493
493
494
494
// getSiftAnalyses is a helper method to get all analyses from an investigation
495
- func (c * siftClient ) getSiftAnalyses (ctx context.Context , investigationID uuid.UUID ) ([]Analysis , error ) {
495
+ func (c * siftClient ) getSiftAnalyses (ctx context.Context , investigationID uuid.UUID ) ([]analysis , error ) {
496
496
path := fmt .Sprintf ("/api/plugins/grafana-ml-app/resources/sift/api/v1/investigations/%s/analyses" , investigationID )
497
497
buf , err := c .makeRequest (ctx , "GET" , path , nil )
498
498
if err != nil {
@@ -501,7 +501,7 @@ func (c *siftClient) getSiftAnalyses(ctx context.Context, investigationID uuid.U
501
501
502
502
var response struct {
503
503
Status string `json:"status"`
504
- Data []Analysis `json:"data"`
504
+ Data []analysis `json:"data"`
505
505
}
506
506
507
507
if err := json .Unmarshal (buf , & response ); err != nil {
@@ -512,15 +512,15 @@ func (c *siftClient) getSiftAnalyses(ctx context.Context, investigationID uuid.U
512
512
}
513
513
514
514
// getSiftAnalysis is a helper method to get a specific analysis from an investigation
515
- func (c * siftClient ) getSiftAnalysis (ctx context.Context , investigationID , analysisID uuid.UUID ) (* Analysis , error ) {
515
+ func (c * siftClient ) getSiftAnalysis (ctx context.Context , investigationID , analysisID uuid.UUID ) (* analysis , error ) {
516
516
// First get all analyses to verify the analysis exists
517
517
analyses , err := c .getSiftAnalyses (ctx , investigationID )
518
518
if err != nil {
519
519
return nil , fmt .Errorf ("getting analyses: %w" , err )
520
520
}
521
521
522
522
// Find the specific analysis
523
- var targetAnalysis * Analysis
523
+ var targetAnalysis * analysis
524
524
for _ , analysis := range analyses {
525
525
if analysis .ID == analysisID {
526
526
targetAnalysis = & analysis
0 commit comments