Skip to content

Commit

Permalink
fix: potential nil pointer in telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianKramm committed Dec 12, 2023
1 parent d55f103 commit 2d06691
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/telemetry/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,18 @@ func (d *DefaultCollector) RecordStatus(ctx context.Context) {
}

func (d *DefaultCollector) RecordStart(ctx context.Context) {
chartInfo := d.getChartInfo(ctx)
properties := map[string]interface{}{
"vcluster_version": SyncerVersion,
"vcluster_k8s_distro": d.getChartInfo(ctx).Name,
"vcluster_k8s_distro_version": d.getVirtualClusterVersion(),
"host_cluster_k8s_version": d.getHostClusterVersion(),
"os_arch": runtime.GOOS + "/" + runtime.GOARCH,
"helm_values": d.getChartInfo(ctx).Values,
"creation_method": d.config.InstanceCreator,
}
if chartInfo != nil {
properties["vcluster_k8s_distro"] = chartInfo.Name
properties["helm_values"] = chartInfo.Values
}

// build the event and record
propertiesRaw, _ := json.Marshal(properties)
Expand Down Expand Up @@ -231,7 +234,10 @@ func (d *DefaultCollector) RecordError(ctx context.Context, severity ErrorSeveri

// if panic or fatal we add the helm values
if severity == PanicSeverity || severity == FatalSeverity {
properties["helm_values"] = d.getChartInfo(ctx).Values
chartInfo := d.getChartInfo(ctx)
if chartInfo != nil {
properties["helm_values"] = chartInfo.Values
}
}

// build the event and record
Expand Down

0 comments on commit 2d06691

Please sign in to comment.