slog.go ×16

Frontier kind: Joint frontier

unlabeled · c_9672f4b9b101

1 test · 477 LOC · 21 files · introduces 1 test · 57 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges57 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
100 ranges477 lines · 21 files · Browse complete extent
All tests (intent)
1 testBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationthrottle_logger.go ×1 · 2 introduced LOCthrottle_logger.go ×1throttle_logger.go ×1 · 4 introduced LOCthrottle_logger.go ×1throttle_logger.go ×1 · 4 introduced LOCthrottle_logger.go ×1dynamic_rate_limiter_impl.go ×1 · 4 introduced LOCdynamic_rate_limiter_imp…throttle_logger.go ×2 · 8 introduced LOCthrottle_logger.go ×2slog.go ×2 · 4 introduced LOCslog.go ×2dynamic_rate_limiter_impl.go ×1 · 10 introduced LOCdynamic_rate_limiter_imp…rate_burst.go ×6 · 13 introduced LOCrate_burst.go ×6zap_logger.go ×6 · 24 introduced LOCzap_logger.go ×6zap_logger.go ×1 · 6 introduced LOCzap_logger.go ×1zap_logger.go ×1 · 1 introduced LOCzap_logger.go ×1zap_logger.go ×4 · 12 introduced LOCzap_logger.go ×4slog.go ×4 · 9 introduced LOCslog.go ×4zap_tag.go ×1 · 6 introduced LOCzap_tag.go ×1rate_burst.go ×3 · 9 introduced LOCrate_burst.go ×3with_logger.go ×1 · 2 introduced LOCwith_logger.go ×1zap_logger.go ×1 · 2 introduced LOCzap_logger.go ×1zap_logger.go ×1 · 7 introduced LOCzap_logger.go ×1tags.go ×1 · 3 introduced LOCtags.go ×1with_logger.go ×1 · 2 introduced LOCwith_logger.go ×1zap_logger.go ×1 · 7 introduced LOCzap_logger.go ×1tags.go ×9 · 37 introduced LOCtags.go ×9cluster.pb.go ×2 · 200 introduced LOCcluster.pb.go ×2dynamic_rate_limiter_impl.go ×2 · 3 introduced LOCdynamic_rate_limiter_imp…TestClockedRateLimiter_Allow_NoQuota · 0 introduced LOCTestClockedRateLimiter_A…dynamic_rate_limiter_impl.go ×1 · 10 introduced LOCdynamic_rate_limiter_imp…clocked_rate_limiter.go ×1 · 3 introduced LOCclocked_rate_limiter.go …rate_limiter_impl.go ×1 · 12 introduced LOCrate_limiter_impl.go ×1clocked_rate_limiter.go ×1 · 3 introduced LOCclocked_rate_limiter.go …time_source.go ×1 · 3 introduced LOCtime_source.go ×1clocked_rate_limiter.go ×1 · 7 introduced LOCclocked_rate_limiter.go …time_source.go ×1 · 3 introduced LOCtime_source.go ×1TestOperatorServiceMetadata, TestWorkflowServiceMetadata · 0 introduced LOCTestOperatorServiceMetad…go.temporal.io/server/api/enums/v1/cluster.pb.go · 233 LOCv1/cluster.pb.gogo.temporal.io/server/api/enums/v1/common.pb.go · 288 LOCv1/common.pb.gogo.temporal.io/server/api/enums/v1/dlq.pb.go · 211 LOCv1/dlq.pb.gogo.temporal.io/server/api/enums/v1/fairness_state.pb.go · 147 LOCv1/fairness_state.pb.gogo.temporal.io/server/api/enums/v1/nexus.pb.go · 182 LOCv1/nexus.pb.gogo.temporal.io/server/api/enums/v1/predicate.pb.go · 194 LOCv1/predicate.pb.gogo.temporal.io/server/api/enums/v1/replication.pb.go · 338 LOCv1/replication.pb.gogo.temporal.io/server/api/enums/v1/task.pb.go · 480 LOCv1/task.pb.gogo.temporal.io/server/api/enums/v1/workflow.pb.go · 299 LOCv1/workflow.pb.gogo.temporal.io/server/api/enums/v1/workflow_task_type.pb.go · 148 LOCv1/workflow_task_type.pb…go.temporal.io/server/common/clock/time_source.go · 56 LOCclock/time_source.gogo.temporal.io/server/common/log/slog.go · 188 LOClog/slog.gogo.temporal.io/server/common/log/tag/tags.go · 1039 LOCtag/tags.gogo.temporal.io/server/common/log/tag/zap_tag.go · 242 LOCtag/zap_tag.gogo.temporal.io/server/common/log/throttle_logger.go · 101 LOClog/throttle_logger.gogo.temporal.io/server/common/log/with_logger.go · 68 LOClog/with_logger.gogo.temporal.io/server/common/log/zap_logger.go · 318 LOClog/zap_logger.gogo.temporal.io/server/common/quotas/clocked_rate_limiter.go · 170 LOCquotas/clocked_rate_limi…go.temporal.io/server/common/quotas/dynamic_rate_limiter_impl.go · 150 LOCquotas/dynamic_rate_limi…go.temporal.io/server/common/quotas/rate_burst.go · 206 LOCquotas/rate_burst.gogo.temporal.io/server/common/quotas/rate_limiter_impl.go · 115 LOCquotas/rate_limiter_impl…TestOperatorServiceMetadata · introduced test · go.temporal.io/server/common/api/TestOperatorServiceMetadataTestOperatorServiceMetad…TestWorkflowServiceMetadata · introduced test · go.temporal.io/server/common/api/TestWorkflowServiceMetadataTestWorkflowServiceMetad…TestNewRealClock_Now · introduced test · go.temporal.io/server/common/clock/TestNewRealClock_NowTestNewRealClock_NowTestSlogFromLayeredLogger · introduced test · go.temporal.io/server/common/log/TestSlogFromLayeredLoggerTestSlogFromLayeredLogge…TestClockedRateLimiter_Allow_NoQuota · introduced test · go.temporal.io/server/common/quotas/TestClockedRateLimiter_Allow_NoQuotaTestClockedRateLimiter_A…Focused concept · slog.go ×16 · 57 introduced LOCslog.go ×16

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 57 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/log/slog.go 52 introduced LOC · 16 ranges

Open complete file

37
38 // Enabled reports whether the handler handles records at the given level.
39 > func (h *handler) Enabled(_ context.Context, level slog.Level) bool { slog.go
40 > if h.zapLogger == nil {
41 return true
42 }
43 > return h.zapLogger.Core().Enabled(convertSlogToZapLevel(level)) slog.go
44 }
45
46 // Handle implements slog.Handler.
47 > func (h *handler) Handle(_ context.Context, record slog.Record) error { slog.go
48 > tags := make([]tag.Tag, len(h.tags), len(h.tags)+record.NumAttrs())
49 > copy(tags, h.tags)
50 > record.Attrs(func(attr slog.Attr) bool {
51 > tags = append(tags, tag.Zap(convertAttrToField(h.prependGroup(attr))))
52 > return true
53 > })
54 // Not capturing the log location and stack trace here. We seem to not need this functionality since our zapLogger
55 // adds the logging-call-at tag.
56 > switch record.Level { slog.go
57 case slog.LevelDebug:
58 h.logger.Debug(record.Message, tags...)
59 > case slog.LevelInfo: slog.go
60 > h.logger.Info(record.Message, tags...)
61 case slog.LevelWarn:
62 h.logger.Warn(record.Message, tags...)
65 default:
66 }
67 > return nil slog.go
68 }
69
70 // WithAttrs implements slog.Handler.
71 > func (h *handler) WithAttrs(attrs []slog.Attr) slog.Handler { slog.go
72 > tags := make([]tag.Tag, len(h.tags), len(h.tags)+len(attrs))
73 > copy(tags, h.tags)
74 > for _, attr := range attrs {
75 > tags = append(tags, tag.Zap(convertAttrToField(h.prependGroup(attr))))
76 > }
77 > return &handler{logger: h.logger, zapLogger: h.zapLogger, tags: tags, group: h.group}
78 }
79
80 // WithGroup implements slog.Handler.
81 > func (h *handler) WithGroup(name string) slog.Handler { slog.go
82 > group := name
83 > if h.group != "" {
84 > group = h.group + "." + name
85 > }
86 > return &handler{logger: h.logger, zapLogger: h.zapLogger, tags: h.tags, group: group}
87 }
88
89 > func (h *handler) prependGroup(attr slog.Attr) slog.Attr { slog.go
90 > if h.group == "" {
91 > return attr
92 > }
93 > return slog.Attr{Key: h.group + "." + attr.Key, Value: attr.Value}
94 }
95
98 case *zapLogger:
99 return l.zl
100 > case *throttledLogger: slog.go
101 > return extractZapLogger(l.logger)
102 case *withLogger:
103 return extractZapLogger(l.logger)
111 case *zapLogger:
112 return l.Skip(skip)
113 > case *throttledLogger: slog.go
114 > return &throttledLogger{
115 > limiter: l.limiter,
116 > logger: withIncreasedSkip(l.logger, skip),
117 > }
118 case *withLogger:
119 return &withLogger{
129 // Note that there is some room between slog levels while zap levels are continuous, so we can't 1:1 map them.
130 // See also https://go.googlesource.com/proposal/+/master/design/56345-structured-logging.md?pli=1#levels
131 > func convertSlogToZapLevel(l slog.Level) zapcore.Level { slog.go
132 > switch {
133 case l >= slog.LevelError:
134 return zapcore.ErrorLevel
135 case l >= slog.LevelWarn:
136 return zapcore.WarnLevel
137 > case l >= slog.LevelInfo: slog.go
138 > return zapcore.InfoLevel
139 > default:
140 > return zapcore.DebugLevel
141 }
142 }
152 }
153
154 > func convertAttrToField(attr slog.Attr) zapcore.Field { slog.go
155 > if attr.Equal(slog.Attr{}) {
156 // Ignore empty attrs.
157 return zap.Skip()
158 }
159
160 > switch attr.Value.Kind() { slog.go
161 case slog.KindBool:
162 return zap.Bool(attr.Key, attr.Value.Bool())
165 case slog.KindFloat64:
166 return zap.Float64(attr.Key, attr.Value.Float64())
167 > case slog.KindInt64: slog.go
168 > return zap.Int64(attr.Key, attr.Value.Int64())
169 > case slog.KindString:
170 > return zap.String(attr.Key, attr.Value.String())
171 case slog.KindTime:
172 return zap.Time(attr.Key, attr.Value.Time())
go.temporal.io/server/common/log/tag/zap_tag.go 5 introduced LOC · 1 range

Open complete file

236 }
237
238 > func Zap(field zap.Field) ZapTag { zap_tag.go
239 > return ZapTag{
240 > field: field,
241 > }
242 > }