Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/service_graph_fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type:

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: servicegraphprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: fix servicegraph failed to find dimensions

# One or more tracking issues related to the change
issues: []

# (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:
68 changes: 27 additions & 41 deletions processor/servicegraphprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,6 @@ func (p *processor) updateSeries(key string, dimensions pcommon.Map) {
}
}

func (p *processor) dimensionsForSeries(key string) (pcommon.Map, bool) {
if series, ok := p.keyToMetric[key]; ok {
return series.dimensions, true
}

return pcommon.Map{}, false
}

func (p *processor) updateCountMetrics(key string) { p.reqTotal[key]++ }

func (p *processor) updateErrorMetrics(key string) { p.reqFailedTotal[key]++ }
Expand Down Expand Up @@ -363,51 +355,48 @@ func (p *processor) buildMetrics() (pmetric.Metrics, error) {
}

func (p *processor) collectCountMetrics(ilm pmetric.ScopeMetrics) error {
for key, c := range p.reqTotal {
mCount := ilm.Metrics().AppendEmpty()
mCount.SetName("traces_service_graph_request_total")
mCount.SetEmptySum().SetIsMonotonic(true)
// TODO: Support other aggregation temporalities
mCount.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)

dpCalls := mCount.Sum().DataPoints().AppendEmpty()
dpCalls.SetStartTimestamp(pcommon.NewTimestampFromTime(p.startTime))
dpCalls.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
dpCalls.SetIntValue(c)

dimensions, ok := p.dimensionsForSeries(key)
for key, series := range p.keyToMetric {
value, ok := p.reqTotal[key]
if !ok {
return fmt.Errorf("failed to find dimensions for key %s", key)
return fmt.Errorf("value not found in reqTotal by key %s", key)
}

dimensions.CopyTo(dpCalls.Attributes())
}

for key, c := range p.reqFailedTotal {
mCount := ilm.Metrics().AppendEmpty()
mCount.SetName("traces_service_graph_request_failed_total")
mCount.SetName("traces_service_graph_request_total")
mCount.SetEmptySum().SetIsMonotonic(true)
// TODO: Support other aggregation temporalities
mCount.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)

dpCalls := mCount.Sum().DataPoints().AppendEmpty()
dpCalls.SetStartTimestamp(pcommon.NewTimestampFromTime(p.startTime))
dpCalls.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
dpCalls.SetIntValue(c)

dimensions, ok := p.dimensionsForSeries(key)
if !ok {
return fmt.Errorf("failed to find dimensions for key %s", key)
dpCalls.SetIntValue(value)
series.dimensions.CopyTo(dpCalls.Attributes())

value, ok = p.reqFailedTotal[key]
if ok {
mCount = ilm.Metrics().AppendEmpty()
mCount.SetName("traces_service_graph_request_failed_total")
mCount.SetEmptySum().SetIsMonotonic(true)
// TODO: Support other aggregation temporalities
mCount.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)

dpCalls = mCount.Sum().DataPoints().AppendEmpty()
dpCalls.SetStartTimestamp(pcommon.NewTimestampFromTime(p.startTime))
dpCalls.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
dpCalls.SetIntValue(value)
series.dimensions.CopyTo(dpCalls.Attributes())
}

dimensions.CopyTo(dpCalls.Attributes())
}

return nil
}

func (p *processor) collectLatencyMetrics(ilm pmetric.ScopeMetrics) error {
for key := range p.reqDurationSecondsCount {
for key, series := range p.keyToMetric {
_, ok := p.reqDurationSecondsCount[key]
if !ok {
return fmt.Errorf("value not found in reqDurationSecondsCount by key %s", key)
}
mDuration := ilm.Metrics().AppendEmpty()
mDuration.SetName("traces_service_graph_request_duration_seconds")
// TODO: Support other aggregation temporalities
Expand All @@ -425,13 +414,10 @@ func (p *processor) collectLatencyMetrics(ilm pmetric.ScopeMetrics) error {

// TODO: Support exemplars

dimensions, ok := p.dimensionsForSeries(key)
if !ok {
return fmt.Errorf("failed to find dimensions for key %s", key)
}
series.dimensions.CopyTo(dpDuration.Attributes())

dimensions.CopyTo(dpDuration.Attributes())
}

return nil
}

Expand Down