Skip to content

Commit

Permalink
fix: use trace to export Spandata (#292)
Browse files Browse the repository at this point in the history
* fix: use trace to export Spandata

Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>

* doc: update changelog

Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
  • Loading branch information
NeJan2020 authored Jul 27, 2022
1 parent c201994 commit 650f8b6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Add a new environment variable: IS_PRINT_EVENT. When the value is true, sinsp events can be printed to the stdout. ([#283](https://github.com/CloudDectective-Harmonycloud/kindling/pull/283))
- Declare the 9500 port in the agent's deployment file ([#282](https://github.com/CloudDectective-Harmonycloud/kindling/pull/282))
### Bug fixes
- Fix the bug that need_trace_as_span options cannot take effect ([#292](https://github.com/CloudDectective-Harmonycloud/kindling/pull/292))
- Fix connection failure rate data lost when change topology layout in the Grafana plugin. ([#289](https://github.com/CloudDectective-Harmonycloud/kindling/pull/289))
- Fix the bug that the external topologys' metric name is named with `kindling_entity_request` prefix. Change the prefix of these metrics to `kindling_topology_request` ([#287](https://github.com/CloudDectective-Harmonycloud/kindling/pull/287))
- Fix the bug where the table name of SQL is missed if there is no trailing character at the end of the table name. ([#284](https://github.com/CloudDectective-Harmonycloud/kindling/pull/284))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ func (n *NetMetricGroupAdapter) dealWithSingleMetricGroup(dataGroup *model.DataG
results := make([]*AdaptedResult, 0, 2)
if n.StoreTraceAsMetric {
// Since TraceAsMetric has to be aggregated again, the attrType of TraceAsMetric must be `AttributeMap`
results = append(results, createResult(
results = append(results, createMetric(
[]*model.Metric{model.NewMetric(constnames.TraceAsMetric, requestTotalTime.GetData())},
dataGroup, n.traceToMetricAdapter,
AttributeMap))
}
if n.StoreTraceAsSpan {
results = append(results, createResult([]*model.Metric{requestTotalTime}, dataGroup, n.traceToSpanAdapter, attrType))
results = append(results, createTrace([]*model.Metric{requestTotalTime}, dataGroup, n.traceToSpanAdapter, attrType))
}
return results
}
Expand Down Expand Up @@ -92,15 +92,15 @@ func (n *NetMetricGroupAdapter) createNetMetricResults(dataGroup *model.DataGrou
}
tmpResults = make([]*AdaptedResult, 0, 2)
if len(metricsExceptRequestCount) > 0 {
tmpResults = append(tmpResults, createResult(metricsExceptRequestCount, dataGroup, adapter[0], attrType))
tmpResults = append(tmpResults, createMetric(metricsExceptRequestCount, dataGroup, adapter[0], attrType))
}
if len(requestCount) > 0 {
tmpResults = append(tmpResults, createResult(requestCount, dataGroup, adapter[1], attrType))
tmpResults = append(tmpResults, createMetric(requestCount, dataGroup, adapter[1], attrType))
}
return
}

func createResult(metrics []*model.Metric, dataGroup *model.DataGroup, adapter *LabelConverter, addrType AttrType) *AdaptedResult {
func createMetric(metrics []*model.Metric, dataGroup *model.DataGroup, adapter *LabelConverter, addrType AttrType) *AdaptedResult {
switch addrType {
case AttributeMap:
attrs, free := adapter.transform(dataGroup)
Expand All @@ -124,6 +124,30 @@ func createResult(metrics []*model.Metric, dataGroup *model.DataGroup, adapter *
return nil
}

func createTrace(metrics []*model.Metric, dataGroup *model.DataGroup, adapter *LabelConverter, addrType AttrType) *AdaptedResult {
switch addrType {
case AttributeMap:
attrs, free := adapter.transform(dataGroup)
return &AdaptedResult{
ResultType: Trace,
AttrsMap: attrs,
Metrics: metrics,
Timestamp: dataGroup.Timestamp,
FreeAttrsMap: free,
}
case AttributeList:
attrs, free := adapter.convert(dataGroup)
return &AdaptedResult{
ResultType: Trace,
AttrsList: attrs,
Metrics: metrics,
Timestamp: dataGroup.Timestamp,
FreeAttrsList: free,
}
}
return nil
}

type NetAdapterManager struct {
detailEntityAdapter [2]*LabelConverter
aggEntityAdapter [2]*LabelConverter
Expand Down

0 comments on commit 650f8b6

Please sign in to comment.