Skip to content

Commit

Permalink
report embedded cluster and k8s versions with metrics object (#1199)
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya authored Sep 23, 2024
1 parent c6a57a4 commit 3fe217d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/metrics/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/http"

"github.com/replicatedhq/embedded-cluster/pkg/versions"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -56,6 +57,10 @@ func (s *Sender) Send(ctx context.Context, ev Event) {

// payload returns the payload to be sent to the metrics endpoint.
func (s *Sender) payload(ev Event) ([]byte, error) {
payload := map[string]Event{"event": ev}
vmap := map[string]string{
"EmbeddedCluster": versions.Version,
"Kubernetes": versions.K0sVersion,
}
payload := map[string]interface{}{"event": ev, "versions": vmap}
return json.Marshal(payload)
}
2 changes: 1 addition & 1 deletion pkg/metrics/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestSend(t *testing.T) {
},
} {
t.Run(tt.name, func(t *testing.T) {
payload := map[string]Event{"event": tt.event}
payload := map[string]interface{}{"event": tt.event, "versions": map[string]string{"EmbeddedCluster": "v0.0.0", "Kubernetes": "0.0.0"}}
expected, err := json.Marshal(payload)
assert.NoError(t, err)
server := httptest.NewServer(
Expand Down

0 comments on commit 3fe217d

Please sign in to comment.