Skip to content

Commit

Permalink
feat: 增加 unify-query trace 打点 #1010158081115225233 (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamcleren authored Nov 21, 2023
1 parent 48eb270 commit 9ce11de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
12 changes: 8 additions & 4 deletions pkg/unify-query/query/infos/infos.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,14 @@ func makeInfluxQLList(
return nil, err
}
if len(condition) != 0 {
whereList.Append(
promql.AndOperator, promql.NewTextWhere(
promql.MakeOrExpression(structured.ConvertToPromBuffer(condition)),
))
influxdbCondition := structured.ConvertToPromBuffer(condition)
if len(influxdbCondition) > 0 {
whereList.Append(
promql.AndOperator, promql.NewTextWhere(
promql.MakeOrExpression(influxdbCondition),
))
}

}
// 增加时间维度查询,秒级转纳秒
if params.Start != "" && params.End != "" {
Expand Down
23 changes: 15 additions & 8 deletions pkg/unify-query/query/structured/query_ts.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,15 @@ func (q *Query) BuildMetadataQuery(
measurements = []string{measurement}

trace.InsertStringIntoSpan("tsdb-table-id", tsDB.TableID, span)
trace.InsertStringSliceIntoSpan("tsdb-field-list", tsDB.Field, span)
trace.InsertStringIntoSpan("tsdb-measurement-type", tsDB.MeasurementType, span)
trace.InsertStringIntoSpan("tsdb-filters", fmt.Sprintf("%+v", tsDB.Filters), span)
trace.InsertStringIntoSpan("tsdb-db", db, span)
trace.InsertStringIntoSpan("tsdb-data-label", tsDB.DataLabel, span)
trace.InsertStringIntoSpan("tsdb-storge-id", storageID, span)
trace.InsertStringIntoSpan("tsdb-cluster-name", clusterName, span)
trace.InsertStringIntoSpan("tsdb-tag-keys", fmt.Sprintf("%+v", tagKeys), span)
trace.InsertStringIntoSpan("tsdb-vm-rt", vmRt, span)
trace.InsertStringIntoSpan("tsdb-db", db, span)
trace.InsertStringIntoSpan("tsdb-measurements", fmt.Sprintf("%+v", measurements), span)

if q.Offset != "" {
Expand All @@ -373,14 +376,18 @@ func (q *Query) BuildMetadataQuery(
query.LabelsMatcher = append(query.LabelsMatcher, queryLabelsMatcher...)

// influxdb 查询特殊处理逻辑
whereList.Append(
promql.AndOperator,
promql.NewTextWhere(
promql.MakeOrExpression(
ConvertToPromBuffer(queryConditions),
influxdbConditions := ConvertToPromBuffer(queryConditions)
if len(influxdbConditions) > 0 {
whereList.Append(
promql.AndOperator,
promql.NewTextWhere(
promql.MakeOrExpression(
influxdbConditions,
),
),
),
)
)
}

}

switch tsDB.MeasurementType {
Expand Down

0 comments on commit 9ce11de

Please sign in to comment.