diff --git a/connector/servicegraphconnector/connector.go b/connector/servicegraphconnector/connector.go index a98cc3ee8523..14e0c50e130c 100644 --- a/connector/servicegraphconnector/connector.go +++ b/connector/servicegraphconnector/connector.go @@ -402,10 +402,9 @@ func (p *serviceGraphConnector) aggregateMetricsForEdge(e *store.Edge) { p.seriesMutex.Lock() defer p.seriesMutex.Unlock() p.updateSeries(metricKey, dimensions) + p.updateCountMetrics(metricKey) if e.Failed { p.updateErrorMetrics(metricKey) - } else { - p.updateCountMetrics(metricKey) } p.updateDurationMetrics(metricKey, e.ServerLatencySec, e.ClientLatencySec) } diff --git a/connector/servicegraphconnector/connector_test.go b/connector/servicegraphconnector/connector_test.go index c48b49369c57..b6dcf8852430 100644 --- a/connector/servicegraphconnector/connector_test.go +++ b/connector/servicegraphconnector/connector_test.go @@ -124,10 +124,11 @@ func TestConnectorConsume(t *testing.T) { assert.NoError(t, err) err = pmetrictest.CompareMetrics(expectedMetrics, actualMetrics, + pmetrictest.IgnoreMetricsOrder(), pmetrictest.IgnoreMetricDataPointsOrder(), - pmetrictest.IgnoreResourceMetricsOrder(), - pmetrictest.IgnoreResourceMetricsOrder(), pmetrictest.IgnoreStartTimestamp(), - pmetrictest.IgnoreTimestamp()) + pmetrictest.IgnoreStartTimestamp(), + pmetrictest.IgnoreTimestamp(), + ) require.NoError(t, err) }) } diff --git a/connector/servicegraphconnector/testdata/failed-label-not-work-expect-metrics.yaml b/connector/servicegraphconnector/testdata/failed-label-not-work-expect-metrics.yaml index 49d74851b8a5..dd4c905a23be 100644 --- a/connector/servicegraphconnector/testdata/failed-label-not-work-expect-metrics.yaml +++ b/connector/servicegraphconnector/testdata/failed-label-not-work-expect-metrics.yaml @@ -23,6 +23,27 @@ resourceMetrics: startTimeUnixNano: "1000000" timeUnixNano: "2000000" isMonotonic: true + - name: traces_service_graph_request_total + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "1" + attributes: + - key: client + value: + stringValue: foo + - key: connection_type + value: + stringValue: "" + - key: failed + value: + boolValue: true + - key: server + value: + stringValue: bar + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + isMonotonic: true - name: traces_service_graph_request_failed_total sum: aggregationTemporality: 2