Skip to content

Commit

Permalink
Adding node name and cluster to init (#254)
Browse files Browse the repository at this point in the history
* Adding node name and cluster to init

Signed-off-by: Amit Schendel <[email protected]>

* Adding test case

Signed-off-by: Amit Schendel <[email protected]>

---------

Signed-off-by: Amit Schendel <[email protected]>
  • Loading branch information
amitschendel authored Apr 15, 2024
1 parent c3034f7 commit 0465b91
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/exporters/http_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func InitHTTPExporter(config HTTPExporterConfig, clusterName string, nodeName st
}

return &HTTPExporter{
config: config,
ClusterName: clusterName,
NodeName: nodeName,
config: config,
httpClient: &http.Client{
Timeout: time.Duration(config.TimeoutSeconds) * time.Second,
},
Expand Down
4 changes: 3 additions & 1 deletion pkg/exporters/http_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,14 @@ func TestValidateHTTPExporterConfig(t *testing.T) {
// Test case: URL is not empty
exp, err := InitHTTPExporter(HTTPExporterConfig{
URL: "http://localhost:9093",
}, "", "")
}, "cluster", "node")
assert.NoError(t, err)
assert.Equal(t, "POST", exp.config.Method)
assert.Equal(t, 5, exp.config.TimeoutSeconds)
assert.Equal(t, 10000, exp.config.MaxAlertsPerMinute)
assert.Equal(t, map[string]string{}, exp.config.Headers)
assert.Equal(t, "cluster", exp.ClusterName)
assert.Equal(t, "node", exp.NodeName)

// Test case: Method is PUT
exp, err = InitHTTPExporter(HTTPExporterConfig{
Expand Down

0 comments on commit 0465b91

Please sign in to comment.