-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: queue size datadog tracking (#1491)
Kuberpults queue size is now tracked on datadog. New metric: kuberpult.request_queue_size --------- Co-authored-by: Sven Urbanski <[email protected]>
- Loading branch information
1 parent
5cb4e21
commit 0da192f
Showing
3 changed files
with
75 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5876,12 +5876,13 @@ func setupRepositoryTestWithPath(t *testing.T) (Repository, string) { | |
repo, err := New( | ||
testutil.MakeTestContext(), | ||
RepositoryConfig{ | ||
URL: remoteDir, | ||
Path: localDir, | ||
CommitterEmail: "[email protected]", | ||
CommitterName: "kuberpult", | ||
WriteCommitData: true, | ||
ArgoCdGenerateFiles: true, | ||
URL: remoteDir, | ||
Path: localDir, | ||
CommitterEmail: "[email protected]", | ||
CommitterName: "kuberpult", | ||
WriteCommitData: true, | ||
MaximumCommitsPerPush: 5, | ||
ArgoCdGenerateFiles: true, | ||
}, | ||
) | ||
if err != nil { | ||
|
@@ -6390,6 +6391,65 @@ func TestUpdateDatadogMetricsInternal(t *testing.T) { | |
} | ||
} | ||
|
||
func TestDatadogQueueMetric(t *testing.T) { | ||
tcs := []struct { | ||
Name string | ||
changes *TransformerResult | ||
transformers []Transformer | ||
expectedGauges int | ||
}{ | ||
{ | ||
Name: "Changes are sent as one event", | ||
transformers: []Transformer{ | ||
&CreateEnvironment{ | ||
Environment: "envA", | ||
Config: config.EnvironmentConfig{Upstream: &config.EnvironmentConfigUpstream{Latest: true}}, | ||
}, | ||
&CreateApplicationVersion{ | ||
Application: "app1", | ||
Manifests: map[string]string{ | ||
"envA": "envA-manifest-1", | ||
}, | ||
WriteCommitData: false, | ||
}, | ||
&CreateApplicationVersion{ | ||
Application: "app2", | ||
Manifests: map[string]string{ | ||
"envA": "envA-manifest-2", | ||
}, | ||
WriteCommitData: false, | ||
}, | ||
}, | ||
expectedGauges: 2, | ||
}, | ||
} | ||
for _, tc := range tcs { | ||
tc := tc | ||
t.Run(tc.Name, func(t *testing.T) { | ||
//t.Parallel() // do not run in parallel because of the global var `ddMetrics`! | ||
ctx := WithTimeNow(testutil.MakeTestContext(), time.Unix(0, 0)) | ||
var mockClient = &MockClient{} | ||
var client statsd.ClientInterface = mockClient | ||
ddMetrics = client | ||
repo := setupRepositoryTest(t) | ||
|
||
err := repo.Apply(ctx, tc.transformers...) | ||
|
||
if err != nil { | ||
t.Fatalf("Expected no error: %v", err) | ||
} | ||
|
||
if tc.expectedGauges != len(mockClient.gauges) { | ||
// Don't compare the value of the gauge, only the number of gauges, | ||
// because we cannot be sure at this point what the size of the queue was during measurement | ||
msg := fmt.Sprintf("expected %d gauges but got %d\n", | ||
tc.expectedGauges, len(mockClient.gauges)) | ||
t.Fatalf(msg) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestUpdateDatadogEventsInternal(t *testing.T) { | ||
tcs := []struct { | ||
Name string | ||
|