Skip to content

Commit 58e7e16

Browse files
committed
feat(backend): fix
1 parent d051f4c commit 58e7e16

File tree

1 file changed

+12
-2
lines changed
  • backend/modules/observability/infra/config

1 file changed

+12
-2
lines changed

backend/modules/observability/infra/config/trace.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/coze-dev/coze-loop/backend/modules/observability/domain/component/config"
1111
"github.com/coze-dev/coze-loop/backend/modules/observability/domain/trace/entity/loop_span"
1212
"github.com/coze-dev/coze-loop/backend/pkg/conf"
13+
"github.com/coze-dev/coze-loop/backend/pkg/json"
1314
"github.com/coze-dev/coze-loop/backend/pkg/logs"
1415
)
1516

@@ -53,8 +54,17 @@ func (t *TraceConfigCenter) GetPlatformTenants(ctx context.Context) (*config.Pla
5354

5455
func (t *TraceConfigCenter) GetPlatformSpansTrans(ctx context.Context, platformType loop_span.PlatformType) (loop_span.SpanTransCfgList, error) {
5556
cfg := new(config.SpanTransHandlerConfig)
56-
if err := t.UnmarshalKey(ctx, platformSpanHandlerCfgKey, cfg); err != nil {
57-
return nil, err
57+
val := t.Get(ctx, platformSpanHandlerCfgKey)
58+
if val == nil {
59+
return nil, fmt.Errorf("config not found")
60+
}
61+
strVal, ok := val.(string)
62+
if !ok {
63+
return nil, fmt.Errorf("config not string")
64+
}
65+
// unmarshal to avoid data race
66+
if err := json.Unmarshal([]byte(strVal), cfg); err != nil {
67+
return nil, fmt.Errorf("fail to unmarshal config: %v", err)
5868
}
5969
ret := cfg.PlatformCfg[string(platformType)]
6070
for _, inheritance := range cfg.PlatformInheritance[string(platformType)] {

0 commit comments

Comments
 (0)