1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

Add non-empty string check for attribute keys (#1659)

* Fixes #1657 Add non-empty string check for attribute keys

* Update PR number in changelog

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update sdk/trace/span.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
Veera Pirla
2021-03-08 22:54:29 +05:30
committed by GitHub
parent e9b9aca8a6
commit 238e7c61ba
3 changed files with 40 additions and 1 deletions

View File

@@ -491,7 +491,9 @@ func (s *span) copyToCappedAttributes(attributes ...attribute.KeyValue) {
s.mu.Lock()
defer s.mu.Unlock()
for _, a := range attributes {
if a.Value.Type() != attribute.INVALID {
// Ensure attributes conform to the specification:
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.0.1/specification/common/common.md#attributes
if a.Value.Type() != attribute.INVALID && a.Key != "" {
s.attributes.add(a)
}
}