Skip to content

Commit

Permalink
[connector/servicegraph] Revert open-telemetry#34562
Browse files Browse the repository at this point in the history
This reverts commit 1a432b9.
  • Loading branch information
jpkrohling committed Aug 27, 2024
1 parent b8ee45e commit 7660963
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 112 deletions.
27 changes: 0 additions & 27 deletions .chloggen/fix-wrong-latency.yaml

This file was deleted.

12 changes: 6 additions & 6 deletions connector/servicegraphconnector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,9 @@ func (p *serviceGraphConnector) collectClientLatencyMetrics(ilm pmetric.ScopeMet
dpDuration.SetStartTimestamp(pcommon.NewTimestampFromTime(p.startTime))
dpDuration.SetTimestamp(timestamp)
dpDuration.ExplicitBounds().FromRaw(p.reqDurationBounds)
dpDuration.BucketCounts().FromRaw(p.reqClientDurationSecondsBucketCounts[key])
dpDuration.SetCount(p.reqClientDurationSecondsCount[key])
dpDuration.SetSum(p.reqClientDurationSecondsSum[key])
dpDuration.BucketCounts().FromRaw(p.reqServerDurationSecondsBucketCounts[key])
dpDuration.SetCount(p.reqServerDurationSecondsCount[key])
dpDuration.SetSum(p.reqServerDurationSecondsSum[key])

// TODO: Support exemplars
dimensions, ok := p.dimensionsForSeries(key)
Expand Down Expand Up @@ -575,9 +575,9 @@ func (p *serviceGraphConnector) collectServerLatencyMetrics(ilm pmetric.ScopeMet
dpDuration.SetStartTimestamp(pcommon.NewTimestampFromTime(p.startTime))
dpDuration.SetTimestamp(timestamp)
dpDuration.ExplicitBounds().FromRaw(p.reqDurationBounds)
dpDuration.BucketCounts().FromRaw(p.reqServerDurationSecondsBucketCounts[key])
dpDuration.SetCount(p.reqServerDurationSecondsCount[key])
dpDuration.SetSum(p.reqServerDurationSecondsSum[key])
dpDuration.BucketCounts().FromRaw(p.reqClientDurationSecondsBucketCounts[key])
dpDuration.SetCount(p.reqClientDurationSecondsCount[key])
dpDuration.SetSum(p.reqClientDurationSecondsSum[key])

// TODO: Support exemplars
dimensions, ok := p.dimensionsForSeries(key)
Expand Down
23 changes: 10 additions & 13 deletions connector/servicegraphconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ func getGoldenTraces(t *testing.T, file string) ptrace.Traces {
}

func verifyHappyCaseMetrics(t *testing.T, md pmetric.Metrics) {
verifyHappyCaseMetricsWithDuration()(t, md)
verifyHappyCaseMetricsWithDuration(1)(t, md)
}

func verifyHappyCaseMetricsWithDuration() func(t *testing.T, md pmetric.Metrics) {
func verifyHappyCaseMetricsWithDuration(durationSum float64) func(t *testing.T, md pmetric.Metrics) {
return func(t *testing.T, md pmetric.Metrics) {
assert.Equal(t, 3, md.MetricCount())

Expand All @@ -231,11 +231,11 @@ func verifyHappyCaseMetricsWithDuration() func(t *testing.T, md pmetric.Metrics)

mServerDuration := ms.At(1)
assert.Equal(t, "traces_service_graph_request_server_seconds", mServerDuration.Name())
verifyDuration(t, mServerDuration, 2, []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0})
verifyDuration(t, mServerDuration, durationSum)

mClientDuration := ms.At(2)
assert.Equal(t, "traces_service_graph_request_client_seconds", mClientDuration.Name())
verifyDuration(t, mClientDuration, 1, []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0})
verifyDuration(t, mClientDuration, durationSum)
}
}

Expand All @@ -259,16 +259,16 @@ func verifyCount(t *testing.T, m pmetric.Metric) {
verifyAttr(t, attributes, "client_some-attribute", "val")
}

func verifyDuration(t *testing.T, m pmetric.Metric, durationSum float64, bs []uint64) {
func verifyDuration(t *testing.T, m pmetric.Metric, durationSum float64) {
assert.Equal(t, pmetric.MetricTypeHistogram, m.Type())
dps := m.Histogram().DataPoints()
assert.Equal(t, 1, dps.Len())

dp := dps.At(0)
assert.Equal(t, durationSum, dp.Sum()) // Duration: client is 1sec, server is 2sec
assert.Equal(t, durationSum, dp.Sum()) // Duration: 1sec
assert.Equal(t, uint64(1), dp.Count())
buckets := pcommon.NewUInt64Slice()
buckets.FromRaw(bs)
buckets.FromRaw([]uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0})
assert.Equal(t, buckets, dp.BucketCounts())

attributes := dp.Attributes()
Expand All @@ -287,10 +287,7 @@ func verifyAttr(t *testing.T, attrs pcommon.Map, k, expected string) {

func buildSampleTrace(t *testing.T, attrValue string) ptrace.Traces {
tStart := time.Date(2022, 1, 2, 3, 4, 5, 6, time.UTC)
// client: 1s
cEnd := time.Date(2022, 1, 2, 3, 4, 6, 6, time.UTC)
// server: 2s
sEnd := time.Date(2022, 1, 2, 3, 4, 7, 6, time.UTC)
tEnd := time.Date(2022, 1, 2, 3, 4, 6, 6, time.UTC)

traces := ptrace.NewTraces()

Expand All @@ -315,7 +312,7 @@ func buildSampleTrace(t *testing.T, attrValue string) ptrace.Traces {
clientSpan.SetTraceID(traceID)
clientSpan.SetKind(ptrace.SpanKindClient)
clientSpan.SetStartTimestamp(pcommon.NewTimestampFromTime(tStart))
clientSpan.SetEndTimestamp(pcommon.NewTimestampFromTime(cEnd))
clientSpan.SetEndTimestamp(pcommon.NewTimestampFromTime(tEnd))
clientSpan.Attributes().PutStr("some-attribute", attrValue) // Attribute selected as dimension for metrics
serverSpan := scopeSpans.Spans().AppendEmpty()
serverSpan.SetName("server span")
Expand All @@ -324,7 +321,7 @@ func buildSampleTrace(t *testing.T, attrValue string) ptrace.Traces {
serverSpan.SetParentSpanID(clientSpanID)
serverSpan.SetKind(ptrace.SpanKindServer)
serverSpan.SetStartTimestamp(pcommon.NewTimestampFromTime(tStart))
serverSpan.SetEndTimestamp(pcommon.NewTimestampFromTime(sEnd))
serverSpan.SetEndTimestamp(pcommon.NewTimestampFromTime(tEnd))

return traces
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,74 +32,74 @@ resourceMetrics:
- histogram:
aggregationTemporality: 2
dataPoints:
- attributes:
- key: client
value:
stringValue: user
- key: connection_type
value:
stringValue: virtual_node
- key: failed
value:
boolValue: false
- key: server
value:
stringValue: bar-requester
- key: server_peer.service
value:
stringValue: external-platform
- key: virtual_node
value:
stringValue: client
bucketCounts:
- "1"
- "0"
- "0"
- "0"
count: "1"
explicitBounds:
- 0.1
- 1
- 10
startTimeUnixNano: "1000000"
sum: 1e-06
timeUnixNano: "2000000"
- attributes:
- key: client
value:
stringValue: user
- key: connection_type
value:
stringValue: virtual_node
- key: failed
value:
boolValue: false
- key: server
value:
stringValue: bar-requester
- key: server_peer.service
value:
stringValue: external-platform
- key: virtual_node
value:
stringValue: client
bucketCounts:
- "1"
- "0"
- "0"
- "0"
count: "1"
explicitBounds:
- 0.1
- 1
- 10
startTimeUnixNano: "1000000"
sum: 0.000000
timeUnixNano: "2000000"
name: traces_service_graph_request_server_seconds
- histogram:
aggregationTemporality: 2
dataPoints:
- attributes:
- key: client
value:
stringValue: user
- key: connection_type
value:
stringValue: virtual_node
- key: failed
value:
boolValue: false
- key: server
value:
stringValue: bar-requester
- key: server_peer.service
value:
stringValue: external-platform
- key: virtual_node
value:
stringValue: client
bucketCounts:
- "1"
- "0"
- "0"
- "0"
count: "1"
explicitBounds:
- 0.1
- 1
- 10
startTimeUnixNano: "1000000"
sum: 0
timeUnixNano: "2000000"
- attributes:
- key: client
value:
stringValue: user
- key: connection_type
value:
stringValue: virtual_node
- key: failed
value:
boolValue: false
- key: server
value:
stringValue: bar-requester
- key: server_peer.service
value:
stringValue: external-platform
- key: virtual_node
value:
stringValue: client
bucketCounts:
- "1"
- "0"
- "0"
- "0"
count: "1"
explicitBounds:
- 0.1
- 1
- 10
startTimeUnixNano: "1000000"
sum: 0.000001
timeUnixNano: "2000000"
name: traces_service_graph_request_client_seconds
scope:
name: traces_service_graph
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ resourceMetrics:
- 1
- 10
startTimeUnixNano: "1000000"
sum: 0
sum: 0.000001
timeUnixNano: "2000000"
name: traces_service_graph_request_server_seconds
- histogram:
Expand Down Expand Up @@ -89,7 +89,7 @@ resourceMetrics:
- 1
- 10
startTimeUnixNano: "1000000"
sum: 1e-06
sum: 0.000000
timeUnixNano: "2000000"
name: traces_service_graph_request_client_seconds
scope:
Expand Down

0 comments on commit 7660963

Please sign in to comment.