Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

(GH-223) Implement UUID for telemetry #239

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/puppetlabs/pdkgo
go 1.16

require (
github.com/denisbrodbeck/machineid v1.0.1
github.com/hashicorp/go-version v1.3.0
github.com/json-iterator/go v1.1.12
github.com/mitchellh/go-homedir v1.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMSRhl4D7AQ=
github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
Expand Down
7 changes: 7 additions & 0 deletions pkg/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"runtime"

"github.com/denisbrodbeck/machineid"
"github.com/rs/zerolog/log"

"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -59,13 +60,19 @@ func Start(ctx context.Context, honeycomb_api_key string, honeycomb_dataset stri

tracer := otel.Tracer("pct")

uuid := attribute.Key("uuid")
osKey := attribute.Key("osinfo/os")
osArch := attribute.Key("osinfo/arch")

var span trace.Span
_, span = tracer.Start(ctx, "execution")
defer span.End()

// The Protected ID is hashed base on application name to prevent any
// accidental leakage of a reversable ID.
machineUUID, _ := machineid.ProtectedID("pdk")

span.SetAttributes(uuid.String(machineUUID))
span.SetAttributes(osKey.String(runtime.GOOS))
span.SetAttributes(osArch.String(runtime.GOARCH))
}