-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[servicegraphprocessor, servicegraphconnector] Measure latency in seconds instead of milliseconds #27665
Merged
jpkrohling
merged 7 commits into
open-telemetry:main
from
mapno:servicegraph-fix-time-unit
Oct 24, 2023
Merged
[servicegraphprocessor, servicegraphconnector] Measure latency in seconds instead of milliseconds #27665
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4ee3a8b
[servicegraph] Measure latency in seconds
mapno a629a8a
chlog entry
mapno c6da52f
Update processor/servicegraphprocessor/processor.go
mapno f82f04f
Add tests for legacy unit
mapno 00dce30
Merge branch 'main' into servicegraph-fix-time-unit
jpkrohling 04696fa
Merge branch 'main' into servicegraph-fix-time-unit
jpkrohling 925ba08
Merge remote-tracking branch 'origin/main' into servicegraph-fix-time…
mapno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: bug_fix | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: servicegraphprocessor, servicegraphconnector | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Measure latency in seconds instead of milliseconds | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [27488] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | | ||
Measures latency in seconds instead of milliseconds, as the metric name indicates. | ||
Previously, milliseconds was used. | ||
This unit is still available via the feature gate `processor.servicegraph.legacyLatencyUnitMs`. | ||
This is a breaking change. | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,12 +122,10 @@ func TestConnectorShutdown(t *testing.T) { | |
} | ||
|
||
func TestProcessorConsume(t *testing.T) { | ||
// set virtual node feature | ||
_ = featuregate.GlobalRegistry().Set(virtualNodeFeatureGate.ID(), true) | ||
|
||
for _, tc := range []struct { | ||
name string | ||
cfg Config | ||
gates []*featuregate.Gate | ||
sampleTraces ptrace.Traces | ||
verifyMetrics func(t *testing.T, md pmetric.Metrics) | ||
}{ | ||
|
@@ -141,6 +139,7 @@ func TestProcessorConsume(t *testing.T) { | |
TTL: time.Nanosecond, | ||
}, | ||
}, sampleTraces: buildSampleTrace(t, "val"), | ||
gates: []*featuregate.Gate{virtualNodeFeatureGate}, | ||
verifyMetrics: verifyHappyCaseMetrics, | ||
}, | ||
{ | ||
|
@@ -153,6 +152,7 @@ func TestProcessorConsume(t *testing.T) { | |
TTL: time.Nanosecond, | ||
}, | ||
}, | ||
gates: []*featuregate.Gate{virtualNodeFeatureGate}, | ||
sampleTraces: incompleteClientTraces(), | ||
verifyMetrics: func(t *testing.T, md pmetric.Metrics) { | ||
v, ok := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Sum().DataPoints().At(0).Attributes().Get("server") | ||
|
@@ -170,6 +170,7 @@ func TestProcessorConsume(t *testing.T) { | |
TTL: time.Nanosecond, | ||
}, | ||
}, | ||
gates: []*featuregate.Gate{virtualNodeFeatureGate}, | ||
sampleTraces: incompleteServerTraces(false), | ||
verifyMetrics: func(t *testing.T, md pmetric.Metrics) { | ||
v, ok := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Sum().DataPoints().At(0).Attributes().Get("client") | ||
|
@@ -187,13 +188,32 @@ func TestProcessorConsume(t *testing.T) { | |
TTL: time.Nanosecond, | ||
}, | ||
}, | ||
gates: []*featuregate.Gate{virtualNodeFeatureGate}, | ||
sampleTraces: incompleteServerTraces(true), | ||
verifyMetrics: func(t *testing.T, md pmetric.Metrics) { | ||
assert.Equal(t, 0, md.MetricCount()) | ||
}, | ||
}, | ||
{ | ||
name: "complete traces with legacy latency metrics", | ||
cfg: Config{ | ||
MetricsExporter: "mock", | ||
Dimensions: []string{"some-attribute", "non-existing-attribute"}, | ||
Store: StoreConfig{ | ||
MaxItems: 10, | ||
TTL: time.Nanosecond, | ||
}, | ||
}, sampleTraces: buildSampleTrace(t, "val"), | ||
gates: []*featuregate.Gate{virtualNodeFeatureGate, legacyLatencyUnitMsFeatureGate}, | ||
verifyMetrics: verifyHappyCaseMetricsWithDuration(1000), | ||
}, | ||
} { | ||
t.Run(tc.name, func(t *testing.T) { | ||
// Set feature gates | ||
for _, gate := range tc.gates { | ||
require.NoError(t, featuregate.GlobalRegistry().Set(gate.ID(), true)) | ||
} | ||
|
||
// Prepare | ||
p := newProcessor(zaptest.NewLogger(t), &tc.cfg) | ||
p.tracesConsumer = consumertest.NewNop() | ||
|
@@ -222,11 +242,13 @@ func TestProcessorConsume(t *testing.T) { | |
|
||
// Shutdown the processor | ||
assert.NoError(t, p.Shutdown(context.Background())) | ||
|
||
// Unset feature gates | ||
for _, gate := range tc.gates { | ||
require.NoError(t, featuregate.GlobalRegistry().Set(gate.ID(), false)) | ||
} | ||
}) | ||
} | ||
|
||
// unset virtual node feature | ||
_ = featuregate.GlobalRegistry().Set(virtualNodeFeatureGate.ID(), false) | ||
} | ||
|
||
func TestConnectorConsume(t *testing.T) { | ||
|
@@ -257,27 +279,33 @@ func TestConnectorConsume(t *testing.T) { | |
} | ||
|
||
func verifyHappyCaseMetrics(t *testing.T, md pmetric.Metrics) { | ||
assert.Equal(t, 3, md.MetricCount()) | ||
verifyHappyCaseMetricsWithDuration(1)(t, md) | ||
} | ||
|
||
rms := md.ResourceMetrics() | ||
assert.Equal(t, 1, rms.Len()) | ||
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()) | ||
|
||
sms := rms.At(0).ScopeMetrics() | ||
assert.Equal(t, 1, sms.Len()) | ||
rms := md.ResourceMetrics() | ||
assert.Equal(t, 1, rms.Len()) | ||
|
||
ms := sms.At(0).Metrics() | ||
assert.Equal(t, 3, ms.Len()) | ||
sms := rms.At(0).ScopeMetrics() | ||
assert.Equal(t, 1, sms.Len()) | ||
|
||
mCount := ms.At(0) | ||
verifyCount(t, mCount) | ||
ms := sms.At(0).Metrics() | ||
assert.Equal(t, 3, ms.Len()) | ||
|
||
mServerDuration := ms.At(1) | ||
assert.Equal(t, "traces_service_graph_request_server_seconds", mServerDuration.Name()) | ||
verifyDuration(t, mServerDuration) | ||
mCount := ms.At(0) | ||
verifyCount(t, mCount) | ||
|
||
mClientDuration := ms.At(2) | ||
assert.Equal(t, "traces_service_graph_request_client_seconds", mClientDuration.Name()) | ||
verifyDuration(t, mClientDuration) | ||
mServerDuration := ms.At(1) | ||
assert.Equal(t, "traces_service_graph_request_server_seconds", mServerDuration.Name()) | ||
verifyDuration(t, mServerDuration, durationSum) | ||
|
||
mClientDuration := ms.At(2) | ||
assert.Equal(t, "traces_service_graph_request_client_seconds", mClientDuration.Name()) | ||
verifyDuration(t, mClientDuration, durationSum) | ||
} | ||
} | ||
|
||
func verifyCount(t *testing.T, m pmetric.Metric) { | ||
|
@@ -300,13 +328,13 @@ func verifyCount(t *testing.T, m pmetric.Metric) { | |
verifyAttr(t, attributes, "client_some-attribute", "val") | ||
} | ||
|
||
func verifyDuration(t *testing.T, m pmetric.Metric) { | ||
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, float64(1000), dp.Sum()) // Duration: 1sec | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be worthwhile to add some tests with the feature gate enabled to ensure we're getting the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added! |
||
assert.Equal(t, durationSum, dp.Sum()) // Duration: 1sec | ||
assert.Equal(t, uint64(1), dp.Count()) | ||
buckets := pcommon.NewUInt64Slice() | ||
buckets.FromRaw([]uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}) | ||
|
@@ -475,7 +503,7 @@ func TestUpdateDurationMetrics(t *testing.T) { | |
reqClientDurationSecondsSum: make(map[string]float64), | ||
reqClientDurationSecondsCount: make(map[string]uint64), | ||
reqClientDurationSecondsBucketCounts: make(map[string][]uint64), | ||
reqDurationBounds: defaultLatencyHistogramBucketsMs, | ||
reqDurationBounds: defaultLatencyHistogramBuckets, | ||
keyToMetric: make(map[string]metricSeries), | ||
config: &Config{ | ||
Dimensions: []string{}, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this is a breaking change, I think the change type is correctly set to bug fix.