Skip to content

nodejs_active_requests fails metric validation when exporting metrics #12

@BryanHunt

Description

@BryanHunt

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
                  }
                ]
              }
            }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions