Skip to content

Commit

Permalink
Merge pull request #6415 from TheThingsNetwork/issue/6081-enable-tele…
Browse files Browse the repository at this point in the history
…metry-default-cfg

Enable telemetry
  • Loading branch information
nicholaspcr authored Aug 14, 2023
2 parents 57b8045 + 25f52a5 commit e618399
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ For details about compatibility between different releases, see the **Commitment

- Add support for `administrative_contact` and `technical_contact` in the Console.
- Reimplement move away prompt in payload formatter views in the Console.
- Add telemetry collection for the CLI. A background process was added to the CLI in order to send the following information: Operating System, Architecture, Binary version and Golang version. The message is sent every 24 hours and it contains an unique random number as an identifier. It is enabled by default and in order to disable it, set `telemetry.enable` to false in the CLI configuration. For more information, consult the documentation [here](https://www.thethingsindustries.com/docs/reference/telemetry/cli).
- Add telemetry collection for the IdentityServer. A background task was added in the Identity Server which is responsible for collecting information regarding the amount of each entity in the database, this has the purpose of allowing us to better understand how users are interacting with the system, an example being if tenants are using Organizations or just Users. All information is sent every 24 hours and it contains an identifier composed of the URLs present in the following configuration fields `console.ui.[is|gs|ns|as|js].base-url`. It is enabled by default and in order to disable it, set `telemetry.enable` to false in the Stack configuration. For more information, consult the documentation [here](https://www.thethingsindustries.com/docs/reference/telemetry/identity_server).

### Changed

Expand Down
8 changes: 3 additions & 5 deletions cmd/internal/shared/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,11 @@ var DefaultTracingConfig = tracing.Config{

// DefaultTelemetryConfig is the default config for telemetry.
var DefaultTelemetryConfig = telemetry.Config{
// TODO: After (https://github.com/TheThingsNetwork/lorawan-stack/issues/6081) is no longer blocked.
// Enable the telemetry and define the target.
Enable: false,
Target: "",
Enable: true,
Target: "https://telemetry.thethingsstack.io/collect",
NumConsumers: 1,
EntityCountTelemetry: telemetry.EntityCountTelemetry{
Enable: false,
Enable: true,
Interval: 24 * time.Hour,
},
}
Expand Down
6 changes: 2 additions & 4 deletions cmd/ttn-lw-cli/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ var (
EnableMetadata: true,
}
defaultTelemetryConfig = telemetry.CLI{
// TODO: After (https://github.com/TheThingsNetwork/lorawan-stack/issues/6081) is no longer blocked.
// Enable the telemetry and define the target.
Enable: false,
Target: "",
Enable: true,
Target: "https://telemetry.thethingsstack.io/collect",
}
)

Expand Down
3 changes: 3 additions & 0 deletions cmd/ttn-lw-cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ func preRun(tasks ...func() error) func(cmd *cobra.Command, args []string) error
// The result is waited in the post run.
telemetrySubmission = make(chan struct{})
if config.Telemetry.Enable {
logger.
WithField("documentation_url", "https://www.thethingsindustries.com/docs/reference/telemetry/cli").
Info("Telemetry is enabled. Check the documentation for more information on what is collected and how to disable it") // nolint:lll
go func(ctx context.Context) {
defer close(telemetrySubmission)
cli.NewCLITelemetry(
Expand Down
3 changes: 3 additions & 0 deletions pkg/identityserver/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func (is *IdentityServer) initializeTelemetryTasks(ctx context.Context) error {
if tq == nil || !tmCfg.Enable {
return nil
}
logger.
WithField("documentation_url", "https://www.thethingsindustries.com/docs/reference/telemetry/identity_server").
Info("Identity Server telemetry is enabled. Check the documentation for more information on what is collected and how to disable it") // nolint:lll

hostname, err := os.Hostname()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/telemetry/exporter/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"path"
"time"

uuid "github.com/satori/go.uuid"
"github.com/google/uuid"
"go.thethings.network/lorawan-stack/v3/pkg/log"
telemetry "go.thethings.network/lorawan-stack/v3/pkg/telemetry/exporter"
"go.thethings.network/lorawan-stack/v3/pkg/telemetry/exporter/models"
Expand Down Expand Up @@ -106,7 +106,7 @@ func getCLIState() (*cliStateTelemetry, bool, error) {
return nil, false, err
}

cliState.UID = uuid.NewV4().String()
cliState.UID = uuid.NewString()
cliState.LastSent = time.Now()
return cliState, true, nil
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/telemetry/exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ type EntityCountTelemetry struct {

// Config contains information regarding the telemetry collection.
type Config struct {
Enable bool `name:"enable" description:"Enables telemetry collection"`
// UIDElements is a list of elements that will be used to generate the UID.
UIDElements []string `name:"-"`
Enable bool `name:"enable" description:"Enables telemetry collection"`
Target string `name:"target" description:"Target to which the information will be sent to"` // nolint:lll
UIDElements []string `name:"uid-elements" description:"Elements that will be used to generate the UID"` // nolint:lll
NumConsumers uint64 `name:"num-consumers" description:"Number of consumers that will be used to monitor telemetry related tasks"` // nolint:lll
EntityCountTelemetry EntityCountTelemetry `name:"entity-count-telemetry"`
}

0 comments on commit e618399

Please sign in to comment.