Skip to content

Commit

Permalink
fix: update usage collection to remove deprecated param
Browse files Browse the repository at this point in the history
Also add ResourceTagsMap to trace model
  • Loading branch information
makeavish committed Jul 16, 2023
1 parent 8d74730 commit 3cb9250
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions exporter/clickhousetracesexporter/clickhouse_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ func newStructuredSpan(otelSpan ptrace.Span, ServiceName string, resource pcommo
Kind: int8(otelSpan.Kind()),
References: references,
TagMap: tagMap,
ResourceTagsMap: resourceAttrs,
StringTagMap: stringTagMap,
NumberTagMap: numberTagMap,
BoolTagMap: boolTagMap,
Expand Down
1 change: 1 addition & 0 deletions exporter/clickhousetracesexporter/schema-signoz.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type TraceModel struct {
References references `json:"references,omitempty"`
StatusCode int16 `json:"statusCode,omitempty"`
TagMap map[string]string `json:"tagMap,omitempty"`
ResourceTagsMap map[string]string `json:"resourceTagsMap,omitempty"`
StringTagMap map[string]string `json:"stringTagMap,omitempty"`
NumberTagMap map[string]float64 `json:"numberTagMap,omitempty"`
BoolTagMap map[string]bool `json:"boolTagMap,omitempty"`
Expand Down
8 changes: 5 additions & 3 deletions exporter/clickhousetracesexporter/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (w *SpanWriter) writeTagBatch(batchSpans []*Span) error {
)
if err != nil {
logBatch := batchSpans[:int(math.Min(10, float64(len(batchSpans))))]
w.logger.Error("Could not write to span attributes table due to error: ", zap.Error(err),zap.Any("batch", logBatch))
w.logger.Error("Could not write to span attributes table due to error: ", zap.Error(err), zap.Any("batch", logBatch))
return err
}

Expand Down Expand Up @@ -404,8 +404,10 @@ func (w *SpanWriter) writeModelBatch(batchSpans []*Span) error {
metrics := map[string]usage.Metric{}
for _, span := range batchSpans {
var serialized []byte

usageMap := span.TraceModel
usageMap.TagMap = map[string]string{}
serialized, err = json.Marshal(span.TraceModel)
serializedUsage, err := json.Marshal(usageMap)

if err != nil {
return err
Expand All @@ -417,7 +419,7 @@ func (w *SpanWriter) writeModelBatch(batchSpans []*Span) error {
return err
}

usage.AddMetric(metrics, *span.Tenant, 1, int64(len(serialized)))
usage.AddMetric(metrics, *span.Tenant, 1, int64(len(serializedUsage)))
}
start := time.Now()

Expand Down

0 comments on commit 3cb9250

Please sign in to comment.