Skip to content

Commit

Permalink
version 1.1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramk committed May 23, 2019
1 parent 66367c8 commit 7405db4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.14
v1.1.16
33 changes: 18 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ import (
)

const (
nrLogDataset = "Log Messages"
nrErrorDataset = "Error Messages"
nrMetricsDataset = "Metric Messages"

// insightsMaxEvents = 500 // size of insights json insert packet
maxConnectionAttempts = 3
// nozzleVersion = "1.1.13"
pcfEventType = "PcfFirehoseEvent"
)

Expand Down Expand Up @@ -148,17 +142,17 @@ type EventFilters struct {
var filters EventFilters

func main() {
logger.Println("New Relic Firehose Nozzle")
if (os.Getenv("DEBUG") == "1" || os.Getenv("DEBUG") == "true" || os.Getenv("DEBUG") == "TRUE") {
debug = true
}
logger.Println("hello world!")

startHealthCheck()
// ------------------------------------------------------------------------
pcfConfig, err := config.Parse()
if err != nil {
panic(err)
}
//10-16-18 - logger.Println("port", pcfConfig.Port)

if debug {
logger.Printf("pcfConfig: %v\n", pcfConfig)
}
Expand Down Expand Up @@ -659,36 +653,30 @@ func transformEvent(cfEvent *events.Envelope, nrEvent map[string]interface{}, pc
switch *cfEvent.EventType {
case events.Envelope_HttpStartStop:
pcfCounters.httpStartStopEvents++
nrEvent["DatasetName"] = nrLogDataset
transformHttpStartStopEvent(cfEvent, nrEvent)

case events.Envelope_LogMessage:
pcfCounters.logMessageEvents++
nrEvent["DatasetName"] = nrLogDataset
transformLogMessage(cfEvent, nrEvent)

case events.Envelope_ContainerMetric:
pcfCounters.containerEvents++
nrEvent["DatasetName"] = nrMetricsDataset
transformContainerMetric(cfEvent, nrEvent)
//nrEvent["containerMetric"] = cfEvent.GetContainerMetric().String()

case events.Envelope_CounterEvent:
pcfCounters.counterEvents++
nrEvent["DatasetName"] = nrMetricsDataset
transformCounterEvent(cfEvent, nrEvent)
// nrEvent["counterEvent"] = cfEvent.GetCounterEvent().String()

case events.Envelope_ValueMetric:

pcfCounters.valueMetricEvents++
nrEvent["DatasetName"] = nrMetricsDataset
transformValueMetric(cfEvent, nrEvent)
//nrEvent["valueMetric"] = cfEvent.GetValueMetric().String()

case events.Envelope_Error:
pcfCounters.errors++
nrEvent["DatasetName"] = nrErrorDataset
transformErrorEvent(cfEvent, nrEvent)
//nrEvent["errorField"] = cfEvent.GetError().String()
if debug {
Expand Down Expand Up @@ -917,3 +905,18 @@ func splitString(value string, separator string) []string {
return filters
}

func startHealthCheck() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
go func() {
http.HandleFunc("/health", healthCheckHandler)
logger.Fatal(http.ListenAndServe(":" + port, nil))
}()
}

func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "I'm alive and well!")
}

0 comments on commit 7405db4

Please sign in to comment.