Skip to content

Commit

Permalink
Add isRemote column to signoz_index_v2 table (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Mar 13, 2024
1 parent 125f938 commit c314be2
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 62 deletions.
17 changes: 16 additions & 1 deletion exporter/clickhousetracesexporter/clickhouse_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ import (
"go.uber.org/zap"
)

const (
hasIsRemoteMask uint32 = 0x00000100
isRemoteMask uint32 = 0x00000200
)

// Crete new exporter.
func newExporter(cfg component.Config, logger *zap.Logger) (*storage, error) {

Expand Down Expand Up @@ -276,6 +281,15 @@ func populateTraceModel(span *Span) {
func newStructuredSpan(otelSpan ptrace.Span, ServiceName string, resource pcommon.Resource, config storageConfig) *Span {
durationNano := uint64(otelSpan.EndTimestamp() - otelSpan.StartTimestamp())

isRemote := "unknown"
flags := otelSpan.Flags()
if flags&hasIsRemoteMask != 0 {
isRemote = "no"
if flags&isRemoteMask != 0 {
isRemote = "yes"
}
}

attributes := otelSpan.Attributes()
resourceAttributes := resource.Attributes()
tagMap := map[string]string{}
Expand Down Expand Up @@ -378,7 +392,8 @@ func newStructuredSpan(otelSpan ptrace.Span, ServiceName string, resource pcommo
BoolTagMap: boolTagMap,
HasError: false,
},
Tenant: &tenant,
Tenant: &tenant,
IsRemote: isRemote,
}

if otelSpan.Status().Code() == ptrace.StatusCodeError {
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 @@ -115,6 +115,7 @@ type Span struct {
BoolTagMap map[string]bool `json:"boolTagMap,omitempty"`
ResourceTagsMap map[string]string `json:"resourceTagsMap,omitempty"`
HasError bool `json:"hasError,omitempty"`
IsRemote string `json:"isRemote,omitempty"`
TraceModel TraceModel `json:"traceModel,omitempty"`
GRPCCode string `json:"gRPCCode,omitempty"`
GRPCMethod string `json:"gRPCMethod,omitempty"`
Expand Down
6 changes: 2 additions & 4 deletions exporter/clickhousetracesexporter/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (w *SpanWriter) writeIndexBatch(ctx context.Context, batchSpans []*Span) er
span.NumberTagMap,
span.BoolTagMap,
span.ResourceTagsMap,
span.IsRemote,
)
if err != nil {
w.logger.Error("Could not append span to batch: ", zap.Object("span", span), zap.Error(err))
Expand Down Expand Up @@ -345,10 +346,7 @@ func (w *SpanWriter) writeErrorBatch(ctx context.Context, batchSpans []*Span) er
}

func stringToBool(s string) bool {
if strings.ToLower(s) == "true" {
return true
}
return false
return strings.ToLower(s) == "true"
}

func (w *SpanWriter) writeModelBatch(ctx context.Context, batchSpans []*Span) error {
Expand Down
36 changes: 18 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ require (
go.opentelemetry.io/collector/extension/zpagesextension v0.88.0
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0017
go.opentelemetry.io/collector/otelcol v0.88.0
go.opentelemetry.io/collector/pdata v1.0.0-rcv0017
go.opentelemetry.io/collector/pdata v1.3.0
go.opentelemetry.io/collector/processor v0.88.0
go.opentelemetry.io/collector/processor/batchprocessor v0.88.0
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.88.0
Expand All @@ -173,13 +173,13 @@ require (
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.26.0
golang.org/x/text v0.14.0
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
google.golang.org/grpc v1.62.0
google.golang.org/protobuf v1.32.0
gopkg.in/yaml.v2 v2.4.0
)

require (
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.4-0.20230617002413-005d2dfb6b68 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
Expand Down Expand Up @@ -235,7 +235,7 @@ require (
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/checkpoint-restore/go-criu/v5 v5.3.0 // indirect
github.com/cilium/ebpf v0.7.0 // indirect
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 // indirect
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/containerd/ttrpc v1.1.0 // indirect
github.com/coreos/go-oidc v2.2.1+incompatible // indirect
Expand All @@ -250,8 +250,8 @@ require (
github.com/docker/go-units v0.5.0 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/envoyproxy/go-control-plane v0.11.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
github.com/envoyproxy/go-control-plane v0.12.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
Expand Down Expand Up @@ -280,7 +280,7 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/gophercloud/gophercloud v1.5.0 // indirect
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
Expand Down Expand Up @@ -404,14 +404,14 @@ require (
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.147.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/api v0.149.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
Expand Down Expand Up @@ -503,7 +503,7 @@ require (
github.com/shirou/gopsutil/v3 v3.23.9 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand All @@ -527,13 +527,13 @@ require (
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/sdk v1.22.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.19.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.16.0 // indirect
gonum.org/v1/gonum v0.14.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
Loading

0 comments on commit c314be2

Please sign in to comment.