Skip to content

Commit

Permalink
feat: add enabled flag for telemetry config
Browse files Browse the repository at this point in the history
  • Loading branch information
lvlcn-t committed Sep 10, 2024
1 parent a66acc9 commit deb04db
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,9 @@ api:
keyPath: mykey.key
# Configures the target manager
# Omitting this section will disable the target manager
# Configures the target manager.
targetManager:
# whether to enable the target manager. defaults to false
# whether to enable the target manager. (default: false)
enabled: true
# Defines which target manager to use.
type: gitlab
Expand Down Expand Up @@ -274,8 +273,9 @@ targetManager:
projectId: 18923
# Configures the telemetry exporter.
# Omitting this section will disable telemetry.
telemetry:
# Whether to enable telemetry. (default: false)
enabled: true
# The telemetry exporter to use.
# Options:
# grpc: Exports telemetry using OTLP via gRPC.
Expand Down Expand Up @@ -506,8 +506,8 @@ dns:
| ---------------- | ----------------- | ---------------------------------------------------------------------------- |
| `interval` | `duration` | Interval to perform the Traceroute check. |
| `timeout` | `duration` | Timeout for every hop. |
| `retry.count` | `integer` | Number of retries for the latency check. |
| `retry.delay` | `duration` | Initial delay between retries for the latency check. |
| `retry.count` | `integer` | Number of retries for the latency check. |
| `retry.delay` | `duration` | Initial delay between retries for the latency check. |
| `maxHops` | `integer` | Maximum number of hops to try before giving up. |
| `targets` | `list of objects` | List of targets to traceroute to. |
| `targets[].addr` | `string` | The address of the target to traceroute to. Can be an IP address or DNS name |
Expand Down
19 changes: 12 additions & 7 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ import (

type Config struct {
// SparrowName is the DNS name of the sparrow
SparrowName string `yaml:"name" mapstructure:"name"`
Loader LoaderConfig `yaml:"loader" mapstructure:"loader"`
Api api.Config `yaml:"api" mapstructure:"api"`
SparrowName string `yaml:"name" mapstructure:"name"`
// Loader is the configuration for the loader
Loader LoaderConfig `yaml:"loader" mapstructure:"loader"`
// Api is the configuration for the api server
Api api.Config `yaml:"api" mapstructure:"api"`
// TargetManager is the configuration for the target manager
TargetManager targets.TargetManagerConfig `yaml:"targetManager" mapstructure:"targetManager"`
Telemetry metrics.Config `yaml:"telemetry" mapstructure:"telemetry"`
// Telemetry is the configuration for the telemetry
Telemetry metrics.Config `yaml:"telemetry" mapstructure:"telemetry"`
}

// LoaderConfig is the configuration for loader
Expand All @@ -45,15 +49,15 @@ type LoaderConfig struct {
File FileLoaderConfig `yaml:"file" mapstructure:"file"`
}

// HttpLoaderConfig is the configuration
// for the specific http loader
// HttpLoaderConfig is the configuration for the http loader
type HttpLoaderConfig struct {
Url string `yaml:"url" mapstructure:"url"`
Token string `yaml:"token" mapstructure:"token"`
Timeout time.Duration `yaml:"timeout" mapstructure:"timeout"`
RetryCfg helper.RetryConfig `yaml:"retry" mapstructure:"retry"`
}

// FileLoaderConfig is the configuration for the file loader
type FileLoaderConfig struct {
Path string `yaml:"path" mapstructure:"path"`
}
Expand All @@ -63,6 +67,7 @@ func (c *Config) HasTargetManager() bool {
return c.TargetManager.Enabled
}

// HasTelemetry returns true if the config has telemetry enabled
func (c *Config) HasTelemetry() bool {
return c.Telemetry != metrics.Config{}
return c.Telemetry.Enabled
}
2 changes: 2 additions & 0 deletions pkg/sparrow/metrics/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (

// Config holds the configuration for OpenTelemetry
type Config struct {
// Enabled is a flag to enable or disable the OpenTelemetry
Enabled bool `yaml:"enabled" mapstructure:"enabled"`
// Exporter is the otlp exporter used to export the traces
Exporter Exporter `yaml:"exporter" mapstructure:"exporter"`
// Url is the Url of the collector to which the traces are exported
Expand Down

0 comments on commit deb04db

Please sign in to comment.