Skip to content

Commit 9106a3f

Browse files
authored
[Feature] [Platform] Allows to opt out in the Inventory Telemetry (#1980)
1 parent 5e666d9 commit 9106a3f

13 files changed

+77
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- (Bugfix) (DP) Propagate Timeout Across Subcommands
88
- (Maintenance) Bump Dependencies
99
- (Feature) (Platform) EventsV1 Integration
10+
- (Feature) (Platform) Allows to opt out in the Inventory Telemetry
1011

1112
## [1.3.1](https://github.com/arangodb/kube-arangodb/tree/1.3.1) (2025-10-07)
1213
- (Documentation) Add ArangoPlatformStorage Docs & Examples

docs/cli/arangodb_operator_platform.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Flags:
136136
--arango.insecure Arango Endpoint Insecure
137137
--arango.token string Arango JWT Token for Authentication
138138
-h, --help help for inventory
139+
--telemetry Enables Telemetry (default true)
139140
140141
Global Flags:
141142
--kubeconfig string Kubernetes Config File
@@ -165,6 +166,7 @@ Flags:
165166
--license.client.stage strings LicenseManager Stages (default [prd])
166167
--license.endpoint string LicenseManager Endpoint (default "license.arango.ai")
167168
--license.interval duration Interval of the license synchronization
169+
--telemetry Enables Telemetry (default true)
168170
169171
Global Flags:
170172
--kubeconfig string Kubernetes Config File

pkg/platform/flags.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ var (
170170
},
171171
}
172172

173+
flagTelemetry = cli.Flag[bool]{
174+
Name: "telemetry",
175+
Description: "Enables Telemetry",
176+
Default: true,
177+
}
178+
173179
flagRegistryUseCredentials = cli.Flag[bool]{
174180
Name: "registry.docker.credentials",
175181
Description: "Use Docker Credentials",

pkg/platform/inventory/aql.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,25 @@ import (
3333
ugrpc "github.com/arangodb/kube-arangodb/pkg/util/grpc"
3434
)
3535

36-
func ExecuteAQL(db string, aql string, bind map[string]any) Executor {
37-
return func(conn driver.Connection, out chan<- *Item) executor.RunFunc {
36+
func ExecuteTelemetryAQL(db string, aql string, bind map[string]any) Executor {
37+
return ExecuteAQL(db, aql, bind, true)
38+
}
39+
40+
func ExecuteBasicAQL(db string, aql string, bind map[string]any) Executor {
41+
return ExecuteAQL(db, aql, bind, false)
42+
}
43+
44+
func ExecuteAQL(db string, aql string, bind map[string]any, telemetry bool) Executor {
45+
return func(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc {
3846
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
47+
if telemetry {
48+
if !cfg.WithTelemetry() {
49+
log.Info("Telemetry disabled")
50+
return nil
51+
}
52+
log.Info("Collecting Telemetry details")
53+
}
54+
3955
c, err := driver.NewClient(driver.ClientConfig{Connection: async.NewConnectionAsyncWrapper(conn)})
4056
if err != nil {
4157
return err
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2025 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package inventory
22+
23+
type Configuration struct {
24+
Telemetry *bool
25+
}
26+
27+
func (c *Configuration) WithTelemetry() bool {
28+
if c == nil || c.Telemetry == nil {
29+
return true
30+
}
31+
return *c.Telemetry
32+
}

pkg/platform/inventory/fetcher.aql.timestamp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ import _ "embed"
2626
var queryTimestampAQL string
2727

2828
func init() {
29-
global.MustRegister("aql.timestamp", ExecuteAQL("_system", queryTimestampAQL, nil))
29+
global.MustRegister("aql.timestamp", ExecuteBasicAQL("_system", queryTimestampAQL, nil))
3030
}

pkg/platform/inventory/fetcher.deployment.id.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
)
3636

3737
func init() {
38-
global.MustRegister("deployment.id", func(conn driver.Connection, out chan<- *Item) executor.RunFunc {
38+
global.MustRegister("deployment.id", func(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc {
3939
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
4040
if handler := arangod.GetRequestWithTimeout[client.DeploymentID](ctx, globals.GetGlobals().Timeouts().ArangoD().Get(), conn, "_admin", "deployment", "id"); handler.Code() == goHttp.StatusOK {
4141
resp, err := handler.Response()

pkg/platform/inventory/fetcher.server.mode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
)
3535

3636
func init() {
37-
global.MustRegister("server.mode", func(conn driver.Connection, out chan<- *Item) executor.RunFunc {
37+
global.MustRegister("server.mode", func(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc {
3838
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
3939
resp := arangod.GetRequestWithTimeout[driver.ClusterHealth](ctx, globals.GetGlobals().Timeouts().ArangoD().Get(), conn, "_admin", "cluster", "health")
4040

pkg/platform/inventory/fetcher.server.version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
)
3535

3636
func init() {
37-
global.MustRegister("server.info", func(conn driver.Connection, out chan<- *Item) executor.RunFunc {
37+
global.MustRegister("server.info", func(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc {
3838
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
3939
resp, err := arangod.GetRequestWithTimeout[driver.VersionInfo](ctx, globals.GetGlobals().Timeouts().ArangoD().Get(), conn, "_api", "version").
4040
AcceptCode(goHttp.StatusOK).

pkg/platform/inventory/inventory.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333

3434
type Items []*Item
3535

36-
func FetchInventory(ctx context.Context, logger logging.Logger, threads int, conn driver.Connection) (Items, error) {
36+
func FetchInventory(ctx context.Context, logger logging.Logger, threads int, conn driver.Connection, cfg *Configuration) (Items, error) {
3737
var out []*Item
3838
done := make(chan struct{})
3939
in := make(chan *Item)
@@ -50,7 +50,7 @@ func FetchInventory(ctx context.Context, logger logging.Logger, threads int, con
5050
}
5151
}()
5252

53-
if err := executor.Run(ctx, logger, threads, runExecution(conn, in)); err != nil {
53+
if err := executor.Run(ctx, logger, threads, runExecution(conn, cfg, in)); err != nil {
5454
return nil, err
5555
}
5656

@@ -61,11 +61,11 @@ func FetchInventory(ctx context.Context, logger logging.Logger, threads int, con
6161
return out, nil
6262
}
6363

64-
func runExecution(conn driver.Connection, out chan<- *Item) executor.RunFunc {
64+
func runExecution(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc {
6565
return func(ctx context.Context, log logging.Logger, t executor.Thread, h executor.Handler) error {
6666
for _, executor := range global.Items() {
6767
log.Str("name", executor.K).Info("Starting executor")
68-
q := executor.V(conn, out)
68+
q := executor.V(conn, cfg, out)
6969

7070
h.RunAsync(ctx, q)
7171
}
@@ -76,7 +76,7 @@ func runExecution(conn driver.Connection, out chan<- *Item) executor.RunFunc {
7676
}
7777
}
7878

79-
type Executor func(conn driver.Connection, out chan<- *Item) executor.RunFunc
79+
type Executor func(conn driver.Connection, cfg *Configuration, out chan<- *Item) executor.RunFunc
8080

8181
func (i *Item) Validate() error {
8282
if i == nil {

0 commit comments

Comments
 (0)