Skip to content

Commit

Permalink
Define common data points
Browse files Browse the repository at this point in the history
Problem:
Ensure that our Kubernetes-related projects share common telemetry
data points for consistency.

Solution:
- Define common data points type.
- Generate Attributes() methods to allow using the type with the
Exporter (to implement Exportable interface).

A project that uses the exporter library will also export the
defined data type.

CLOSES - #8
  • Loading branch information
pleshakov committed Feb 29, 2024
1 parent 3fc010d commit e852880
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
9 changes: 8 additions & 1 deletion pkg/telemetry/data_attributes_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ import (
func (d *Data) Attributes() []attribute.KeyValue {
var attrs []attribute.KeyValue

attrs = append(attrs, attribute.Int64("Nodes", d.Nodes))
attrs = append(attrs, attribute.String("ProjectName", d.ProjectName))
attrs = append(attrs, attribute.String("ProjectVersion", d.ProjectVersion))
attrs = append(attrs, attribute.String("ProjectArchitecture", d.ProjectArchitecture))
attrs = append(attrs, attribute.String("ClusterID", d.ClusterID))
attrs = append(attrs, attribute.String("ClusterVersion", d.ClusterVersion))
attrs = append(attrs, attribute.String("ClusterPlatform", d.ClusterPlatform))
attrs = append(attrs, attribute.String("DeploymentID", d.DeploymentID))
attrs = append(attrs, attribute.Int64("ClusterNodeCount", d.ClusterNodeCount))


return attrs
Expand Down
25 changes: 18 additions & 7 deletions pkg/telemetry/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,27 @@ import (
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

// Data includes common telemetry data points.
// FIXME(pleshakov): Define the data points.
// Currently, only one data point is added, for the only reason that we can make sure the generator
// generates code for a struct defined in this package.
// https://github.com/nginxinc/telemetry-exporter/issues/8 will define the actual data points.
// Data defines common telemetry data points for NGINX Kubernetes-related projects.
//
//go:generate go run -tags=generator github.com/nginxinc/telemetry-exporter/cmd/generator -type Data
type Data struct {
// Nodes is a number of nodes.
Nodes int64
// ProjectName is the name of the project.
ProjectName string
// ProjectVersion is the version of the project.
ProjectVersion string
// ProjectArchitecture is the architecture the project. For example, "amd64".
ProjectArchitecture string
// ClusterID is the unique id of the Kubernetes cluster where the project is installed.
// It is the UID of the `kube-system` Namespace.
ClusterID string
// ClusterVersion is the Kubernetes version of the cluster.
ClusterVersion string
// ClusterPlatform is the Kubernetes platform of the cluster.
ClusterPlatform string
// DeploymentID is the unique id of the project installation in the cluster.
DeploymentID string
// ClusterNodeCount is the number of nodes in the cluster.
ClusterNodeCount int64
}

// Exportable allows exporting telemetry data using the Exporter.
Expand Down

0 comments on commit e852880

Please sign in to comment.