Skip to content

Commit

Permalink
Move to single database for the various telemetry staging data
Browse files Browse the repository at this point in the history
Main changes includes:
1. Using a single database with multiple tables for the
items, bundles and reports. Seperate structs have been
defined for the database mapping.
Reduce the overhead with multiple levels of marshalling/unmarshalling.
2. Update the unittests accordingly
3. Remove extractor component from the library since
the telemetry-server will no longer use this implementation
of the extractor.
4. Also define a default configuration and add unitests for config.go
5. Remove the authtoken from the report structure
  • Loading branch information
mbelur committed May 24, 2024
1 parent c6e9eed commit ad72044
Show file tree
Hide file tree
Showing 27 changed files with 1,148 additions and 1,243 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@

# Go workspace file
go.work

#
# From github/gitignore/Global/VisualStudioCode.gitignore
#
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets


4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ The pkg/types module defined useful common types
The pkg/lib module provides functionality for managing the local staging
of data items, bundles and reports.

## internal/pkg/datastore
The internal/pkg/datastore implement general purpose datastore used for
local staging of telemetry objects.

# See Also
See the companion telemetry-server repo for a basic implementation of
a telemetry server to handle the requests generated by the telemetry
Expand Down
2 changes: 1 addition & 1 deletion cmd/clientds/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/SUSE/telemetry/cmd/clientds

go 1.21.9
go 1.21

replace github.com/SUSE/telemetry => ../../../telemetry

Expand Down
33 changes: 16 additions & 17 deletions cmd/clientds/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ var opts options
func main() {
fmt.Printf("clientds: %s\n", opts)

cfg := config.NewConfig(opts.config)
err := cfg.Load()
cfg, err := config.NewConfig(opts.config)
if err != nil {
log.Fatal(err)
}
Expand All @@ -41,46 +40,46 @@ func main() {
processor := tc.Processor()

if opts.items {
items, err := processor.GetDataItems()
itemRows, err := processor.GetDataItemRows()
if err != nil {
log.Fatal(err.Error())
}

itemCount := len(items)
itemCount := len(itemRows)
if itemCount > 0 {
fmt.Printf("%d Telemetry data items found.\n", len(items))
for i, dataItem := range items {
fmt.Printf("Data Item[%d]: %q\n", i, dataItem.Key())
fmt.Printf("%d Telemetry data items found.\n", len(itemRows))
for i, dataItemRow := range itemRows {
fmt.Printf("Data Item[%d]: %q\n", i, dataItemRow.ItemId)
}
}
}

if opts.bundles {
bundles, err := processor.GetBundles()
bundleRows, err := processor.GetBundleRows()
if err != nil {
log.Fatal(err.Error())
}

bundleCount := len(bundles)
bundleCount := len(bundleRows)
if bundleCount > 0 {
fmt.Printf("%d Telemetry bundles found.\n", len(bundles))
for i, bundle := range bundles {
fmt.Printf("Bundle[%d]: %q\n", i, bundle.Key())
fmt.Printf("%d Telemetry bundles found.\n", len(bundleRows))
for i, bundleRow := range bundleRows {
fmt.Printf("Bundle[%d]: %q\n", i, bundleRow.BundleId)
}
}
}

if opts.reports {
reports, err := processor.GetReports()
reportRows, err := processor.GetReportRows()
if err != nil {
log.Fatal(err.Error())
}

reportCount := len(reports)
reportCount := len(reportRows)
if reportCount > 0 {
fmt.Printf("%d Telemetry reports found.\n", len(reports))
for i, report := range reports {
fmt.Printf("Reports[%d]: %q\n", i, report.Key())
fmt.Printf("%d Telemetry reports found.\n", len(reportRows))
for i, reportRow := range reportRows {
fmt.Printf("Reports[%d]: %q\n", i, reportRow.ReportId)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/generator/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/SUSE/telemetry/cmd/generator

go 1.21.0
go 1.21

replace github.com/SUSE/telemetry => ../../

Expand Down
3 changes: 1 addition & 2 deletions cmd/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ var opts options
func main() {
fmt.Printf("Generator: %s\n", opts)

cfg := config.NewConfig(opts.config)
err := cfg.Load()
cfg, err := config.NewConfig(opts.config)
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions examples/config/telemetry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ enabled: true
customer_id: 1234567890
tags: []
datastores:
items: sqlite3:/tmp/telemetry/client/itemstore.db
bundles: sqlite3:/tmp/telemetry/client/bundlestore.db
reports: sqlite3:/tmp/telemetry/client/reportstore.db
driver: sqlite3
params: /tmp/telemetry/client/telemetry.db
extras:
some: thing
else:
Expand Down
115 changes: 0 additions & 115 deletions internal/pkg/datastore/datastore.go

This file was deleted.

115 changes: 0 additions & 115 deletions internal/pkg/datastore/datastore_test.go

This file was deleted.

Loading

0 comments on commit ad72044

Please sign in to comment.