Repository: istio/istio
File: pilot/pkg/networking/core/tracing_test.go (Go)

Code before:
		&tracing.CustomTag{
			Tag: "istio.mesh_id",
			Type: &tracing.CustomTag_Literal_{
				Literal: &tracing.CustomTag_Literal{
					Value: "unknown",
				},
			},
		},
		&tracing.CustomTag{
			Tag: "istio.namespace",
			Type: &tracing.CustomTag_Literal_{
				Literal: &tracing.CustomTag_Literal{
					Value: "default",
				},
			},
		})
}

func waypointTracingTags(extra ...*tracing.CustomTag) []*tracing.CustomTag {
	tags := append([]*tracing.CustomTag{}, defaultTracingTags()...)
	tags = append(tags,
		// CEL-based tags for downstream/upstream peer info
		&tracing.CustomTag{Tag: "istio.downstream.namespace", Type: &tracing.CustomTag_Value{Value: "%CEL(filter_state.downstream_peer.namespace)%"}},
		&tracing.CustomTag{Tag: "istio.downstream.workload", Type: &tracing.CustomTag_Value{Value: "%CEL(filter_state.downstream_peer.workload)%"}},
		&tracing.CustomTag{Tag: "istio.upstream.namespace", Type: &tracing.CustomTag_Value{Value: "%CEL(filter_state.upstream_peer.namespace)%"}},
		&tracing.CustomTag{Tag: "istio.upstream.workload", Type: &tracing.CustomTag_Value{Value: "%CEL(filter_state.upstream_peer.workload)%"}},
		// FIELD accessor tags for waypoint source tracking (uses downstream_peer_obj key)
		&tracing.CustomTag{Tag: "istio.source_app", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:app)%"}},
		&tracing.CustomTag{Tag: "istio.source_app_version", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:version)%"}},
		&tracing.CustomTag{Tag: "istio.source_canonical_revision", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:revision)%"}},
		&tracing.CustomTag{Tag: "istio.source_canonical_service", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:service)%"}},
		&tracing.CustomTag{Tag: "istio.source_cluster_id", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:cluster)%"}},
		&tracing.CustomTag{Tag: "istio.source_instance_name", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:name)%"}},
		&tracing.CustomTag{Tag: "istio.source_namespace", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:namespace)%"}},
		&tracing.CustomTag{Tag: "istio.source_workload", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:workload)%"}},
		&tracing.CustomTag{Tag: "istio.source_workload_type", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:type)%"}},
	)
	tags = append(tags, extra...)
	sort.Slice(tags, func(i, j int) bool { return tags[i].Tag < tags[j].Tag })
	return tags
}

func fakeOptsWithDefaultProviders() gatewayListenerOpts {
	var opts gatewayListenerOpts
	opts.push = &model.PushContext{
		Mesh: &meshconfig.MeshConfig{
			EnableTracing: true,
			DefaultConfig: &meshconfig.ProxyConfig{
				Tracing: &meshconfig.Tracing{
					Sampling: 55.5,
				},

Review comment (suggestion):
@PetrMc any chance we we could add `istio.destination_{name,workload}`. The Kiali folks plan to use it @josunect 

Code after:
		&tracing.CustomTag{
			Tag: "istio.mesh_id",
			Type: &tracing.CustomTag_Literal_{
				Literal: &tracing.CustomTag_Literal{
					Value: "unknown",
				},
			},
		},
		&tracing.CustomTag{
			Tag: "istio.namespace",
			Type: &tracing.CustomTag_Literal_{
				Literal: &tracing.CustomTag_Literal{
					Value: "default",
				},
			},
		})
}

func waypointTracingTags(extra ...*tracing.CustomTag) []*tracing.CustomTag {
	tags := append([]*tracing.CustomTag{}, defaultTracingTags()...)
	tags = append(tags,
		// FIELD accessor tags for waypoint source tracking (uses downstream_peer_obj key)
		&tracing.CustomTag{Tag: "istio.source_app", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:app)%"}},
		&tracing.CustomTag{Tag: "istio.source_app_version", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:version)%"}},
		&tracing.CustomTag{Tag: "istio.source_canonical_revision", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:revision)%"}},
		&tracing.CustomTag{Tag: "istio.source_canonical_service", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:service)%"}},
		&tracing.CustomTag{Tag: "istio.source_cluster_id", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:cluster)%"}},
		&tracing.CustomTag{Tag: "istio.source_instance_name", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:name)%"}},
		&tracing.CustomTag{Tag: "istio.source_namespace", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:namespace)%"}},
		&tracing.CustomTag{Tag: "istio.source_workload", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:workload)%"}},
		&tracing.CustomTag{Tag: "istio.source_workload_type", Type: &tracing.CustomTag_Value{Value: "%FILTER_STATE(downstream_peer_obj:FIELD:type)%"}},
	)
	tags = append(tags, extra...)
	sort.Slice(tags, func(i, j int) bool { return tags[i].Tag < tags[j].Tag })
	return tags
}

func fakeOptsWithDefaultProviders() gatewayListenerOpts {
	var opts gatewayListenerOpts
	opts.push = &model.PushContext{
		Mesh: &meshconfig.MeshConfig{
			EnableTracing: true,
			DefaultConfig: &meshconfig.ProxyConfig{
				Tracing: &meshconfig.Tracing{
					Sampling: 55.5,
				},
			},
			DefaultProviders: &meshconfig.MeshConfig_DefaultProviders{
				Tracing: []string{
					"foo",
				},