@@ -372,7 +372,17 @@ type inherentGRPCRuntimeConfig struct {
372372}
373373
374374type inherentGRPCTelemetryRuntimeConfig struct {
375- Metrics * inherentGRPCMetricsRuntimeConfig `json:"metrics,omitempty"`
375+ Metrics * inherentGRPCMetricsRuntimeConfig `json:"metrics,omitempty"`
376+ Logging []inherentGRPCLoggingRuntimeConfig `json:"logging,omitempty"`
377+ }
378+
379+ type inherentGRPCLoggingRuntimeConfig struct {
380+ Providers []string `json:"providers,omitempty"`
381+ Disabled bool `json:"disabled"`
382+ Mode string `json:"mode,omitempty"`
383+ FilterExpression string `json:"filterExpression,omitempty"`
384+ Tags map [string ]string `json:"tags,omitempty"`
385+ Endpoint string `json:"endpoint,omitempty"`
376386}
377387
378388type inherentGRPCMetricsRuntimeConfig struct {
@@ -771,28 +781,52 @@ func buildRuntimeConfigJSON(
771781}
772782
773783func inherentGRPCTelemetryConfig (effective telemetryconfig.EffectiveTracing ) * inherentGRPCTelemetryRuntimeConfig {
774- if ! effective .MetricsConfigured {
784+ if ! effective .MetricsConfigured && ! effective . LoggingConfigured {
775785 return nil
776786 }
777- metrics := & inherentGRPCMetricsRuntimeConfig {
778- Enabled : effective .MetricsEnabled (),
779- Providers : append ([]string (nil ), effective .MetricProviders ... ),
780- Rules : make ([]inherentGRPCMetricRuleRuntimeConfig , 0 , len (effective .MetricRules )),
787+ config := & inherentGRPCTelemetryRuntimeConfig {
788+ Logging : make ([]inherentGRPCLoggingRuntimeConfig , 0 , len (effective .Logging )),
781789 }
782- for _ , rule := range effective .MetricRules {
783- runtimeRule := inherentGRPCMetricRuleRuntimeConfig {
784- Metric : rule .Metric .String (),
785- Scope : rule .Scope .String (),
790+ if effective .MetricsConfigured {
791+ config .Metrics = & inherentGRPCMetricsRuntimeConfig {
792+ Enabled : effective .MetricsEnabled (),
793+ Providers : append ([]string (nil ), effective .MetricProviders ... ),
794+ Rules : make ([]inherentGRPCMetricRuleRuntimeConfig , 0 , len (effective .MetricRules )),
786795 }
787- if len ( rule . Tags ) > 0 {
788- runtimeRule . Tags = make ( map [ string ] inherentGRPCTagOverrideRuntimeConfig , len ( rule . Tags ))
789- for _ , tag := range rule .Tags {
790- runtimeRule . Tags [ tag . Name ] = inherentGRPCTagOverrideRuntimeConfig { Action : tag . Action .String ()}
796+ for _ , rule := range effective . MetricRules {
797+ runtimeRule := inherentGRPCMetricRuleRuntimeConfig {
798+ Metric : rule .Metric . String (),
799+ Scope : rule . Scope .String (),
791800 }
801+ if len (rule .Tags ) > 0 {
802+ runtimeRule .Tags = make (map [string ]inherentGRPCTagOverrideRuntimeConfig , len (rule .Tags ))
803+ for _ , tag := range rule .Tags {
804+ runtimeRule .Tags [tag .Name ] = inherentGRPCTagOverrideRuntimeConfig {Action : tag .Action .String ()}
805+ }
806+ }
807+ config .Metrics .Rules = append (config .Metrics .Rules , runtimeRule )
808+ }
809+ }
810+ for _ , rule := range effective .Logging {
811+ runtimeRule := inherentGRPCLoggingRuntimeConfig {
812+ Providers : append ([]string (nil ), rule .Providers ... ),
813+ Disabled : rule .Disabled ,
814+ Mode : rule .Mode .String (),
815+ FilterExpression : rule .FilterExpression ,
816+ Tags : make (map [string ]string , len (rule .Tags )),
817+ }
818+ if runtimeRule .Mode == "MODE_UNSPECIFIED" {
819+ runtimeRule .Mode = "CLIENT_AND_SERVER"
820+ }
821+ if len (rule .Providers ) > 0 {
822+ runtimeRule .Endpoint = telemetryconfig .ProviderEndpoint (rule .Providers [0 ], constants .DubboSystemNamespace )
823+ }
824+ for _ , tag := range rule .Tags {
825+ runtimeRule .Tags [tag .Name ] = tag .Value
792826 }
793- metrics . Rules = append (metrics . Rules , runtimeRule )
827+ config . Logging = append (config . Logging , runtimeRule )
794828 }
795- return & inherentGRPCTelemetryRuntimeConfig { Metrics : metrics }
829+ return config
796830}
797831
798832func (c * inherentGRPCWorkloadController ) buildRuntimeTrafficConfig () ([]inherentGRPCServiceRuntimeConfig , []inherentGRPCRouteRuntimeConfig ) {
0 commit comments