@@ -26,7 +26,7 @@ func TestOTelConfigFromEnv_Defaults(t *testing.T) {
2626 "OTEL_LOGS_EXPORTER" ,
2727 }
2828 for _ , env := range envVars {
29- os .Unsetenv (env )
29+ _ = os .Unsetenv (env )
3030 }
3131
3232 cfg := OTelConfigFromEnv ()
@@ -64,26 +64,26 @@ func TestOTelConfigFromEnv_Defaults(t *testing.T) {
6464// reads and parses all supported OTEL_* environment variables.
6565func TestOTelConfigFromEnv_CustomValues (t * testing.T ) {
6666 // Set all environment variables
67- os .Setenv ("OTEL_SERVICE_NAME" , "test-service" )
68- os .Setenv ("OTEL_SERVICE_VERSION" , "1.2.3" )
69- os .Setenv ("OTEL_EXPORTER_OTLP_PROTOCOL" , "http" )
70- os .Setenv ("OTEL_EXPORTER_OTLP_ENDPOINT" , "localhost:4318" )
71- os .Setenv ("OTEL_EXPORTER_OTLP_INSECURE" , "true" )
72- os .Setenv ("OTEL_TRACES_EXPORTER" , "otlp" )
73- os .Setenv ("OTEL_TRACES_SAMPLE_RATIO" , "0.5" )
74- os .Setenv ("OTEL_METRICS_EXPORTER" , "otlp" )
75- os .Setenv ("OTEL_LOGS_EXPORTER" , "otlp" )
67+ _ = os .Setenv ("OTEL_SERVICE_NAME" , "test-service" )
68+ _ = os .Setenv ("OTEL_SERVICE_VERSION" , "1.2.3" )
69+ _ = os .Setenv ("OTEL_EXPORTER_OTLP_PROTOCOL" , "http" )
70+ _ = os .Setenv ("OTEL_EXPORTER_OTLP_ENDPOINT" , "localhost:4318" )
71+ _ = os .Setenv ("OTEL_EXPORTER_OTLP_INSECURE" , "true" )
72+ _ = os .Setenv ("OTEL_TRACES_EXPORTER" , "otlp" )
73+ _ = os .Setenv ("OTEL_TRACES_SAMPLE_RATIO" , "0.5" )
74+ _ = os .Setenv ("OTEL_METRICS_EXPORTER" , "otlp" )
75+ _ = os .Setenv ("OTEL_LOGS_EXPORTER" , "otlp" )
7676
7777 defer func () {
78- os .Unsetenv ("OTEL_SERVICE_NAME" )
79- os .Unsetenv ("OTEL_SERVICE_VERSION" )
80- os .Unsetenv ("OTEL_EXPORTER_OTLP_PROTOCOL" )
81- os .Unsetenv ("OTEL_EXPORTER_OTLP_ENDPOINT" )
82- os .Unsetenv ("OTEL_EXPORTER_OTLP_INSECURE" )
83- os .Unsetenv ("OTEL_TRACES_EXPORTER" )
84- os .Unsetenv ("OTEL_TRACES_SAMPLE_RATIO" )
85- os .Unsetenv ("OTEL_METRICS_EXPORTER" )
86- os .Unsetenv ("OTEL_LOGS_EXPORTER" )
78+ _ = os .Unsetenv ("OTEL_SERVICE_NAME" )
79+ _ = os .Unsetenv ("OTEL_SERVICE_VERSION" )
80+ _ = os .Unsetenv ("OTEL_EXPORTER_OTLP_PROTOCOL" )
81+ _ = os .Unsetenv ("OTEL_EXPORTER_OTLP_ENDPOINT" )
82+ _ = os .Unsetenv ("OTEL_EXPORTER_OTLP_INSECURE" )
83+ _ = os .Unsetenv ("OTEL_TRACES_EXPORTER" )
84+ _ = os .Unsetenv ("OTEL_TRACES_SAMPLE_RATIO" )
85+ _ = os .Unsetenv ("OTEL_METRICS_EXPORTER" )
86+ _ = os .Unsetenv ("OTEL_LOGS_EXPORTER" )
8787 }()
8888
8989 cfg := OTelConfigFromEnv ()
@@ -139,11 +139,11 @@ func TestOTelConfigFromEnv_TracesSampleRatio(t *testing.T) {
139139 for _ , tt := range tests {
140140 t .Run (tt .name , func (t * testing.T ) {
141141 // Clear and set the env var
142- os .Unsetenv ("OTEL_TRACES_SAMPLE_RATIO" )
142+ _ = os .Unsetenv ("OTEL_TRACES_SAMPLE_RATIO" )
143143 if tt .envValue != "" {
144- os .Setenv ("OTEL_TRACES_SAMPLE_RATIO" , tt .envValue )
144+ _ = os .Setenv ("OTEL_TRACES_SAMPLE_RATIO" , tt .envValue )
145145 }
146- defer os .Unsetenv ("OTEL_TRACES_SAMPLE_RATIO" )
146+ defer func () { _ = os .Unsetenv ("OTEL_TRACES_SAMPLE_RATIO" ) }( )
147147
148148 cfg := OTelConfigFromEnv ()
149149
@@ -173,11 +173,11 @@ func TestOTelConfigFromEnv_InsecureFlag(t *testing.T) {
173173
174174 for _ , tt := range tests {
175175 t .Run (tt .name , func (t * testing.T ) {
176- os .Unsetenv ("OTEL_EXPORTER_OTLP_INSECURE" )
176+ _ = os .Unsetenv ("OTEL_EXPORTER_OTLP_INSECURE" )
177177 if tt .envValue != "" {
178- os .Setenv ("OTEL_EXPORTER_OTLP_INSECURE" , tt .envValue )
178+ _ = os .Setenv ("OTEL_EXPORTER_OTLP_INSECURE" , tt .envValue )
179179 }
180- defer os .Unsetenv ("OTEL_EXPORTER_OTLP_INSECURE" )
180+ defer func () { _ = os .Unsetenv ("OTEL_EXPORTER_OTLP_INSECURE" ) }( )
181181
182182 cfg := OTelConfigFromEnv ()
183183
@@ -369,7 +369,7 @@ func TestSetupOTelSDK(t *testing.T) {
369369 "OTEL_LOGS_EXPORTER" ,
370370 }
371371 for _ , env := range envVars {
372- os .Unsetenv (env )
372+ _ = os .Unsetenv (env )
373373 }
374374
375375 ctx := context .Background ()
0 commit comments