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

Config, newrelic setup, and installation cleanup. #1053

Merged
merged 4 commits into from
May 20, 2024
Merged
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ go.work*
atrium/vestibulum/trcchatproxy/.vscode/*
atrium/plugins/*
atrium/.vscode/*

installation/trclocal/tls/cert.*

installation/trclocal/trchelloworld/deploy/*

installation/trccarrier/deploy/
installation/trccarrier/trc_seeds/


2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ See [Contributing](CONTRIBUTING.MD).
Check the [code review](CODE_REVIEW.MD) information to find out how a **Pull Request** is evaluated for this project and what other coding standards you should consider when you want to contribute.

## Current effort
Usability enhancements. Tierceron can do a lot of things. Some features are very easy to set up and use, others not so much. Contributions welcomed!
Titrating. Tierceron can do a lot of things. Some features are very easy to set up and use, others not so much. Contributions welcomed!
11 changes: 8 additions & 3 deletions atrium/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ harbingplugintrcdbsha:
harbinger: harbingplugintrcdbbuild harbingplugintrcdbsha

certify:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(GOBIN)/trcplgtool -tags "memonly azrcr" github.com/trimble-oss/tierceron/atrium/vestibulum/cmd/trcplgtool
trcshell:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(GOBIN)/trcsh -tags "memonly" github.com/trimble-oss/tierceron/atrium/vestibulum/shell/trcsh
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(GOBIN)/trcplgtool -tags "memonly azrcr" github.com/trimble-oss/tierceron/atrium/vestibulum/cmd/trcplgtool

trcshellbuild:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o plugins/deploy/target/trcsh -tags "memonly" github.com/trimble-oss/tierceron/atrium/vestibulum/shell/trcsh
trcshellsha:
sha256sum plugins/deploy/target/trcsh | cut -d' ' -f1 > plugins/deploy/target/trcsh.sha256
trcshell: trcshellbuild trcshellsha

trcshellwin:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) GOOS=windows GOARCH=amd64 go build -tags "tc windows azrcr memonly" -o $(GOBIN)/trcsh.exe github.com/trimble-oss/tierceron/atrium/vestibulum/shell/trcsh

Expand Down
39 changes: 39 additions & 0 deletions atrium/vestibulum/pluginutil/pluginutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ package pluginutil

import (
"errors"
"log"
"os"

"github.com/newrelic/go-agent/v3/integrations/logcontext-v2/logWriter"
"github.com/newrelic/go-agent/v3/newrelic"
eUtils "github.com/trimble-oss/tierceron/pkg/utils"
"github.com/trimble-oss/tierceron/pkg/vaulthelper/kv"
)

Expand All @@ -16,3 +21,37 @@ func GetPluginCertifyMap(mod *kv.Modifier, pluginConfig map[string]interface{})
}
return nil, errors.New("missing plugin name for configuration")
}

func PluginInitNewRelic(driverConfig *eUtils.DriverConfig, mod *kv.Modifier, pluginConfig map[string]interface{}) {
certifyConfig, certifyErr := GetPluginCertifyMap(mod, pluginConfig)
if certifyErr == nil {
driverConfig.CoreConfig.Log.Printf("Found certification for plugin: %s Env: %s", pluginConfig["pluginName"], pluginConfig["env"])
if newrelic_app_name, ok := certifyConfig["newrelic_app_name"].(string); ok && len(newrelic_app_name) > 0 {
if newrelicLicenseKey, ok := certifyConfig["newrelic_license_key"].(string); ok {
driverConfig.CoreConfig.Log.Println("Setting up newrelic...")
app, err := newrelic.NewApplication(
newrelic.ConfigAppName(newrelic_app_name),
newrelic.ConfigLicense(newrelicLicenseKey),
newrelic.ConfigDistributedTracerEnabled(true),
newrelic.ConfigAppLogForwardingEnabled(true),
newrelic.ConfigDebugLogger(os.Stdout),
newrelic.ConfigInfoLogger(os.Stdout),
)

if err != nil {
driverConfig.CoreConfig.Log.Println("Error setting up newrelic:", err)
os.Exit(-1)
}

driverConfig.CoreConfig.Log = log.New(logWriter.New(driverConfig.CoreConfig.Log.Writer(), app), "["+pluginConfig["pluginName"].(string)+"]", log.LstdFlags)
driverConfig.CoreConfig.Log.Println("Newrelic configured...")
} else {
driverConfig.CoreConfig.Log.Println("Missing license key for newrelic. Continue without newrelic.")
}
} else {
driverConfig.CoreConfig.Log.Println("Missing app name for newrelic. Continue without newrelic.")
}
} else {
driverConfig.CoreConfig.Log.Println("No pluginName provided for newrelic configuration. Continue without newrelic.")
}
}
10 changes: 6 additions & 4 deletions atrium/vestibulum/trccarrier/carrierfactory/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func Init(processFlowConfig trcvutils.ProcessFlowConfig, processFlowInit trcvuti

// Range over all plugins and init them... but only once!
for _, pluginName := range pluginEnvConfig["pluginNameList"].([]string) {
logger.Printf("Initializing plugin: %s\n", pluginName)
pluginEnvConfigClone := make(map[string]interface{})
logger.Printf("Cloning %d..\n", len(pluginEnvConfig))
for k, v := range pluginEnvConfig {
Expand All @@ -109,10 +110,10 @@ func Init(processFlowConfig trcvutils.ProcessFlowConfig, processFlowInit trcvuti
logger.Printf("Cloned %d..\n", len(pluginEnvConfigClone))

pluginEnvConfigClone["trcplugin"] = pluginName
logger.Println("*****Env: " + pluginEnvConfig["env"].(string) + " plugin: " + pluginEnvConfigClone["trcplugin"].(string))
logger.Println("*****Env: " + pluginEnvConfigClone["env"].(string) + " plugin: " + pluginEnvConfigClone["trcplugin"].(string))
pecError := ProcessPluginEnvConfig(processFlowConfig, processFlow, pluginEnvConfigClone, configCompleteChan)
if pecError != nil {
logger.Println("Bad configuration data for env: " + pluginEnvConfig["env"].(string) + " and plugin: " + pluginName + " error: " + pecError.Error())
logger.Println("Bad configuration data for env: " + pluginEnvConfigClone["env"].(string) + " and plugin: " + pluginName + " error: " + pecError.Error())
}
}

Expand Down Expand Up @@ -363,9 +364,10 @@ func ProcessPluginEnvConfig(processFlowConfig trcvutils.ProcessFlowConfig,
}
}
}
logger.Println("Init: " + pluginEnvConfig["env"].(string) + " plugin: " + pluginEnvConfig["trcplugin"].(string))

go func(pec map[string]interface{}, l *log.Logger) {
logger.Println("Begin processFlows for env: " + pec["env"].(string) + " plugin: " + pec["trcplugin"].(string))
logger.Println("Initiate process flow for env: " + pec["env"].(string) + " and plugin: " + pec["trcplugin"].(string))

flowErr := processPluginFlow(pec, l)
if configCompleteChan != nil {
Expand All @@ -376,7 +378,7 @@ func ProcessPluginEnvConfig(processFlowConfig trcvutils.ProcessFlowConfig,
}
}(pluginEnvConfig, logger)

logger.Println("End processFlows for env: " + env.(string))
logger.Println("ProcessPluginEnvConfig ended and initiated for env: " + env.(string))

return nil
}
Expand Down
225 changes: 0 additions & 225 deletions atrium/vestibulum/trcdb/deploy/deploy.sh

This file was deleted.

Loading