11// Unless explicitly stated otherwise all files in this repository are licensed
22// under the Apache License Version 2.0.
33// This product includes software developed at Datadog (https://www.datadoghq.com/).
4- // Copyright 2016 Datadog, Inc.
4+ // Copyright 2025 Datadog, Inc.
55
66package main
77
88import (
99 "net"
1010 "strconv"
1111
12+ gocontrolplane "github.com/DataDog/dd-trace-go/contrib/envoyproxy/go-control-plane/v2"
13+ "github.com/DataDog/dd-trace-go/v2/instrumentation"
1214 "github.com/DataDog/dd-trace-go/v2/instrumentation/env"
1315)
1416
@@ -17,13 +19,16 @@ import (
1719func intEnv (key string , def int ) int {
1820 vv , ok := env .Lookup (key )
1921 if ! ok {
22+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , def , instrumentation .TelemetryOriginDefault )
2023 return def
2124 }
2225 v , err := strconv .Atoi (vv )
2326 if err != nil {
2427 log .Warn ("Non-integer value for env var %s, defaulting to %d. Parse failed with error: %v" , key , def , err )
28+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , def , instrumentation .TelemetryOriginDefault )
2529 return def
2630 }
31+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , def , instrumentation .TelemetryOriginEnvVar )
2732 return v
2833}
2934
@@ -39,22 +44,25 @@ func intEnvNil(key string) *int {
3944 log .Warn ("Non-integer value for env var %s. Parse failed with error: %v" , key , err )
4045 return nil
4146 }
47+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , & v , instrumentation .TelemetryOriginEnvVar )
4248 return & v
4349}
4450
4551// IpEnv returns the valid IP value of an environment variable, or def otherwise.
4652func ipEnv (key string , def net.IP ) net.IP {
4753 vv , ok := env .Lookup (key )
4854 if ! ok {
55+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , def .String (), instrumentation .TelemetryOriginDefault )
4956 return def
5057 }
5158
5259 ip := net .ParseIP (vv )
5360 if ip == nil {
5461 log .Warn ("Non-IP value for env var %s, defaulting to %s" , key , def .String ())
62+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , def .String (), instrumentation .TelemetryOriginDefault )
5563 return def
5664 }
57-
65+ gocontrolplane . Instrumentation (). TelemetryRegisterAppConfig ( key , vv , instrumentation . TelemetryOriginEnvVar )
5866 return ip
5967}
6068
@@ -63,13 +71,16 @@ func ipEnv(key string, def net.IP) net.IP {
6371func boolEnv (key string , def bool ) bool {
6472 vv , ok := env .Lookup (key )
6573 if ! ok {
74+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , def , instrumentation .TelemetryOriginDefault )
6675 return def
6776 }
6877 v , err := strconv .ParseBool (vv )
6978 if err != nil {
7079 log .Warn ("Non-boolean value for env var %s, defaulting to %t. Parse failed with error: %v" , key , def , err )
80+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , def , instrumentation .TelemetryOriginDefault )
7181 return def
7282 }
83+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , v , instrumentation .TelemetryOriginEnvVar )
7384 return v
7485}
7586
@@ -78,7 +89,9 @@ func boolEnv(key string, def bool) bool {
7889func stringEnv (key , def string ) string {
7990 v , ok := env .Lookup (key )
8091 if ! ok {
92+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , v , instrumentation .TelemetryOriginDefault )
8193 return def
8294 }
95+ gocontrolplane .Instrumentation ().TelemetryRegisterAppConfig (key , v , instrumentation .TelemetryOriginEnvVar )
8396 return v
8497}
0 commit comments