Skip to content

Conversation

@ttetyanka
Copy link

No description provided.

// NewPodConfig returns a PodConfig which uses for the provided pod, namespace and container label values,
// if found, and falls back to the podId and namespaceId.
func NewPodConfig(podId, namespaceId, podIdLabel, namespaceIdLabel, containerNameLabel, tenantUIDLabel string) PodConfig {
func NewPodConfig(podId, namespaceId, podIdLabel, namespaceIdLabel, containerNameLabel, tenantUIDLabel, entityTypeLabel, entityNameLabel string) PodConfig {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a bit off. It just doesn't really look like it belongs to pod config.

Comment on lines +601 to +616
CustomLabels: map[string]string{
"project_id": "",
"cluster_name": "",
"location": "",
"instance_id": "",
"node_name": "",
"entity_type": "test",
},
PodConfig: config.NewPodConfig("", "", "", "", "", "", "entityTypeLabel", ""),
},
},
[]*dto.LabelPair{
{
Name: stringPtr("entityTypeLabel"),
Value: stringPtr("test"),
},
Copy link

@MartynaGrotek MartynaGrotek Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that entity_type and entity_name will be in SourceConfig.CustomLabels and will be just taken from LabelPairs, so that we just need to adjust getCustomMonitoredResource function to sth like this:

func getCustomMonitoredResource(config *config.CommonConfig, tenantUID string, , labels []*dto.LabelPair) *monitoredres.MonitoredResource {
	resourceLabels := config.SourceConfig.CustomLabels
	applyDefaultIfEmpty(resourceLabels, "instance_id", config.GceConfig.InstanceId)
	applyDefaultIfEmpty(resourceLabels, "project_id", config.GceConfig.Project)
	applyDefaultIfEmpty(resourceLabels, "cluster_name", config.GceConfig.Cluster)
	applyDefaultIfEmpty(resourceLabels, "location", config.GceConfig.ClusterLocation)
	applyDefaultIfEmpty(resourceLabels, "node_name", config.GceConfig.Instance)

takeFromLabelsIfEmptyAndExistsInCustomLabels(resourceLabels, "entity_type", labels)
takeFromLabelsIfEmptyAndExistsInCustomLabels(resourceLabels, "entity_name", labels) // or more generic solution to do that for all empty custom labels


	return &monitoredres.MonitoredResource{
		Type: config.SourceConfig.CustomResourceType,
		// Need to clone the map because timeseries created using this label can
		// have its label value overwritten by a newer value of tenant_uid before
		// it was even exported since map would have pointed to the same address.
		Labels: cloneAndApplyDefaultIfFound(resourceLabels, "tenant_uid", tenantUID),
	}
}

But maybe I am missing sth.
@x13n could you help here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't touched this repo for years, so I'm afraid I don't have good intuition here. Current component owners should be able to address deep code questions much better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants