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

nodejs_active_requests fails metric validation when exporting metrics #12

Open
BryanHunt opened this issue Mar 30, 2023 · 0 comments
Open

Comments

@BryanHunt
Copy link

BryanHunt commented Mar 30, 2023

We are exporting metrics to an instance of OpenTelemetry collector which has the following validation code:

// validateMetrics returns a bool representing whether the metric has a valid type and temporality combination and a
// matching metric type and field
func validateMetrics(metric pmetric.Metric) bool {
	switch metric.Type() {
	case pmetric.MetricTypeGauge:
		return metric.Gauge().DataPoints().Len() != 0
	case pmetric.MetricTypeSum:
		return metric.Sum().DataPoints().Len() != 0 && metric.Sum().AggregationTemporality() == pmetric.AggregationTemporalityCumulative
	case pmetric.MetricTypeHistogram:
		return metric.Histogram().DataPoints().Len() != 0 && metric.Histogram().AggregationTemporality() == pmetric.AggregationTemporalityCumulative
	case pmetric.MetricTypeSummary:
		return metric.Summary().DataPoints().Len() != 0
	}
	return false
}

We are getting the following failure which is the first case above:

Metrics validation failed (1) [service-id=******, metric-name=nodejs_active_requests, metric-type=Gauge, datapoints-num=0]

It appears that nodejs_active_requests has no datapoints.

I captured an export in the debugger and here is some sample data:

{
            {
              "name": "nodejs_active_handles_total",
              "description": "Total number of active handles.",
              "unit": "",
              "gauge": {
                "dataPoints": [
                  {
                    "attributes": [],
                    "startTimeUnixNano": 1680208888555000000,
                    "timeUnixNano": 1680208888555000000,
                    "asDouble": 6
                  }
                ]
              }
            },
            {
              "name": "nodejs_active_requests",
              "description": "Number of active libuv requests grouped by request type. Every request type is C++ class name.",
              "unit": "",
              "gauge": {
                "dataPoints": []
              }
            },
            {
              "name": "nodejs_active_requests_total",
              "description": "Total number of active requests.",
              "unit": "",
              "gauge": {
                "dataPoints": [
                  {
                    "attributes": [],
                    "startTimeUnixNano": 1680208888555000000,
                    "timeUnixNano": 1680208888555000000,
                    "asDouble": 0
                  }
                ]
              }
            }
}
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

No branches or pull requests

1 participant