Skip to content

Commit 00fb953

Browse files
committed
[pkg/stanza] Switch to faster json parser lib for container operator
Signed-off-by: ChrsMark <[email protected]>
1 parent f5d54da commit 00fb953

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: pkg/stanza
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Switch to faster json parser lib for container operator
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [33929]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

pkg/stanza/operator/parser/container/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"sync"
99

10-
jsoniter "github.com/json-iterator/go"
1110
"go.opentelemetry.io/collector/component"
1211

1312
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/entry"
@@ -81,7 +80,6 @@ func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error
8180
p := &Parser{
8281
ParserOperator: parserOperator,
8382
recombineParser: recombineParser,
84-
json: jsoniter.ConfigFastest,
8583
format: c.Format,
8684
addMetadataFromFilepath: c.AddMetadataFromFilePath,
8785
crioLogEmitter: cLogEmitter,

pkg/stanza/operator/parser/container/parser.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"sync"
1313
"time"
1414

15-
jsoniter "github.com/json-iterator/go"
15+
"github.com/goccy/go-json"
1616
"go.uber.org/zap"
1717

1818
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/timeutils"
@@ -58,7 +58,6 @@ type Parser struct {
5858
helper.ParserOperator
5959
recombineParser operator.Operator
6060
format string
61-
json jsoniter.API
6261
addMetadataFromFilepath bool
6362
crioLogEmitter *helper.LogEmitter
6463
asyncConsumerStarted bool
@@ -243,7 +242,7 @@ func (p *Parser) parseDocker(value any) (any, error) {
243242
}
244243

245244
parsedValue := make(map[string]any)
246-
err := p.json.UnmarshalFromString(raw, &parsedValue)
245+
err := json.Unmarshal([]byte(raw), &parsedValue)
247246
if err != nil {
248247
return nil, err
249248
}

0 commit comments

Comments
 (0)