@@ -22,6 +22,7 @@ import (
2222 "encoding/base64"
2323 "fmt"
2424 "io"
25+ "reflect"
2526 "slices"
2627 "sort"
2728 "strings"
@@ -476,3 +477,49 @@ func TestToOtelMetricAttrs(t *testing.T) {
476477 })
477478 }
478479}
480+
481+ func TestCreateExporterOptionsFiltering (t * testing.T ) {
482+ endpointOpt := option .WithEndpoint ("test.endpoint" )
483+ apiKeyOpt := option .WithAPIKey ("test.apikey" )
484+ audiencesOpt := option .WithAudiences ("test.audience" )
485+
486+ inputOpts := []option.ClientOption {
487+ endpointOpt ,
488+ apiKeyOpt ,
489+ audiencesOpt ,
490+ }
491+
492+ filteredOpts := createExporterOptions (inputOpts ... )
493+
494+ foundEndpointOpt := false
495+ foundAPIKeyOpt := false
496+ foundAudiencesOpt := false
497+
498+ for _ , opt := range filteredOpts {
499+ if reflect .TypeOf (opt ) == reflect .TypeOf (endpointOpt ) {
500+ foundEndpointOpt = true
501+ }
502+ if reflect .TypeOf (opt ) == reflect .TypeOf (apiKeyOpt ) {
503+ foundAPIKeyOpt = true
504+ }
505+ if reflect .TypeOf (opt ) == reflect .TypeOf (audiencesOpt ) {
506+ foundAudiencesOpt = true
507+ }
508+ }
509+
510+ if foundEndpointOpt {
511+ t .Errorf ("option.WithEndpoint was found in filtered options, but it should have been filtered out" )
512+ }
513+
514+ if ! foundAPIKeyOpt {
515+ t .Errorf ("option.WithAPIKey was not found in filtered options, but it should have been preserved" )
516+ }
517+
518+ if ! foundAudiencesOpt {
519+ t .Errorf ("option.WithAudiences was not found in filtered options, but it should have been preserved" )
520+ }
521+
522+ if len (filteredOpts ) != 2 {
523+ t .Errorf ("Expected 2 options to be returned, got %d" , len (filteredOpts ))
524+ }
525+ }
0 commit comments