-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEATURE: telemetry events from devtron #517
Conversation
return nil, err | ||
} | ||
|
||
_, err = cron.AddFunc(fmt.Sprintf("@every %dm", 1), watcher.HeartbeatEventForTelemetry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if orchestrator bounces timer will get reset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case we can get more than one event for heartbeat is this will create problem ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved
|
||
func (impl *TelemetryEventClientImpl) HeartbeatEventForTelemetry() { | ||
impl.logger.Info(">>>>>>>>>>VIKI startup heartbeat event ") | ||
clusterBean, err := impl.clusterService.FindOne(cluster.ClusterName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache this value in memory
|
||
func (impl AppListingRepositoryImpl) FindAppCount(isProd bool) (int, error) { | ||
var count int | ||
query := "SELECT count(distinct pipeline.app_id) from pipeline pipeline " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use ORM query instead of native
client/telemetry/PosthogClient.go
Outdated
cfg := &PosthogConfig{} | ||
err := env.Parse(cfg) | ||
if err != nil { | ||
logger.Error("err", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proper stack-trace will not be printed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.Errorw("exception caught while parsing posthog config", "err", err)
done
ciPipelineRepository: ciPipelineRepository, pipelineRepository: pipelineRepository, | ||
} | ||
watcher.HeartbeatEventForTelemetry() | ||
_, err := cron.AddFunc(fmt.Sprintf("@every %dm", 5), watcher.SummeryEventForTelemetry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make duration configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return | ||
} | ||
cm, err := impl.K8sUtil.GetConfigMap(impl.aCDAuthConfig.ACDConfigMapNamespace, DevtronUniqueClientIdConfigMap, client) | ||
if err != nil && strings.Contains(err.Error(), "not found") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have some error codes available to identify not found?
we should be using that instead of not found string match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return | ||
} | ||
|
||
client, err := impl.K8sUtil.GetClientForIncluster(cfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
impl.PosthogClient.Client.Enqueue(posthog.Capture{ | ||
DistinctId: ucid, | ||
Event: fmt.Sprintf("heartbeat event sent from devtron"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use short keywords as event name, filtering will be easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
}) | ||
} | ||
|
||
type CronLoggerImpl struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we are using derived logger class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required here, removed
internal/util/K8sUtil.go
Outdated
// creates the in-cluster config | ||
config, err := rest.InClusterConfig() | ||
if err != nil { | ||
panic(err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
panic from code, is it intended ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error logged, returned error
Description
telemetry events such as Summary (app total count, user count total, env n cluster count total, ci and cd daily runs count, helm charts total count, s scan runs daily) or Heatbeat events sent to posthog.
Fixes # (issue): #407
Type of change
How Has This Been Tested?
Checklist: