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

[pdatatest] Supporting shortening attribute value #27690

Closed
atoulme opened this issue Oct 16, 2023 · 3 comments · Fixed by #28654
Closed

[pdatatest] Supporting shortening attribute value #27690

atoulme opened this issue Oct 16, 2023 · 3 comments · Fixed by #28654
Labels
enhancement New feature or request pkg/pdatatest

Comments

@atoulme
Copy link
Contributor

atoulme commented Oct 16, 2023

Component(s)

No response

Is your feature request related to a problem? Please describe.

We have attribute values we want to match two set of metrics, spans, or logs on, but have a variable part, such as "foo-bar-UUID", where UUID is always different.

Describe the solution you'd like

We want to be able to match 2 sets of signals based on the prefixed, fixed portion of the attribute value, such as "foo-bar".

Describe alternatives you've considered

Right now we wind up doing this:

func shortenNames(value string) string {
	if strings.HasPrefix(value, "kube-proxy") {
		return "kube-proxy"
	}
	if strings.HasPrefix(value, "local-path-provisioner") {
		return "local-path-provisioner"
	}
	if strings.HasPrefix(value, "kindnet") {
		return "kindnet"
	}
	if strings.HasPrefix(value, "coredns") {
		return "coredns"
	}
	if strings.HasPrefix(value, "otelcol") {
		return "otelcol"
	}
	if strings.HasPrefix(value, "sock-splunk-otel-collector-agent") {
		return "sock-splunk-otel-collector-agent"
	}
	if strings.HasPrefix(value, "sock-splunk-otel-collector-k8s-cluster-receiver") {
		return "sock-splunk-otel-collector-k8s-cluster-receiver"
	}
	if strings.HasPrefix(value, "cert-manager-cainjector") {
		return "cert-manager-cainjector"
	}
	if strings.HasPrefix(value, "sock-operator") {
		return "sock-operator"
	}
	if strings.HasPrefix(value, "nodejs-test") {
		return "nodejs-test"
	}
	if strings.HasPrefix(value, "cert-manager-webhook") {
		return "cert-manager-webhook"
	}
	if strings.HasPrefix(value, "cert-manager") {
		return "cert-manager"
	}

	return value
}

and use it here:

pmetrictest.ChangeResourceAttributeValue("k8s.deployment.name", shortenNames),

Additional context

No response

@atoulme atoulme added enhancement New feature or request needs triage New item requiring triage labels Oct 16, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions
Copy link
Contributor

Pinging code owners for pkg/pdatatest: @djaglowski @fatsheep9146. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@crobert-1
Copy link
Member

crobert-1 commented Oct 19, 2023

Sounds like a valid enhancement to me 👍

@crobert-1 crobert-1 removed the needs triage New item requiring triage label Oct 19, 2023
djaglowski pushed a commit that referenced this issue Oct 27, 2023
…via regular expression (#28654)

**Description:**
Allow to compare metrics resource attributes or metric attribute values
by matching on a portion of the dimension value with a regular
expression.

**Link to tracking Issue:**
Fixes #27690

**Testing:**
Unit tests.
jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this issue Nov 12, 2023
…via regular expression (open-telemetry#28654)

**Description:**
Allow to compare metrics resource attributes or metric attribute values
by matching on a portion of the dimension value with a regular
expression.

**Link to tracking Issue:**
Fixes open-telemetry#27690

**Testing:**
Unit tests.
RoryCrispin pushed a commit to ClickHouse/opentelemetry-collector-contrib that referenced this issue Nov 24, 2023
…via regular expression (open-telemetry#28654)

**Description:**
Allow to compare metrics resource attributes or metric attribute values
by matching on a portion of the dimension value with a regular
expression.

**Link to tracking Issue:**
Fixes open-telemetry#27690

**Testing:**
Unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg/pdatatest
Projects
None yet
2 participants