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

[chore] Improve startup error message #5978

Merged
merged 4 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge in upstream/main
  • Loading branch information
TylerHelmuth committed Aug 26, 2022
commit 6647d5787134be05d6b672a58d5827a67ecc3a91
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
### 🧰 Bug fixes 🧰

- Fix reading scope attributes for trace JSON, remove duplicate code. (#5930)
- otlpjson/trace: skip unknown fields instead of error. (#5931)
- Fix bug in setting the correct collector state after a configuration change event. (#5830)
- Fix json trace unmarshalling for numbers (#5924):
- Accept both string and number for float64.
Expand Down
25 changes: 18 additions & 7 deletions pdata/internal/json/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestReadScope(t *testing.T) {
name: "scope",
jsonStr: `{
"name": "name_value",
"version": "version_value",
"version": "version_value"
}`,
want: &otlpcommon.InstrumentationScope{
Name: "name_value",
Expand All @@ -48,22 +48,22 @@ func TestReadScope(t *testing.T) {
"attributes": [
{
"key":"string_key",
"value":{"stringValue": "value"}
"value":{ "stringValue": "value" }
},
{
"key":"bool_key",
"value":{"boolValue": true}
"value":{ "boolValue": true }
},
{
"key":"int_key",
"value":{"intValue": 314}
"value":{ "intValue": 314 }
},
{
"key":"double_key",
"value":{"doubleValue": 3.14}
"value":{ "doubleValue": 3.14 }
}
],
"dropped_attributes_count": 1,
"dropped_attributes_count": 1
}`,
want: &otlpcommon.InstrumentationScope{
Name: "my_name",
Expand Down Expand Up @@ -105,14 +105,25 @@ func TestReadScope(t *testing.T) {
DroppedAttributesCount: 1,
},
},
{
name: "unknown field",
jsonStr: `{
"name": "name_value",
"unknown": "version"
}`,
want: &otlpcommon.InstrumentationScope{
Name: "name_value",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
iter := jsoniter.ConfigFastest.BorrowIterator([]byte(tt.jsonStr))
defer jsoniter.ConfigFastest.ReturnIterator(iter)
got := &otlpcommon.InstrumentationScope{}
ReadScope(iter, got)
assert.EqualValues(t, tt.want, got)
assert.NoError(t, iter.Error)
assert.Equal(t, tt.want, got)
})
}
}
7 changes: 3 additions & 4 deletions pdata/ptrace/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,9 @@ func TestReadScopeSpansUnknownField(t *testing.T) {
jsonStr := `{"extra":""}`
iter := jsoniter.ConfigFastest.BorrowIterator([]byte(jsonStr))
defer jsoniter.ConfigFastest.ReturnIterator(iter)
readScopeSpans(iter)
if assert.Error(t, iter.Error) {
assert.Contains(t, iter.Error.Error(), "unknown field")
}
val := readScopeSpans(iter)
assert.NoError(t, iter.Error)
assert.Equal(t, &otlptrace.ScopeSpans{}, val)
}

func TestReadSpanUnknownField(t *testing.T) {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.