Skip to content

Commit

Permalink
fix(server): fix span-naming and empty-attributes rules (#3403)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc authored Nov 27, 2023
1 parent 83bb2f1 commit b46d547
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 2 additions & 4 deletions server/linter/rules/ensure_span_naming_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ func (r ensureSpanNamingRule) validateSpanName(ctx context.Context, span *traces

func (r ensureSpanNamingRule) validateHTTPSpanName(ctx context.Context, span *traces.Span) analyzer.Result {
expectedName := ""
if span.Kind == traces.SpanKindServer {
expectedName = fmt.Sprintf("%s %s", span.Attributes.Get("http.method"), span.Attributes.Get("http.route"))
}

if span.Kind == traces.SpanKindClient {
expectedName = span.Attributes.Get("http.method")
} else {
expectedName = fmt.Sprintf("%s %s", span.Attributes.Get("http.method"), span.Attributes.Get("http.route"))
}

if span.Name != expectedName {
Expand Down
5 changes: 4 additions & 1 deletion server/traces/span_entitiess.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ func (span Span) setMetadataAttributes() Span {

if span.Status != nil {
span.Attributes.Set(TracetestMetadataFieldStatusCode, span.Status.Code)
span.Attributes.Set(TracetestMetadataFieldStatusDescription, span.Status.Description)

if span.Status.Description != "" {
span.Attributes.Set(TracetestMetadataFieldStatusDescription, span.Status.Description)
}
}

return span
Expand Down

0 comments on commit b46d547

Please sign in to comment.