@@ -1015,12 +1015,14 @@ func (t *Translator) processTracing(gwCtx *GatewayContext, envoyproxy *egv1a1.En
10151015 }
10161016
10171017 return & ir.Tracing {
1018- Authority : authority ,
1019- ServiceName : serviceName ,
1020- SamplingRate : proxySamplingRate (tracing ),
1021- CustomTags : ir .CustomTagMapToSlice (tracing .CustomTags ),
1022- Tags : ir .MapToSlice (tracing .Tags ),
1023- ResourceAttributes : ir .MapToSlice (getOpenTelemetryTracingResourceAttributes (& tracing .Provider )),
1018+ Authority : authority ,
1019+ ServiceName : serviceName ,
1020+ SamplingRate : proxySamplingRate (tracing .SamplingRate , tracing .SamplingFraction ),
1021+ ClientSamplingRate : proxySamplingFractionPtr (tracing .ClientSamplingFraction ),
1022+ OverallSamplingRate : proxySamplingFractionPtr (tracing .OverallSamplingFraction ),
1023+ CustomTags : ir .CustomTagMapToSlice (tracing .CustomTags ),
1024+ Tags : ir .MapToSlice (tracing .Tags ),
1025+ ResourceAttributes : ir .MapToSlice (getOpenTelemetryTracingResourceAttributes (& tracing .Provider )),
10241026 Destination : ir.RouteDestination {
10251027 Name : destName ,
10261028 Settings : ds ,
@@ -1033,20 +1035,29 @@ func (t *Translator) processTracing(gwCtx *GatewayContext, envoyproxy *egv1a1.En
10331035 }, nil
10341036}
10351037
1036- func proxySamplingRate (tracing * egv1a1.ProxyTracing ) float64 {
1037- rate := 100.0
1038- if tracing .SamplingRate != nil {
1039- rate = float64 (* tracing .SamplingRate )
1040- } else if tracing .SamplingFraction != nil {
1041- numerator := float64 (tracing .SamplingFraction .Numerator )
1042- denominator := ptr .Deref (tracing .SamplingFraction .Denominator , 100 )
1043-
1044- rate = numerator * 100 / float64 (denominator )
1045- // Identifies a percentage, in the range [0.0, 100.0]
1046- rate = math .Max (0 , rate )
1047- rate = math .Min (100 , rate )
1038+ func proxySamplingFractionPtr (fraction * gwapiv1.Fraction ) * float64 {
1039+ if fraction == nil {
1040+ return nil
1041+ }
1042+ return new (proxySamplingRate (nil , fraction ))
1043+ }
1044+
1045+ func proxySamplingRate (rate * uint32 , fraction * gwapiv1.Fraction ) float64 {
1046+ if rate != nil {
1047+ return float64 (* rate )
10481048 }
1049- return rate
1049+ if fraction == nil {
1050+ return 100.0
1051+ }
1052+
1053+ numerator := float64 (fraction .Numerator )
1054+ denominator := ptr .Deref (fraction .Denominator , 100 )
1055+
1056+ value := numerator * 100 / float64 (denominator )
1057+ // Identifies a percentage, in the range [0.0, 100.0]
1058+ value = math .Max (0 , value )
1059+ value = math .Min (100 , value )
1060+ return value
10501061}
10511062
10521063// getAuthorityFromDestination extracts the gRPC authority from a destination setting.
0 commit comments