Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always decorate k8s_owner_name #1226

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions docs/sources/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@ In order to configure which attributes to show or which attributes to hide, chec
| Application (all) | `http.request.method` | shown |
| Application (all) | `http.response.status_code` | shown |
| Application (all) | `http.route` | shown if `routes` configuration section exists |
| Application (all) | `k8s.daemonset.name` | shown if network metrics are enabled |
| Application (all) | `k8s.deployment.name` | shown if network metrics are enabled |
| Application (all) | `k8s.namespace.name` | shown if network metrics are enabled |
| Application (all) | `k8s.node.name` | shown if network metrics are enabled |
| Application (all) | `k8s.pod.name` | shown if network metrics are enabled |
| Application (all) | `k8s.pod.start_time` | shown if network metrics are enabled |
| Application (all) | `k8s.pod.uid` | shown if network metrics are enabled |
| Application (all) | `k8s.replicaset.name` | shown if network metrics are enabled |
| Application (all) | `k8s.statefulset.name` | shown if network metrics are enabled |
| Application (all) | `k8s.cluster.name` | shown if network metrics are enabled |
| Application (all) | `k8s.daemonset.name` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.deployment.name` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.namespace.name` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.node.name` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.owner.name` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.pod.name` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.pod.start_time` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.pod.uid` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.replicaset.name` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.statefulset.name` | shown if Kubernetes metadata is enabled |
| Application (all) | `k8s.cluster.name` | shown if Kubernetes metadata is enabled |
| Application (all) | `service.name` | shown |
| Application (all) | `service.namespace` | shown |
| Application (all) | `target.instance` | shown |
Expand Down
1 change: 1 addition & 0 deletions pkg/transform/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (md *metadataDecorator) appendMetadata(span *request.Span, info *kube.PodIn
span.ServiceID.Metadata[attr.Name(info.Owner.LabelName)] = info.Owner.Name
topOwner := info.Owner.TopOwner()
span.ServiceID.Metadata[attr.Name(topOwner.LabelName)] = topOwner.Name
span.ServiceID.Metadata[attr.K8sOwnerName] = topOwner.Name
}
// override hostname by the Pod name
span.ServiceID.HostName = info.Name
Expand Down
3 changes: 3 additions & 0 deletions pkg/transform/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestDecoration(t *testing.T) {
"k8s.pod.name": "pod-12",
"k8s.pod.uid": "uid-12",
"k8s.deployment.name": "deployment-12",
"k8s.owner.name": "deployment-12",
"k8s.pod.start_time": "2020-01-02 12:12:56",
"k8s.cluster.name": "the-cluster",
}, deco[0].ServiceID.Metadata)
Expand All @@ -82,6 +83,7 @@ func TestDecoration(t *testing.T) {
"k8s.namespace.name": "the-ns",
"k8s.replicaset.name": "rs-34",
"k8s.deployment.name": "rs",
"k8s.owner.name": "rs",
"k8s.pod.name": "pod-34",
"k8s.pod.uid": "uid-34",
"k8s.pod.start_time": "2020-01-02 12:34:56",
Expand Down Expand Up @@ -131,6 +133,7 @@ func TestDecoration(t *testing.T) {
"k8s.pod.name": "pod-12",
"k8s.pod.uid": "uid-12",
"k8s.deployment.name": "deployment-12",
"k8s.owner.name": "deployment-12",
"k8s.pod.start_time": "2020-01-02 12:12:56",
"k8s.cluster.name": "the-cluster",
}, deco[0].ServiceID.Metadata)
Expand Down
2 changes: 2 additions & 0 deletions test/integration/k8s/common/k8s_metrics_testfuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func FeatureHTTPMetricsDecoration(manifest string) features.Feature {
"k8s_node_name": ".+-control-plane$",
"k8s_pod_uid": UUIDRegex,
"k8s_pod_start_time": TimeRegex,
"k8s_owner_name": "^testserver$",
"k8s_deployment_name": "^testserver$",
"k8s_replicaset_name": "^testserver-",
"k8s_cluster_name": "^beyla$",
Expand Down Expand Up @@ -163,6 +164,7 @@ func FeatureGRPCMetricsDecoration(manifest string) features.Feature {
"k8s_node_name": ".+-control-plane$",
"k8s_pod_uid": UUIDRegex,
"k8s_pod_start_time": TimeRegex,
"k8s_owner_name": "^testserver$",
"k8s_deployment_name": "^testserver$",
"k8s_replicaset_name": "^testserver-",
"k8s_cluster_name": "^beyla$",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func TestBasicTracing(t *testing.T) {
{Key: "k8s.node.name", Type: "string", Value: ".+-control-plane$"},
{Key: "k8s.pod.uid", Type: "string", Value: k8s.UUIDRegex},
{Key: "k8s.pod.start_time", Type: "string", Value: k8s.TimeRegex},
{Key: "k8s.owner.name", Type: "string", Value: "^otherinstance$"},
{Key: "k8s.deployment.name", Type: "string", Value: "^otherinstance$"},
{Key: "k8s.namespace.name", Type: "string", Value: "^default$"},
{Key: "k8s.cluster.name", Type: "string", Value: "^beyla$"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ func TestProcessMetrics(t *testing.T) {
"k8s_deployment_name": "^otherinstance$",
"k8s_replicaset_name": "^otherinstance-.*",
"k8s_pod_name": "^otherinstance-.*",
"k8s_owner_name": "^otherinstance$",
}))
}
Loading