Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glitchtip config #339

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"errors"
"flag"
"fmt"
"github.com/RedHatInsights/insights-operator-utils/logger"
"os"
"strconv"
"strings"
Expand All @@ -51,7 +52,6 @@ import (

"github.com/google/uuid"

"github.com/rs/zerolog"
"github.com/rs/zerolog/log"

"github.com/olekukonko/tablewriter"
Expand Down Expand Up @@ -425,13 +425,17 @@ func main() {
log.Err(err).Msg("Check configuration")
return
}

if config.Logging.Debug {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
err = logger.InitZerolog(
GetLoggingConfiguration(&config),
logger.CloudWatchConfiguration{},
GetSentryConfiguration(&config),
logger.KafkaZerologConfiguration{},
)
if err != nil {
panic(err)
}

log.Debug().Msg("Started")

log.Error().Msg("test error for aggregator cleaner")
// override default value read from configuration file
if cliFlags.MaxAge != "" {
config.Cleaner.MaxAge = cliFlags.MaxAge
Expand All @@ -442,7 +446,6 @@ func main() {
if err != nil {
log.Err(err).Msg("Connection to database not established")
}

// perform selected operation
exitStatus, err := doSelectedOperation(&config, connection, cliFlags)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package main_test

import (
"errors"
"github.com/RedHatInsights/insights-operator-utils/logger"
"os"
"testing"
"time"
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
15 changes: 11 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ package main
import (
"bytes"
"fmt"
"github.com/RedHatInsights/insights-operator-utils/logger"
"os"
"strings"

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 Down Expand Up @@ -219,7 +221,7 @@ func GetStorageConfiguration(config *ConfigStruct) StorageConfiguration {
}

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

Expand All @@ -228,6 +230,11 @@ func GetCleanerConfiguration(config *ConfigStruct) CleanerConfiguration {
return config.Cleaner
}

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

// updateConfigFromClowder function updates the current config with the values
// defined in clowder
func updateConfigFromClowder(c *ConfigStruct) error {
Expand Down
12 changes: 12 additions & 0 deletions deploy/clowdapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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 @@ -105,3 +115,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: "true"
23 changes: 23 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,51 @@ require (
)

require (
github.com/RedHatInsights/cloudwatch v0.0.0-20210111105023-1df2bdfe3291 // indirect
github.com/RedHatInsights/insights-results-types v1.23.4 // 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.4 // indirect
github.com/aws/aws-sdk-go v1.55.5 // 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
github.com/mattn/go-runewidth v0.0.9 // indirect
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.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.48.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 @@ -53,13 +71,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
Loading