|
9 | 9 | "github.com/hookdeck/outpost/internal/clickhouse"
|
10 | 10 | "github.com/hookdeck/outpost/internal/migrator"
|
11 | 11 | "github.com/hookdeck/outpost/internal/redis"
|
| 12 | + "github.com/hookdeck/outpost/internal/telemetry" |
| 13 | + "github.com/hookdeck/outpost/internal/version" |
12 | 14 | "github.com/joho/godotenv"
|
13 | 15 | "gopkg.in/yaml.v3"
|
14 | 16 | )
|
@@ -41,6 +43,7 @@ type Config struct {
|
41 | 43 | LogLevel string `yaml:"log_level" env:"LOG_LEVEL"`
|
42 | 44 | AuditLog bool `yaml:"audit_log" env:"AUDIT_LOG"`
|
43 | 45 | OpenTelemetry OpenTelemetryConfig `yaml:"otel"`
|
| 46 | + Telemetry TelemetryConfig `yaml:"telemetry"` |
44 | 47 |
|
45 | 48 | // API
|
46 | 49 | APIPort int `yaml:"api_port" env:"API_PORT"`
|
@@ -150,6 +153,14 @@ func (c *Config) InitDefaults() {
|
150 | 153 | ConsecutiveFailureCount: 20,
|
151 | 154 | AutoDisableDestination: true,
|
152 | 155 | }
|
| 156 | + |
| 157 | + c.Telemetry = TelemetryConfig{ |
| 158 | + Disabled: false, |
| 159 | + BatchSize: 100, |
| 160 | + BatchInterval: 5, |
| 161 | + HookdeckSourceURL: "https://hkdk.events/ih7t3hukydzlge", |
| 162 | + SentryDSN: "https://[email protected]/0", |
| 163 | + } |
153 | 164 | }
|
154 | 165 |
|
155 | 166 | func (c *Config) parseConfigFile(flagPath string, osInterface OSInterface) error {
|
@@ -325,6 +336,47 @@ func (c *Config) ConfigFilePath() string {
|
325 | 336 | return c.configPath
|
326 | 337 | }
|
327 | 338 |
|
| 339 | +type TelemetryConfig struct { |
| 340 | + Disabled bool `yaml:"disabled" env:"DISABLE_TELEMETRY"` |
| 341 | + BatchSize int `yaml:"batch_size" env:"TELEMETRY_BATCH_SIZE"` |
| 342 | + BatchInterval int `yaml:"batch_interval" env:"TELEMETRY_BATCH_INTERVAL"` |
| 343 | + HookdeckSourceURL string `yaml:"hookdeck_source_url" env:"TELEMETRY_HOOKDECK_SOURCE_URL"` |
| 344 | + SentryDSN string `yaml:"sentry_dsn" env:"TELEMETRY_SENTRY_DSN"` |
| 345 | +} |
| 346 | + |
| 347 | +func (c *TelemetryConfig) ToTelemetryConfig() telemetry.TelemetryConfig { |
| 348 | + return telemetry.TelemetryConfig{ |
| 349 | + Disabled: c.Disabled, |
| 350 | + BatchSize: c.BatchSize, |
| 351 | + BatchInterval: c.BatchInterval, |
| 352 | + HookdeckSourceURL: c.HookdeckSourceURL, |
| 353 | + SentryDSN: c.SentryDSN, |
| 354 | + } |
| 355 | +} |
| 356 | + |
| 357 | +func (c *Config) ToTelemetryApplicationInfo() telemetry.ApplicationInfo { |
| 358 | + portalEnabled := c.APIKey != "" && c.APIJWTSecret != "" |
| 359 | + |
| 360 | + entityStore := "redis" |
| 361 | + logStore := "TODO" |
| 362 | + if c.ClickHouse.Addr != "" { |
| 363 | + logStore = "clickhouse" |
| 364 | + } |
| 365 | + if c.PostgresURL != "" { |
| 366 | + logStore = "postgres" |
| 367 | + } |
| 368 | + |
| 369 | + return telemetry.ApplicationInfo{ |
| 370 | + Version: version.Version(), |
| 371 | + MQ: c.MQs.GetInfraType(), |
| 372 | + PortalEnabled: portalEnabled, |
| 373 | + EntityStore: entityStore, |
| 374 | + LogStore: logStore, |
| 375 | + } |
| 376 | +} |
| 377 | + |
| 378 | +// ===== Misc ===== |
| 379 | + |
328 | 380 | func (c *Config) ToMigratorOpts() migrator.MigrationOpts {
|
329 | 381 | return migrator.MigrationOpts{
|
330 | 382 | PG: migrator.MigrationOptsPG{
|
|
0 commit comments