-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from raphaelkox/max-samples-variable
addded TransactionEvent.MaxSamplesStored as environment variable
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package restqlnewrelic | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/newrelic/go-agent/v3/newrelic" | ||
) | ||
|
||
const transactionEventsMaxSamples = "NEW_RELIC_TRANSACTION_EVENTS_MAX_SAMPLES_STORED" | ||
|
||
func ExtraConfigFromEnvironment() newrelic.ConfigOption { | ||
return extraConfigFromEnvironment(os.Getenv) | ||
} | ||
|
||
func extraConfigFromEnvironment(getenv func(string) string) newrelic.ConfigOption { | ||
return func(cfg *newrelic.Config) { | ||
// Because fields could have been assigned in a previous | ||
// ConfigOption, we only want to assign fields using environment | ||
// variables that have been populated. This is especially | ||
// relevant for the string case where no processing occurs. | ||
assignInt := func(field *int, name string) { | ||
if env := getenv(name); env != "" { | ||
if i, err := strconv.Atoi(env); nil != err { | ||
cfg.Error = fmt.Errorf("invalid %s value: %s", name, env) | ||
} else { | ||
*field = i | ||
} | ||
} | ||
} | ||
|
||
assignInt(&cfg.TransactionEvents.MaxSamplesStored, transactionEventsMaxSamples) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters