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

processor/metricstransformprocessor bug report, more detail in description #23886

Closed
JimChenWYU opened this issue Jul 3, 2023 · 4 comments
Closed
Labels
bug Something isn't working processor/metricstransform Metrics Transform processor

Comments

@JimChenWYU
Copy link

JimChenWYU commented Jul 3, 2023

Component(s)

processor/metricstransform

What happened?

Description

In processor/metricstransformprocessor/metrics_transform_processor_testcases_test.go, I add a test case

{
	name: "test kafka cpu time",
	transforms: []internalTransform{
		{
			NewName: "kafka_cpu_time_seconds_total",
			MetricIncludeFilter: func() internalFilter {
				filter, _ := createFilter(FilterConfig{
					Include:   "process_all_cpu_time_seconds_total",
					MatchType: StrictMatchType,
					MatchLabels: map[string]string{
						"cwd":   "/usr/local/kafka",
						"pname": "java",
					},
				})
				return filter
			}(),
			Action: Insert,
		},
		{
			NewName:             "kafka_cpu_time_seconds_total",
			MetricIncludeFilter: internalFilterStrict{include: "kafka_cpu_time_seconds_total"},
			Action:              Combine,
			AggregationType:     Max,
		},
		{
			MetricIncludeFilter: internalFilterStrict{include: "kafka_cpu_time_seconds_total"},
			Action:              Update,
			Operations: []internalOperation{
				{
					configOperation: Operation{
						Action:          AggregateLabels,
						AggregationType: Max,
					},
				},
			},
		},
	},
	in: []pmetric.Metric{
		metricBuilder(pmetric.MetricTypeSum, "process_all_cpu_time_seconds_total", "cwd", "pid", "pname").
			addDoubleDatapoint(1, 2, 0.02, "/usr/local/kafka", "1821184", "bash").
			addDoubleDatapoint(1, 2, 1.4200000000000002, "/usr/local/kafka", "1821702", "java").
			addDoubleDatapoint(1, 2, 0, "/usr/local/kafka", "1821703", "grep").
			addDoubleDatapoint(1, 2, 0.02, "/usr/local/kafka", "1829456", "bash").
			addDoubleDatapoint(1, 2, 3.95, "/usr/local/kafka", "1829511", "java").
			addDoubleDatapoint(1, 2, 13008.900000000001, "/usr/local/kafka", "685117", "java").
			build(),
	},
	out: []pmetric.Metric{
		metricBuilder(pmetric.MetricTypeSum, "process_all_cpu_time_seconds_total", "cwd", "pid", "pname").
			addDoubleDatapoint(1, 2, 0.02, "/usr/local/kafka", "1821184", "bash").
			addDoubleDatapoint(1, 2, 1.4200000000000002, "/usr/local/kafka", "1821702", "java").
			addDoubleDatapoint(1, 2, 0, "/usr/local/kafka", "1821703", "grep").
			addDoubleDatapoint(1, 2, 0.02, "/usr/local/kafka", "1829456", "bash").
			addDoubleDatapoint(1, 2, 3.95, "/usr/local/kafka", "1829511", "java").
			addDoubleDatapoint(1, 2, 13008.900000000001, "/usr/local/kafka", "685117", "java").
			build(),
		metricBuilder(pmetric.MetricTypeSum, "kafka_cpu_time_seconds_total", "cwd", "pid", "pname").
			addDoubleDatapoint(1, 2, 1.4200000000000002, "/usr/local/kafka", "1821702", "java").
                         addDoubleDatapoint(1, 2, 3.95, "/usr/local/kafka", "1829511", "java").
			addDoubleDatapoint(1, 2, 13008.900000000001, "/usr/local/kafka", "685117", "java").
			build(),
	},
},

Steps to Reproduce

Run unit test

Expected Result

out should be

	out: []pmetric.Metric{
		metricBuilder(pmetric.MetricTypeSum, "process_all_cpu_time_seconds_total", "cwd", "pid", "pname").
			addDoubleDatapoint(1, 2, 0.02, "/usr/local/kafka", "1821184", "bash").
			addDoubleDatapoint(1, 2, 1.4200000000000002, "/usr/local/kafka", "1821702", "java").
			addDoubleDatapoint(1, 2, 0, "/usr/local/kafka", "1821703", "grep").
			addDoubleDatapoint(1, 2, 0.02, "/usr/local/kafka", "1829456", "bash").
			addDoubleDatapoint(1, 2, 3.95, "/usr/local/kafka", "1829511", "java").
			addDoubleDatapoint(1, 2, 13008.900000000001, "/usr/local/kafka", "685117", "java").
			build(),
		metricBuilder(pmetric.MetricTypeSum, "kafka_cpu_time_seconds_total", "cwd", "pid", "pname").
			addDoubleDatapoint(1, 2, 13008.900000000001, "/usr/local/kafka", "685117", "java").
			build(),
	},

Actual Result

	out: []pmetric.Metric{
		metricBuilder(pmetric.MetricTypeSum, "process_all_cpu_time_seconds_total", "cwd", "pid", "pname").
			addDoubleDatapoint(1, 2, 0.02, "/usr/local/kafka", "1821184", "bash").
			addDoubleDatapoint(1, 2, 1.4200000000000002, "/usr/local/kafka", "1821702", "java").
			addDoubleDatapoint(1, 2, 0, "/usr/local/kafka", "1821703", "grep").
			addDoubleDatapoint(1, 2, 0.02, "/usr/local/kafka", "1829456", "bash").
			addDoubleDatapoint(1, 2, 3.95, "/usr/local/kafka", "1829511", "java").
			addDoubleDatapoint(1, 2, 13008.900000000001, "/usr/local/kafka", "685117", "java").
			build(),
		metricBuilder(pmetric.MetricTypeSum, "kafka_cpu_time_seconds_total", "cwd", "pid", "pname").
			addDoubleDatapoint(1, 2, 1.4200000000000002, "/usr/local/kafka", "1821702", "java").
                         addDoubleDatapoint(1, 2, 3.95, "/usr/local/kafka", "1829511", "java").
			addDoubleDatapoint(1, 2, 13008.900000000001, "/usr/local/kafka", "685117", "java").
			build(),
	},

Is it a bug?

Collector version

v0.79.0

Environment information

Environment

OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")

OS: macOSX
Compiler: go1.20.4

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

@JimChenWYU JimChenWYU added bug Something isn't working needs triage New item requiring triage labels Jul 3, 2023
@github-actions github-actions bot added the processor/metricstransform Metrics Transform processor label Jul 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Pinging code owners:

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

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

  • processor/metricstransform: @dmitryax
  • needs: Github issue template generation code needs this to generate the corresponding labels.

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

@crobert-1
Copy link
Member

@JimChenWYU I just tried your test on the latest version of the collector, and it's passing as expected.

    --- PASS: TestMetricsTransformProcessor/test_kafka_cpu_time (0.00s)

Can you test again? Sorry for taking so long to respond!

@github-actions github-actions bot removed the Stale label Oct 25, 2023
@crobert-1
Copy link
Member

I thought a bit more about this and I think this can be closed as completed since the test is passing. Feel free to open a PR adding the test, or let us know if there's anything else to do here.

@crobert-1 crobert-1 removed the needs triage New item requiring triage label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working processor/metricstransform Metrics Transform processor
Projects
None yet
Development

No branches or pull requests

2 participants