Skip to content

Commit

Permalink
feat: [TKC-2622] container env (#5886)
Browse files Browse the repository at this point in the history
* feat: container env

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>

* fix: add comment

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>

* fix: typo

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>

* fix: remove env detection

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>

* fix: map sio field

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>

---------

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
  • Loading branch information
vsukhin authored Oct 2, 2024
1 parent 6d220ef commit 4bfe8f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/telemetry/payload.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package telemetry

import (
"os"
"runtime"
"strings"

"github.com/kubeshop/testkube/pkg/utils"
"github.com/kubeshop/testkube/pkg/utils/text"
)

const runContextAgent = "agent"
const (
runContextAgent = "agent"
containerEnvKubernetes = "kubernetes"
)

type Params struct {
ErrorCode string `json:"error_code,omitempty"`
Expand Down Expand Up @@ -88,6 +92,7 @@ type RunContext struct {
Type string
OrganizationId string
EnvironmentId string
ContainerEnv string
}

type WorkflowParams struct {
Expand Down Expand Up @@ -340,6 +345,10 @@ func AnonymizeHost(host string) string {
func getAgentContext() RunContext {
orgID := utils.GetEnvVarWithDeprecation("TESTKUBE_PRO_ORG_ID", "TESTKUBE_CLOUD_ORG_ID", "")
envID := utils.GetEnvVarWithDeprecation("TESTKUBE_PRO_ENV_ID", "TESTKUBE_CLOUD_ENV_ID", "")
containerEnv := os.Getenv("TESTKUBE_CONTAINER_ENV")
if containerEnv == "" {
containerEnv = containerEnvKubernetes
}

if orgID == "" || envID == "" {
return RunContext{}
Expand All @@ -348,5 +357,6 @@ func getAgentContext() RunContext {
Type: runContextAgent,
EnvironmentId: envID,
OrganizationId: orgID,
ContainerEnv: containerEnv,
}
}
1 change: 1 addition & 0 deletions pkg/telemetry/sender_sio.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func mapProperties(name string, params Params) analytics.Properties {
Set("clusterId", params.ClusterID).
Set("eventCategory", params.EventCategory).
Set("host", params.Host).
Set("containerEnv", params.Context.ContainerEnv).
Set("contextType", params.Context.Type).
Set("cloudOrganizationId", params.Context.OrganizationId).
Set("cloudEnvironmentId", params.Context.EnvironmentId).
Expand Down

0 comments on commit 4bfe8f4

Please sign in to comment.