Skip to content

Commit

Permalink
Adding Glitchtip configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Drobena committed Jul 31, 2024
1 parent 4f60957 commit f23fc66
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 6 deletions.
14 changes: 13 additions & 1 deletion cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"

"github.com/RedHatInsights/insights-operator-utils/logger"
"github.com/olekukonko/tablewriter"
)

Expand Down Expand Up @@ -429,7 +430,18 @@ func main() {
if config.Logging.Debug {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
}

if config.Logging.LoggingToSentryEnabled {
err = logger.InitZerolog(
config.Logging,
logger.CloudWatchConfiguration{},
config.Sentry,
logger.KafkaZerologConfiguration{},
)
if err != nil {
log.Error().Err(err).Msg("Unable to init ZeroLog")
}
}
log.Error().Msg("TEST CLEANER ERROR")
log.Debug().Msg("Started")

// override default value read from configuration file
Expand Down
3 changes: 2 additions & 1 deletion cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/tisnik/go-capture"

"github.com/RedHatInsights/insights-operator-utils/logger"
cleaner "github.com/RedHatInsights/insights-results-aggregator-cleaner"
main "github.com/RedHatInsights/insights-results-aggregator-cleaner"
)
Expand Down Expand Up @@ -84,7 +85,7 @@ func TestShowConfiguration(t *testing.T) {
PGHost: "baz",
PGDBName: "aggregator",
PGParams: ""}
configuration.Logging = main.LoggingConfiguration{
configuration.Logging = logger.LoggingConfiguration{
Debug: true,
LogLevel: ""}
configuration.Cleaner = main.CleanerConfiguration{
Expand Down
16 changes: 12 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import (
"strings"

"github.com/BurntSushi/toml"
"github.com/RedHatInsights/insights-operator-utils/logger"
clowder "github.com/redhatinsights/app-common-go/pkg/api/v1"

"path/filepath"
Expand All @@ -91,9 +92,10 @@ const (

// ConfigStruct is a structure holding the whole service configuration
type ConfigStruct struct {
Storage StorageConfiguration `mapstructure:"storage" toml:"storage"`
Logging LoggingConfiguration `mapstructure:"logging" toml:"logging"`
Cleaner CleanerConfiguration `mapstructure:"cleaner" toml:"cleaner"`
Storage StorageConfiguration `mapstructure:"storage" toml:"storage"`
Logging logger.LoggingConfiguration `mapstructure:"logging" toml:"logging"`
Cleaner CleanerConfiguration `mapstructure:"cleaner" toml:"cleaner"`
Sentry logger.SentryLoggingConfiguration `mapstructure:"sentry" toml:"sentry"`
}

// LoggingConfiguration represents configuration for logging in general
Expand All @@ -114,6 +116,7 @@ type LoggingConfiguration struct {
// LoggingToCloudWatchEnabled enables logging to CloudWatch
// (configuration for CloudWatch is in CloudWatchConfiguration)
LoggingToCloudWatchEnabled bool `mapstructure:"logging_to_cloud_watch_enabled" toml:"logging_to_cloud_watch_enabled"`
LoggingToSentryEnabled bool `mapstructure:"logging_to_sentry_enabled" toml:"logging_to_sentry_enabled"`
}

// CleanerConfiguration represents configuration for the main cleaner
Expand Down Expand Up @@ -219,10 +222,15 @@ func GetStorageConfiguration(config *ConfigStruct) StorageConfiguration {
}

// GetLoggingConfiguration function returns logging configuration
func GetLoggingConfiguration(config *ConfigStruct) LoggingConfiguration {
func GetLoggingConfiguration(config *ConfigStruct) logger.LoggingConfiguration {
return config.Logging
}

// GetSentryConfiguration function returns sentry configuration
func GetSentryConfiguration(config *ConfigStruct) logger.SentryLoggingConfiguration {
return config.Sentry
}

// GetCleanerConfiguration returns cleaner configuration
func GetCleanerConfiguration(config *ConfigStruct) CleanerConfiguration {
return config.Cleaner
Expand Down
5 changes: 5 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ schema = "ocp_recommendations"
[logging]
debug = true
log_level = ""
logging_to_sentry_enabled = true

[sentry]
dsn = "https://[email protected]/97"
environment = "dev"

[cleaner]
max_age = "90 days"
Expand Down
12 changes: 12 additions & 0 deletions deploy/clowdapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ objects:
value: "${LOG_LEVEL}"
- name: INSIGHTS_RESULTS_CLEANER__CLEANER__MAX_AGE
value: "${MAX_AGE}"
- name: INSIGHTS_RESULTS_CLEANER__LOGGING__LOGGING_TO_SENTRY_ENABLED
value: ${SENTRY_ENABLED}
- name: INSIGHTS_RESULTS_CLEANER__SENTRY__DSN
valueFrom:
secretKeyRef:
key: dsn
name: insights-results-aggregator-cleaner-dsn
optional: true
- name: INSIGHTS_RESULTS_CLEANER__SENTRY__ENVIRONMENT
value: ${ENV_NAME}
command:
- ./insights-results-aggregator-cleaner
- -dry-run=${DRY_RUN}
Expand Down Expand Up @@ -104,3 +114,5 @@ parameters:
- name: CLEANUP_ALL
description: If true (default), the program will be executed with the -cleanup-all argument, cleaning the database from old clusters
value: "true"
- name: SENTRY_ENABLED
value: "false"
23 changes: 23 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,34 @@ require (
)

require (
github.com/RedHatInsights/cloudwatch v0.0.0-20210111105023-1df2bdfe3291 // indirect
github.com/RedHatInsights/insights-results-types v1.3.23 // indirect
github.com/RedHatInsights/kafka-zerolog v1.0.0 // indirect
github.com/Shopify/sarama v1.27.1 // indirect
github.com/archdx/zerolog-sentry v1.8.2 // indirect
github.com/aws/aws-sdk-go v1.50.16 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitly/go-simplejson v0.5.0 // indirect
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getkin/kin-openapi v0.22.1 // indirect
github.com/getsentry/sentry-go v0.24.1 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jcmturner/gofork v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
Expand All @@ -39,13 +54,16 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mozillazg/request v0.8.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/segmentio/kafka-go v0.4.10 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand All @@ -54,13 +72,18 @@ require (
github.com/verdverm/frisby v0.0.0-20170604211311-b16556248a9a // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/h2non/gock.v1 v1.1.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/jcmturner/aescts.v1 v1.0.1 // indirect
gopkg.in/jcmturner/dnsutils.v1 v1.0.1 // indirect
gopkg.in/jcmturner/gokrb5.v7 v7.5.0 // indirect
gopkg.in/jcmturner/rpc.v1 v1.1.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit f23fc66

Please sign in to comment.