mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-09-23 11:43:13 +08:00
added dimensions for external calls and db calls
This commit is contained in:
parent
e24577b663
commit
381fcd710e
@ -42,19 +42,26 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Span struct {
|
type Span struct {
|
||||||
TraceId string
|
TraceId string
|
||||||
SpanId string
|
SpanId string
|
||||||
ParentSpanId string
|
ParentSpanId string
|
||||||
Name string
|
Name string
|
||||||
DurationNano uint64
|
DurationNano uint64
|
||||||
StartTimeUnixNano uint64
|
StartTimeUnixNano uint64
|
||||||
ServiceName string
|
ServiceName string
|
||||||
Kind int32
|
Kind int32
|
||||||
StatusCode int64
|
References []OtelSpanRef
|
||||||
References []OtelSpanRef
|
Tags []string
|
||||||
Tags []string
|
TagsKeys []string
|
||||||
TagsKeys []string
|
TagsValues []string
|
||||||
TagsValues []string
|
StatusCode int64
|
||||||
|
ExternalHttpMethod string
|
||||||
|
ExternalHttpUrl string
|
||||||
|
Component string
|
||||||
|
DBSystem string
|
||||||
|
DBName string
|
||||||
|
DBOperation string
|
||||||
|
PeerService string
|
||||||
}
|
}
|
||||||
|
|
||||||
type OtelSpanRef struct {
|
type OtelSpanRef struct {
|
||||||
@ -195,6 +202,39 @@ func byteSlice2string(byteSlice []byte) string {
|
|||||||
return hex.EncodeToString(byteSlice)
|
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 {
|
func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
|
||||||
|
|
||||||
durationNano := uint64(otelSpan.EndTime() - otelSpan.StartTime())
|
durationNano := uint64(otelSpan.EndTime() - otelSpan.StartTime())
|
||||||
@ -202,8 +242,6 @@ func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
|
|||||||
spanID_bytes := otelSpan.SpanID().Bytes()
|
spanID_bytes := otelSpan.SpanID().Bytes()
|
||||||
parentSpanID_bytes := otelSpan.ParentSpanID().Bytes()
|
parentSpanID_bytes := otelSpan.ParentSpanID().Bytes()
|
||||||
|
|
||||||
var statusCode int64
|
|
||||||
|
|
||||||
attributes := otelSpan.Attributes()
|
attributes := otelSpan.Attributes()
|
||||||
|
|
||||||
var tags []string
|
var tags []string
|
||||||
@ -217,9 +255,6 @@ func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
|
|||||||
} else {
|
} else {
|
||||||
tag = fmt.Sprintf("%s:%s", k, v.StringVal())
|
tag = fmt.Sprintf("%s:%s", k, v.StringVal())
|
||||||
}
|
}
|
||||||
if k == "http.status_code" {
|
|
||||||
statusCode = v.IntVal()
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = append(tags, tag)
|
tags = append(tags, tag)
|
||||||
tagsKeys = append(tagsKeys, k)
|
tagsKeys = append(tagsKeys, k)
|
||||||
@ -228,7 +263,7 @@ func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
|
|||||||
|
|
||||||
references, _ := makeJaegerProtoReferences(otelSpan.Links(), otelSpan.ParentSpanID(), otelSpan.TraceID())
|
references, _ := makeJaegerProtoReferences(otelSpan.Links(), otelSpan.ParentSpanID(), otelSpan.TraceID())
|
||||||
|
|
||||||
return &Span{
|
var span *Span = &Span{
|
||||||
TraceId: hex.EncodeToString(traceID_bytes[:]),
|
TraceId: hex.EncodeToString(traceID_bytes[:]),
|
||||||
SpanId: hex.EncodeToString(spanID_bytes[:]),
|
SpanId: hex.EncodeToString(spanID_bytes[:]),
|
||||||
ParentSpanId: hex.EncodeToString(parentSpanID_bytes[:]),
|
ParentSpanId: hex.EncodeToString(parentSpanID_bytes[:]),
|
||||||
@ -237,12 +272,15 @@ func newStructuredSpan(otelSpan pdata.Span, ServiceName string) *Span {
|
|||||||
DurationNano: durationNano,
|
DurationNano: durationNano,
|
||||||
ServiceName: ServiceName,
|
ServiceName: ServiceName,
|
||||||
Kind: int32(otelSpan.Kind()),
|
Kind: int32(otelSpan.Kind()),
|
||||||
StatusCode: statusCode,
|
|
||||||
References: references,
|
References: references,
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
TagsKeys: tagsKeys,
|
TagsKeys: tagsKeys,
|
||||||
TagsValues: tagsValues,
|
TagsValues: tagsValues,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
populateOtherDimensions(attributes, span)
|
||||||
|
|
||||||
|
return span
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceNameForResource gets the service name for a specified Resource.
|
// ServiceNameForResource gets the service name for a specified Resource.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user