1
1
package tracing
2
2
3
3
import (
4
- v12 "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
5
4
envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
6
5
envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
7
6
envoytrace "github.com/envoyproxy/go-control-plane/envoy/config/trace/v3"
@@ -24,7 +23,6 @@ import (
24
23
)
25
24
26
25
var _ = Describe ("Plugin" , func () {
27
-
28
26
var (
29
27
plugin plugins.Plugin
30
28
pluginParams plugins.Params
@@ -318,7 +316,6 @@ var _ = Describe("Plugin", func() {
318
316
})
319
317
320
318
Context ("should handle tracing provider config" , func () {
321
-
322
319
It ("when provider config is nil" , func () {
323
320
cfg := & envoyhttp.HttpConnectionManager {}
324
321
hcmSettings = & hcm.HttpConnectionManagerSettings {
@@ -712,167 +709,6 @@ var _ = Describe("Plugin", func() {
712
709
})
713
710
})
714
711
715
- Describe ("when opencensus provider config" , func () {
716
- It ("translates the plugin correctly using OcagentAddress" , func () {
717
-
718
- expectedHttpAddress := "localhost:10000"
719
- cfg := & envoyhttp.HttpConnectionManager {}
720
- hcmSettings = & hcm.HttpConnectionManagerSettings {
721
- Tracing : & tracing.ListenerTracingSettings {
722
- ProviderConfig : & tracing.ListenerTracingSettings_OpenCensusConfig {
723
- OpenCensusConfig : & envoytrace_gloo.OpenCensusConfig {
724
- TraceConfig : & envoytrace_gloo.TraceConfig {
725
- Sampler : & envoytrace_gloo.TraceConfig_ConstantSampler {
726
- ConstantSampler : & envoytrace_gloo.ConstantSampler {
727
- Decision : envoytrace_gloo .ConstantSampler_ALWAYS_ON ,
728
- },
729
- },
730
- MaxNumberOfAttributes : 5 ,
731
- MaxNumberOfAnnotations : 10 ,
732
- MaxNumberOfMessageEvents : 15 ,
733
- MaxNumberOfLinks : 20 ,
734
- },
735
- OcagentExporterEnabled : true ,
736
- OcagentAddress : & envoytrace_gloo.OpenCensusConfig_HttpAddress {
737
- HttpAddress : expectedHttpAddress ,
738
- },
739
- IncomingTraceContext : nil ,
740
- OutgoingTraceContext : nil ,
741
- },
742
- },
743
- },
744
- }
745
- err := processHcmNetworkFilter (cfg )
746
- Expect (err ).NotTo (HaveOccurred ())
747
-
748
- expectedEnvoyConfig := & envoytrace.OpenCensusConfig {
749
- TraceConfig : & v12.TraceConfig {
750
- Sampler : & v12.TraceConfig_ConstantSampler {
751
- ConstantSampler : & v12.ConstantSampler {
752
- Decision : v12 .ConstantSampler_ALWAYS_ON ,
753
- },
754
- },
755
- MaxNumberOfAttributes : 5 ,
756
- MaxNumberOfAnnotations : 10 ,
757
- MaxNumberOfMessageEvents : 15 ,
758
- MaxNumberOfLinks : 20 ,
759
- },
760
- OcagentExporterEnabled : true ,
761
- OcagentAddress : expectedHttpAddress ,
762
- OcagentGrpcService : nil ,
763
- IncomingTraceContext : nil ,
764
- OutgoingTraceContext : nil ,
765
- }
766
- expectedEnvoyConfigMarshalled , _ := ptypes .MarshalAny (expectedEnvoyConfig )
767
- expectedEnvoyTracingProvider := & envoytrace.Tracing_Http {
768
- Name : "envoy.tracers.opencensus" ,
769
- ConfigType : & envoytrace.Tracing_Http_TypedConfig {
770
- TypedConfig : expectedEnvoyConfigMarshalled ,
771
- },
772
- }
773
-
774
- Expect (cfg .Tracing .Provider .GetName ()).To (Equal (expectedEnvoyTracingProvider .GetName ()))
775
- Expect (cfg .Tracing .Provider .GetTypedConfig ()).To (Equal (expectedEnvoyTracingProvider .GetTypedConfig ()))
776
- })
777
-
778
- It ("translates the plugin correctly using OcagentGrpcService" , func () {
779
-
780
- sampleGrpcTargetUri := "sampleGrpcTargetUri"
781
- sampleGrpcStatPrefix := "sampleGrpcStatPrefix"
782
- cfg := & envoyhttp.HttpConnectionManager {}
783
- hcmSettings = & hcm.HttpConnectionManagerSettings {
784
- Tracing : & tracing.ListenerTracingSettings {
785
- ProviderConfig : & tracing.ListenerTracingSettings_OpenCensusConfig {
786
- OpenCensusConfig : & envoytrace_gloo.OpenCensusConfig {
787
- TraceConfig : & envoytrace_gloo.TraceConfig {
788
- Sampler : & envoytrace_gloo.TraceConfig_ConstantSampler {
789
- ConstantSampler : & envoytrace_gloo.ConstantSampler {
790
- Decision : envoytrace_gloo .ConstantSampler_ALWAYS_ON ,
791
- },
792
- },
793
- MaxNumberOfAttributes : 5 ,
794
- MaxNumberOfAnnotations : 10 ,
795
- MaxNumberOfMessageEvents : 15 ,
796
- MaxNumberOfLinks : 20 ,
797
- },
798
- OcagentExporterEnabled : true ,
799
- OcagentAddress : & envoytrace_gloo.OpenCensusConfig_GrpcAddress {
800
- GrpcAddress : & envoytrace_gloo.OpenCensusConfig_OcagentGrpcAddress {
801
- TargetUri : sampleGrpcTargetUri ,
802
- StatPrefix : sampleGrpcStatPrefix ,
803
- },
804
- },
805
- IncomingTraceContext : []envoytrace_gloo.OpenCensusConfig_TraceContext {
806
- envoytrace_gloo .OpenCensusConfig_NONE ,
807
- envoytrace_gloo .OpenCensusConfig_TRACE_CONTEXT ,
808
- envoytrace_gloo .OpenCensusConfig_GRPC_TRACE_BIN ,
809
- envoytrace_gloo .OpenCensusConfig_CLOUD_TRACE_CONTEXT ,
810
- envoytrace_gloo .OpenCensusConfig_B3 ,
811
- },
812
- OutgoingTraceContext : []envoytrace_gloo.OpenCensusConfig_TraceContext {
813
- envoytrace_gloo .OpenCensusConfig_B3 ,
814
- envoytrace_gloo .OpenCensusConfig_CLOUD_TRACE_CONTEXT ,
815
- envoytrace_gloo .OpenCensusConfig_GRPC_TRACE_BIN ,
816
- envoytrace_gloo .OpenCensusConfig_TRACE_CONTEXT ,
817
- envoytrace_gloo .OpenCensusConfig_NONE ,
818
- },
819
- },
820
- },
821
- },
822
- }
823
- err := processHcmNetworkFilter (cfg )
824
- Expect (err ).NotTo (HaveOccurred ())
825
-
826
- expectedEnvoyConfig := & envoytrace.OpenCensusConfig {
827
- TraceConfig : & v12.TraceConfig {
828
- Sampler : & v12.TraceConfig_ConstantSampler {
829
- ConstantSampler : & v12.ConstantSampler {
830
- Decision : v12 .ConstantSampler_ALWAYS_ON ,
831
- },
832
- },
833
- MaxNumberOfAttributes : 5 ,
834
- MaxNumberOfAnnotations : 10 ,
835
- MaxNumberOfMessageEvents : 15 ,
836
- MaxNumberOfLinks : 20 ,
837
- },
838
- OcagentExporterEnabled : true ,
839
- OcagentAddress : "" ,
840
- OcagentGrpcService : & envoy_config_core_v3.GrpcService {
841
- TargetSpecifier : & envoy_config_core_v3.GrpcService_GoogleGrpc_ {
842
- GoogleGrpc : & envoy_config_core_v3.GrpcService_GoogleGrpc {
843
- TargetUri : sampleGrpcTargetUri ,
844
- StatPrefix : sampleGrpcStatPrefix ,
845
- },
846
- },
847
- },
848
- IncomingTraceContext : []envoytrace.OpenCensusConfig_TraceContext {
849
- envoytrace .OpenCensusConfig_NONE ,
850
- envoytrace .OpenCensusConfig_TRACE_CONTEXT ,
851
- envoytrace .OpenCensusConfig_GRPC_TRACE_BIN ,
852
- envoytrace .OpenCensusConfig_CLOUD_TRACE_CONTEXT ,
853
- envoytrace .OpenCensusConfig_B3 ,
854
- },
855
- OutgoingTraceContext : []envoytrace.OpenCensusConfig_TraceContext {
856
- envoytrace .OpenCensusConfig_B3 ,
857
- envoytrace .OpenCensusConfig_CLOUD_TRACE_CONTEXT ,
858
- envoytrace .OpenCensusConfig_GRPC_TRACE_BIN ,
859
- envoytrace .OpenCensusConfig_TRACE_CONTEXT ,
860
- envoytrace .OpenCensusConfig_NONE ,
861
- },
862
- }
863
- expectedEnvoyConfigMarshalled , _ := ptypes .MarshalAny (expectedEnvoyConfig )
864
- expectedEnvoyTracingProvider := & envoytrace.Tracing_Http {
865
- Name : "envoy.tracers.opencensus" ,
866
- ConfigType : & envoytrace.Tracing_Http_TypedConfig {
867
- TypedConfig : expectedEnvoyConfigMarshalled ,
868
- },
869
- }
870
-
871
- Expect (cfg .Tracing .Provider .GetName ()).To (Equal (expectedEnvoyTracingProvider .GetName ()))
872
- Expect (cfg .Tracing .Provider .GetTypedConfig ()).To (Equal (expectedEnvoyTracingProvider .GetTypedConfig ()))
873
- })
874
- })
875
-
876
712
Describe ("when opentelemetry provider config" , func () {
877
713
const (
878
714
testClusterName = "test-cluster"
@@ -1056,5 +892,4 @@ var _ = Describe("Plugin", func() {
1056
892
Expect (outFull .Tracing .RandomSampling .Numerator / 10000 ).To (Equal (uint32 (20 )))
1057
893
Expect (outFull .Tracing .OverallSampling .Numerator / 10000 ).To (Equal (uint32 (30 )))
1058
894
})
1059
-
1060
895
})
0 commit comments