istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/config/analysis/analyzers/telemetry/lightstep.go (about) 1 // Copyright Istio Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package telemetry 16 17 import ( 18 "fmt" 19 20 "istio.io/api/mesh/v1alpha1" 21 telemetryapi "istio.io/api/telemetry/v1alpha1" 22 "istio.io/istio/pkg/config" 23 "istio.io/istio/pkg/config/analysis" 24 "istio.io/istio/pkg/config/analysis/msg" 25 "istio.io/istio/pkg/config/resource" 26 "istio.io/istio/pkg/config/schema/gvk" 27 "istio.io/istio/pkg/util/sets" 28 ) 29 30 type LightstepAnalyzer struct{} 31 32 var _ analysis.Analyzer = &LightstepAnalyzer{} 33 34 // Metadata implements Analyzer 35 func (a *LightstepAnalyzer) Metadata() analysis.Metadata { 36 return analysis.Metadata{ 37 Name: "telemetry.LightstepAnalyzer", 38 Description: "Validates that lightstep provider is still used", 39 Inputs: []config.GroupVersionKind{ 40 gvk.Telemetry, 41 gvk.MeshConfig, 42 }, 43 } 44 } 45 46 // Analyze implements Analyzer 47 func (a *LightstepAnalyzer) Analyze(c analysis.Context) { 48 meshConfig := fetchMeshConfig(c) 49 providerNames := sets.New[string]() 50 for _, prov := range meshConfig.ExtensionProviders { 51 switch prov.Provider.(type) { 52 case *v1alpha1.MeshConfig_ExtensionProvider_Lightstep: 53 providerNames.Insert(prov.Name) 54 } 55 } 56 if len(providerNames) == 0 { 57 return 58 } 59 60 c.ForEach(gvk.Telemetry, func(r *resource.Instance) bool { 61 telemetry := r.Message.(*telemetryapi.Telemetry) 62 for _, tracing := range telemetry.Tracing { 63 for _, p := range tracing.Providers { 64 if providerNames.Contains(p.Name) { 65 c.Report(gvk.Telemetry, 66 msg.NewDeprecated(r, fmt.Sprintf("The Lightstep provider %s is deprecated, please migrate to OpenTelemetry provider.", p.Name))) 67 } 68 } 69 } 70 71 return true 72 }) 73 }