mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-09-16 09:36:18 +02:00
Add New relic labels supoprt
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
## [Unreleased]
|
||||
### Add
|
||||
- Add support of 16-bit BMP.
|
||||
- Add `IMGPROXY_NEW_RELIC_LABELS` config.
|
||||
|
||||
### Fix
|
||||
- Fix trimming of CMYK images.
|
||||
|
@@ -132,6 +132,7 @@ var (
|
||||
|
||||
NewRelicAppName string
|
||||
NewRelicKey string
|
||||
NewRelicLabels map[string]string
|
||||
|
||||
PrometheusBind string
|
||||
PrometheusNamespace string
|
||||
@@ -287,6 +288,7 @@ func Reset() {
|
||||
|
||||
NewRelicAppName = ""
|
||||
NewRelicKey = ""
|
||||
NewRelicLabels = make(map[string]string)
|
||||
|
||||
PrometheusBind = ""
|
||||
PrometheusNamespace = ""
|
||||
@@ -458,6 +460,7 @@ func Configure() error {
|
||||
|
||||
configurators.String(&NewRelicAppName, "IMGPROXY_NEW_RELIC_APP_NAME")
|
||||
configurators.String(&NewRelicKey, "IMGPROXY_NEW_RELIC_KEY")
|
||||
configurators.StringMap(&NewRelicLabels, "IMGPROXY_NEW_RELIC_LABELS")
|
||||
|
||||
configurators.String(&PrometheusBind, "IMGPROXY_PROMETHEUS_BIND")
|
||||
configurators.String(&PrometheusNamespace, "IMGPROXY_PROMETHEUS_NAMESPACE")
|
||||
|
@@ -76,6 +76,26 @@ func StringSliceFile(s *[]string, filepath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func StringMap(m *map[string]string, name string) error {
|
||||
if env := os.Getenv(name); len(env) > 0 {
|
||||
mm := make(map[string]string)
|
||||
|
||||
keyvalues := strings.Split(env, ";")
|
||||
|
||||
for _, keyvalue := range keyvalues {
|
||||
parts := strings.SplitN(keyvalue, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
return fmt.Errorf("Invalid key/value: %s", keyvalue)
|
||||
}
|
||||
mm[parts[0]] = parts[1]
|
||||
}
|
||||
|
||||
*m = mm
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Bool(b *bool, name string) {
|
||||
if env, err := strconv.ParseBool(os.Getenv(name)); err == nil {
|
||||
*b = env
|
||||
|
@@ -350,6 +350,7 @@ imgproxy can send its metrics to New Relic. Specify your New Relic license key t
|
||||
|
||||
* `IMGPROXY_NEW_RELIC_KEY`: the New Relic license key
|
||||
* `IMGPROXY_NEW_RELIC_APP_NAME`: a New Relic application name. Default: `imgproxy`
|
||||
* `IMGPROXY_NEW_RELIC_LABELS`: the list of New Relic labels, semicolon divided. Example: `label1=value1;label2=value2`. Default: blank
|
||||
|
||||
Check out the [New Relic](new_relic.md) guide to learn more.
|
||||
|
||||
|
@@ -5,6 +5,7 @@ imgproxy can send its metrics to New Relic. To use this feature, do the followin
|
||||
1. Register at New Relic and get a license key.
|
||||
2. Set the `IMGPROXY_NEW_RELIC_KEY` environment variable to the license key.
|
||||
3. _(optional)_ Set the `IMGPROXY_NEW_RELIC_APP_NAME` environment variable to be the desired application name.
|
||||
4. _(optional)_ Set the `IMGPROXY_NEW_RELIC_LABELS` environment variable to be the desired list of labels. Example: `label1=value1;label2=value2`.
|
||||
|
||||
imgproxy will send the following info to New Relic:
|
||||
|
||||
|
@@ -33,6 +33,11 @@ func Init() error {
|
||||
newRelicApp, err = newrelic.NewApplication(
|
||||
newrelic.ConfigAppName(name),
|
||||
newrelic.ConfigLicense(config.NewRelicKey),
|
||||
func(c *newrelic.Config) {
|
||||
if len(config.NewRelicLabels) > 0 {
|
||||
c.Labels = config.NewRelicLabels
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user