@@ -11,6 +11,7 @@ import (
1111 "testing"
1212 "time"
1313
14+ "github.com/gobwas/glob"
1415 "github.com/stretchr/testify/assert"
1516 "github.com/stretchr/testify/require"
1617
@@ -71,8 +72,11 @@ network:
7172 enable: true
7273 cidrs:
7374 - 10.244.0.0/16
75+ discovery:
76+ default_exclude_services:
77+ - exe_path: "*foo*"
7478` )
75- t .Setenv ("OTEL_EBPF_EXECUTABLE_NAME " , "tras" )
79+ t .Setenv ("OTEL_EBPF_EXECUTABLE_PATH " , "* tras* " )
7680 t .Setenv ("OTEL_EBPF_NETWORK_AGENT_IP" , "1.2.3.4" )
7781 t .Setenv ("OTEL_EBPF_OPEN_PORT" , "8080-8089" )
7882 t .Setenv ("OTEL_SERVICE_NAME" , "svc-name" )
@@ -212,7 +216,7 @@ network:
212216 ExcludeOTelInstrumentedServices : true ,
213217 DefaultExcludeServices : services.DefinitionCriteria {
214218 services.Attributes {
215- Path : services .NewPathRegexp ( regexp .MustCompile ("(?:^|/)(beyla$|alloy$|otelcol[^/]*$) " )),
219+ Path : services .NewGlob ( glob .MustCompile ("*foo* " )),
216220 },
217221 },
218222 },
@@ -237,15 +241,15 @@ func TestConfig_ShutdownTimeout(t *testing.T) {
237241
238242func TestConfigValidate (t * testing.T ) {
239243 testCases := []envMap {
240- {"OTEL_EXPORTER_OTLP_ENDPOINT" : "localhost:1234" , "OTEL_EBPF_EXECUTABLE_NAME " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" },
241- {"OTEL_EXPORTER_OTLP_METRICS_ENDPOINT" : "localhost:1234" , "OTEL_EBPF_EXECUTABLE_NAME " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" },
242- {"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" : "localhost:1234" , "OTEL_EBPF_EXECUTABLE_NAME " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" },
243- {"OTEL_EBPF_TRACE_PRINTER" : "text" , "OTEL_EBPF_SHUTDOWN_TIMEOUT" : "1m" , "OTEL_EBPF_EXECUTABLE_NAME " : "foo" },
244- {"OTEL_EBPF_TRACE_PRINTER" : "json" , "OTEL_EBPF_EXECUTABLE_NAME " : "foo" },
245- {"OTEL_EBPF_TRACE_PRINTER" : "json_indent" , "OTEL_EBPF_EXECUTABLE_NAME " : "foo" },
246- {"OTEL_EBPF_TRACE_PRINTER" : "counter" , "OTEL_EBPF_EXECUTABLE_NAME " : "foo" },
247- {"OTEL_EBPF_PROMETHEUS_PORT" : "8080" , "OTEL_EBPF_EXECUTABLE_NAME " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" },
248- {"OTEL_EBPF_INTERNAL_OTEL_METRICS" : "true" , "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT" : "localhost:1234" , "OTEL_EBPF_EXECUTABLE_NAME " : "foo" },
244+ {"OTEL_EXPORTER_OTLP_ENDPOINT" : "localhost:1234" , "OTEL_EBPF_EXECUTABLE_PATH " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" },
245+ {"OTEL_EXPORTER_OTLP_METRICS_ENDPOINT" : "localhost:1234" , "OTEL_EBPF_EXECUTABLE_PATH " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" },
246+ {"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" : "localhost:1234" , "OTEL_EBPF_EXECUTABLE_PATH " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" },
247+ {"OTEL_EBPF_TRACE_PRINTER" : "text" , "OTEL_EBPF_SHUTDOWN_TIMEOUT" : "1m" , "OTEL_EBPF_EXECUTABLE_PATH " : "foo" },
248+ {"OTEL_EBPF_TRACE_PRINTER" : "json" , "OTEL_EBPF_EXECUTABLE_PATH " : "foo" },
249+ {"OTEL_EBPF_TRACE_PRINTER" : "json_indent" , "OTEL_EBPF_EXECUTABLE_PATH " : "foo" },
250+ {"OTEL_EBPF_TRACE_PRINTER" : "counter" , "OTEL_EBPF_EXECUTABLE_PATH " : "foo" },
251+ {"OTEL_EBPF_PROMETHEUS_PORT" : "8080" , "OTEL_EBPF_EXECUTABLE_PATH " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" },
252+ {"OTEL_EBPF_INTERNAL_OTEL_METRICS" : "true" , "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT" : "localhost:1234" , "OTEL_EBPF_EXECUTABLE_PATH " : "foo" },
249253 }
250254 for n , tc := range testCases {
251255 t .Run (fmt .Sprint ("case" , n ), func (t * testing.T ) {
@@ -257,9 +261,9 @@ func TestConfigValidate(t *testing.T) {
257261func TestConfigValidate_error (t * testing.T ) {
258262 testCases := []envMap {
259263 {"OTEL_EXPORTER_OTLP_ENDPOINT" : "localhost:1234" , "INSTRUMENT_FUNC_NAME" : "bar" },
260- {"OTEL_EBPF_EXECUTABLE_NAME " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" , "OTEL_EBPF_TRACE_PRINTER" : "disabled" },
261- {"OTEL_EBPF_EXECUTABLE_NAME " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" , "OTEL_EBPF_TRACE_PRINTER" : "" },
262- {"OTEL_EBPF_EXECUTABLE_NAME " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" , "OTEL_EBPF_TRACE_PRINTER" : "invalid" },
264+ {"OTEL_EBPF_EXECUTABLE_PATH " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" , "OTEL_EBPF_TRACE_PRINTER" : "disabled" },
265+ {"OTEL_EBPF_EXECUTABLE_PATH " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" , "OTEL_EBPF_TRACE_PRINTER" : "" },
266+ {"OTEL_EBPF_EXECUTABLE_PATH " : "foo" , "INSTRUMENT_FUNC_NAME" : "bar" , "OTEL_EBPF_TRACE_PRINTER" : "invalid" },
263267 }
264268 for n , tc := range testCases {
265269 t .Run (fmt .Sprint ("case" , n ), func (t * testing.T ) {
@@ -331,11 +335,11 @@ func TestConfigValidate_TracePrinter(t *testing.T) {
331335
332336 testCases := []test {
333337 {
334- env : envMap {"OTEL_EBPF_EXECUTABLE_NAME " : "foo" , "OTEL_EBPF_TRACE_PRINTER" : "invalid_printer" },
338+ env : envMap {"OTEL_EBPF_EXECUTABLE_PATH " : "foo" , "OTEL_EBPF_TRACE_PRINTER" : "invalid_printer" },
335339 errorMsg : "invalid value for trace_printer: 'invalid_printer'" ,
336340 },
337341 {
338- env : envMap {"OTEL_EBPF_EXECUTABLE_NAME " : "foo" },
342+ env : envMap {"OTEL_EBPF_EXECUTABLE_PATH " : "foo" },
339343 errorMsg : "you need to define at least one exporter: trace_printer, grafana, otel_metrics_export, otel_traces_export or prometheus_export" ,
340344 },
341345 }
@@ -352,7 +356,7 @@ func TestConfigValidate_TracePrinter(t *testing.T) {
352356}
353357
354358func TestConfigValidate_TracePrinterFallback (t * testing.T ) {
355- env := envMap {"OTEL_EBPF_EXECUTABLE_NAME " : "foo" , "OTEL_EBPF_TRACE_PRINTER" : "text" }
359+ env := envMap {"OTEL_EBPF_EXECUTABLE_PATH " : "foo" , "OTEL_EBPF_TRACE_PRINTER" : "text" }
356360
357361 cfg := loadConfig (t , env )
358362 err := cfg .Validate ()
@@ -361,7 +365,7 @@ func TestConfigValidate_TracePrinterFallback(t *testing.T) {
361365}
362366
363367func TestConfigValidateRoutes (t * testing.T ) {
364- userConfig := bytes .NewBufferString (`executable_name : foo
368+ userConfig := bytes .NewBufferString (`executable_path : foo
365369trace_printer: text
366370routes:
367371 unmatched: heuristic
@@ -374,12 +378,12 @@ routes:
374378
375379func TestConfigValidateRoutes_Errors (t * testing.T ) {
376380 for _ , tc := range []string {
377- `executable_name : foo
381+ `executable_path : foo
378382trace_printer: text
379383routes:
380384 unmatched: heuristic
381385 wildcard_char: "##"
382- ` , `executable_name : foo
386+ ` , `executable_path : foo
383387trace_printer: text
384388routes:
385389 unmatched: heuristic
@@ -397,16 +401,16 @@ routes:
397401}
398402
399403func TestConfig_OtelGoAutoEnv (t * testing.T ) {
400- // OTEL_GO_AUTO_TARGET_EXE is an alias to OTEL_EBPF_EXECUTABLE_NAME
404+ // OTEL_GO_AUTO_TARGET_EXE is an alias to OTEL_EBPF_EXECUTABLE_PATH
401405 // (Compatibility with OpenTelemetry)
402406 t .Setenv ("OTEL_GO_AUTO_TARGET_EXE" , "testserver" )
403407 cfg , err := LoadConfig (bytes .NewReader (nil ))
404408 require .NoError (t , err )
405- assert .True (t , cfg .Exec .IsSet ()) // Exec maps to OTEL_EBPF_EXECUTABLE_NAME
409+ assert .True (t , cfg .Exec .IsSet ()) // Exec maps to OTEL_EBPF_EXECUTABLE_PATH
406410}
407411
408412func TestConfig_NetworkImplicit (t * testing.T ) {
409- // OTEL_GO_AUTO_TARGET_EXE is an alias to OTEL_EBPF_EXECUTABLE_NAME
413+ // OTEL_GO_AUTO_TARGET_EXE is an alias to OTEL_EBPF_EXECUTABLE_PATH
410414 // (Compatibility with OpenTelemetry)
411415 t .Setenv ("OTEL_EXPORTER_OTLP_ENDPOINT" , "http://localhost:4318" )
412416 t .Setenv ("OTEL_EBPF_OTEL_METRIC_FEATURES" , "network" )
@@ -416,7 +420,7 @@ func TestConfig_NetworkImplicit(t *testing.T) {
416420}
417421
418422func TestConfig_NetworkImplicitProm (t * testing.T ) {
419- // OTEL_GO_AUTO_TARGET_EXE is an alias to OTEL_EBPF_EXECUTABLE_NAME
423+ // OTEL_GO_AUTO_TARGET_EXE is an alias to OTEL_EBPF_EXECUTABLE_PATH
420424 // (Compatibility with OpenTelemetry)
421425 t .Setenv ("OTEL_EBPF_PROMETHEUS_PORT" , "9090" )
422426 t .Setenv ("OTEL_EBPF_PROMETHEUS_FEATURES" , "network" )
0 commit comments