Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reporter: do not add empty attributes #233

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions reporter/otlp_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ type traceEvents struct {

// attrKeyValue is a helper to populate Profile.attribute_table.
type attrKeyValue[T string | int64] struct {
key string
value T
key string
// Set to true for OTel SemConv attributes with requirement level: Required
required bool
rockdaboot marked this conversation as resolved.
Show resolved Hide resolved
value T
}

// OTLPReporter receives and transforms information to be OTLP/profiles compliant.
Expand Down Expand Up @@ -753,6 +755,9 @@ func addProfileAttributes[T string | int64](profile *profiles.Profile,

switch val := any(attr.value).(type) {
case string:
if !attr.required && val == "" {
return
}
attributeCompositeKey = attr.key + "_" + val
attributeValue = common.AnyValue{Value: &common.AnyValue_StringValue{StringValue: val}}
case int64:
Expand Down
20 changes: 1 addition & 19 deletions reporter/otlp_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,8 @@ func TestGetSampleAttributes(t *testing.T) {
},
},
attributeMap: make(map[string]uint64),
expectedIndices: [][]uint64{{0, 1, 2, 3}},
expectedIndices: [][]uint64{{0}},
expectedAttributeTable: []*common.KeyValue{
{
Key: "container.id",
Value: &common.AnyValue{
Value: &common.AnyValue_StringValue{StringValue: ""},
},
},
{
Key: "thread.name",
Value: &common.AnyValue{
Value: &common.AnyValue_StringValue{StringValue: ""},
},
},
{
Key: "service.name",
Value: &common.AnyValue{
Value: &common.AnyValue_StringValue{StringValue: ""},
},
},
{
Key: "process.pid",
Value: &common.AnyValue{
Expand Down