Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

added dimensions for external calls and db calls

Ankit Nayan381fcd710e15
diff --git a/pkg/processors/flattener/main.go b/pkg/processors/flattener/main.go
index 493a6bcb17..0e974ba2de 100644
--- a/pkg/processors/flattener/main.go
+++ b/pkg/processors/flattener/main.go
@@ -42,19 +42,26 @@ var (
)
type Span struct {
- TraceId string
- SpanId string
- ParentSpanId string
- Name string
- DurationNano uint64
- StartTimeUnixNano uint64
- ServiceName string
- Kind int32
- StatusCode int64
- References []OtelSpanRef
- Tags []string
- TagsKeys []string
- TagsValues []string
+ TraceId string
+ SpanId string
+ ParentSpanId string
+ Name string
+ DurationNano uint64
+ StartTimeUnixNano uint64
+ ServiceName string
+ Kind int32
+ References []OtelSpanRef
+ Tags []string
+ TagsKeys []string
+ TagsValues []string
+ StatusCode int64
+ ExternalHttpMethod string
+ ExternalHttpUrl string
+ Component string
+ DBSystem string
+ DBName string
+ DBOperation string
+ PeerService string
}
type OtelSpanRef struct {
@@ -195,6 +202,39 @@ func byteSlice2string(byteSlice []byte) string {
return hex.EncodeToString(byteSlice)
}
+func populateOtherDimensions(attributes pdata.AttributeMap, span *Span) {
+
+ attributes.ForEach(func(k string, v pdata.AttributeValue) {
+ if k == "http.status_code" {
+ span.StatusCode = v.IntVal()
+ }
+ if k == "http.url" {
+ span.ExternalHttpUrl = v.StringVal()
+ }
+ if k == "http.method" {
+ span.ExternalHttpMethod = v.StringVal()
+ }
+ if k == "component" {
+ span.Component = v.StringVal()
+ }
+
+ if k == "db.system" {
+ span.DBSystem = v.StringVal()
+ }
+ if k == "db.name" {
+ span.DBName = v.StringVal()
+ }
+ if k == "db.operation" {
+ span.DBOperation = v.StringVal()
+ }
+ if k == "peer.service" {
+ span.PeerService = v.StringVal()
+ }
+
+ })
+
+}
+
func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
durationNano := uint64(otelSpan.EndTime() - otelSpan.StartTime())
@@ -202,8 +242,6 @@ func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
spanID_bytes := otelSpan.SpanID().Bytes()
parentSpanID_bytes := otelSpan.ParentSpanID().Bytes()
- var statusCode int64
-
attributes := otelSpan.Attributes()
var tags []string
@@ -217,9 +255,6 @@ func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
} else {
tag = fmt.Sprintf("%s:%s", k, v.StringVal())
}
- if k == "http.status_code" {
- statusCode = v.IntVal()
- }
tags = append(tags, tag)
tagsKeys = append(tagsKeys, k)
@@ -228,7 +263,7 @@ func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
references, _ := makeJaegerProtoReferences(otelSpan.Links(), otelSpan.ParentSpanID(), otelSpan.TraceID())
- return &Span{
+ var span *Span = &Span{
TraceId: hex.EncodeToString(traceID_bytes[:]),
SpanId: hex.EncodeToString(spanID_bytes[:]),
ParentSpanId: hex.EncodeToString(parentSpanID_bytes[:]),
@@ -237,12 +272,15 @@ func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
DurationNano: durationNano,
ServiceName: ServiceName,
Kind: int32(otelSpan.Kind()),
- StatusCode: statusCode,
References: references,
Tags: tags,
TagsKeys: tagsKeys,
TagsValues: tagsValues,
}
+
+ populateOtherDimensions(attributes, span)
+
+ return span
}
// ServiceNameForResource gets the service name for a specified Resource.