mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +00:00
Use tracing semconv types instead of own defines
To keep things in sync when adding new traces, we now use the official semconv types of OTEL rather than our own values. Nothing should change for now behavior wise. Refers to https://github.com/kubernetes/kubernetes/pull/119771 Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
This commit is contained in:
parent
8a7df72782
commit
b9cf6991e6
@ -36,6 +36,7 @@ import (
|
|||||||
libcontaineruserns "github.com/opencontainers/runc/libcontainer/userns"
|
libcontaineruserns "github.com/opencontainers/runc/libcontainer/userns"
|
||||||
"github.com/opencontainers/selinux/go-selinux"
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
|
|
||||||
@ -1686,11 +1687,11 @@ func (kl *Kubelet) Run(updates <-chan kubetypes.PodUpdate) {
|
|||||||
// Callers should not write an event if this operation returns an error.
|
// Callers should not write an event if this operation returns an error.
|
||||||
func (kl *Kubelet) SyncPod(ctx context.Context, updateType kubetypes.SyncPodType, pod, mirrorPod *v1.Pod, podStatus *kubecontainer.PodStatus) (isTerminal bool, err error) {
|
func (kl *Kubelet) SyncPod(ctx context.Context, updateType kubetypes.SyncPodType, pod, mirrorPod *v1.Pod, podStatus *kubecontainer.PodStatus) (isTerminal bool, err error) {
|
||||||
ctx, otelSpan := kl.tracer.Start(ctx, "syncPod", trace.WithAttributes(
|
ctx, otelSpan := kl.tracer.Start(ctx, "syncPod", trace.WithAttributes(
|
||||||
attribute.String("k8s.pod.uid", string(pod.UID)),
|
semconv.K8SPodUIDKey.String(string(pod.UID)),
|
||||||
attribute.String("k8s.pod", klog.KObj(pod).String()),
|
attribute.String("k8s.pod", klog.KObj(pod).String()),
|
||||||
attribute.String("k8s.pod.name", pod.Name),
|
semconv.K8SPodNameKey.String(pod.Name),
|
||||||
attribute.String("k8s.pod.update_type", updateType.String()),
|
attribute.String("k8s.pod.update_type", updateType.String()),
|
||||||
attribute.String("k8s.namespace.name", pod.Namespace),
|
semconv.K8SNamespaceNameKey.String(pod.Namespace),
|
||||||
))
|
))
|
||||||
klog.V(4).InfoS("SyncPod enter", "pod", klog.KObj(pod), "podUID", pod.UID)
|
klog.V(4).InfoS("SyncPod enter", "pod", klog.KObj(pod), "podUID", pod.UID)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -1971,10 +1972,10 @@ func (kl *Kubelet) SyncTerminatingPod(_ context.Context, pod *v1.Pod, podStatus
|
|||||||
// TODO(#113606): connect this with the incoming context parameter, which comes from the pod worker.
|
// TODO(#113606): connect this with the incoming context parameter, which comes from the pod worker.
|
||||||
// Currently, using that context causes test failures.
|
// Currently, using that context causes test failures.
|
||||||
ctx, otelSpan := kl.tracer.Start(context.Background(), "syncTerminatingPod", trace.WithAttributes(
|
ctx, otelSpan := kl.tracer.Start(context.Background(), "syncTerminatingPod", trace.WithAttributes(
|
||||||
attribute.String("k8s.pod.uid", string(pod.UID)),
|
semconv.K8SPodUIDKey.String(string(pod.UID)),
|
||||||
attribute.String("k8s.pod", klog.KObj(pod).String()),
|
attribute.String("k8s.pod", klog.KObj(pod).String()),
|
||||||
attribute.String("k8s.pod.name", pod.Name),
|
semconv.K8SPodNameKey.String(pod.Name),
|
||||||
attribute.String("k8s.namespace.name", pod.Namespace),
|
semconv.K8SNamespaceNameKey.String(pod.Namespace),
|
||||||
))
|
))
|
||||||
defer otelSpan.End()
|
defer otelSpan.End()
|
||||||
klog.V(4).InfoS("SyncTerminatingPod enter", "pod", klog.KObj(pod), "podUID", pod.UID)
|
klog.V(4).InfoS("SyncTerminatingPod enter", "pod", klog.KObj(pod), "podUID", pod.UID)
|
||||||
@ -2106,10 +2107,10 @@ func (kl *Kubelet) SyncTerminatingRuntimePod(_ context.Context, runningPod *kube
|
|||||||
// kubelet restarts in the middle of the action.
|
// kubelet restarts in the middle of the action.
|
||||||
func (kl *Kubelet) SyncTerminatedPod(ctx context.Context, pod *v1.Pod, podStatus *kubecontainer.PodStatus) error {
|
func (kl *Kubelet) SyncTerminatedPod(ctx context.Context, pod *v1.Pod, podStatus *kubecontainer.PodStatus) error {
|
||||||
ctx, otelSpan := kl.tracer.Start(ctx, "syncTerminatedPod", trace.WithAttributes(
|
ctx, otelSpan := kl.tracer.Start(ctx, "syncTerminatedPod", trace.WithAttributes(
|
||||||
attribute.String("k8s.pod.uid", string(pod.UID)),
|
semconv.K8SPodUIDKey.String(string(pod.UID)),
|
||||||
attribute.String("k8s.pod", klog.KObj(pod).String()),
|
attribute.String("k8s.pod", klog.KObj(pod).String()),
|
||||||
attribute.String("k8s.pod.name", pod.Name),
|
semconv.K8SPodNameKey.String(pod.Name),
|
||||||
attribute.String("k8s.namespace.name", pod.Namespace),
|
semconv.K8SNamespaceNameKey.String(pod.Namespace),
|
||||||
))
|
))
|
||||||
defer otelSpan.End()
|
defer otelSpan.End()
|
||||||
klog.V(4).InfoS("SyncTerminatedPod enter", "pod", klog.KObj(pod), "podUID", pod.UID)
|
klog.V(4).InfoS("SyncTerminatedPod enter", "pod", klog.KObj(pod), "podUID", pod.UID)
|
||||||
|
Loading…
Reference in New Issue
Block a user