Skip to content

Commit c9fdef1

Browse files
drfloobcopybara-github
authored andcommitted
[logging] Centralize configuration for trace flags (grpc#36576)
All TraceFlags are now configured in `src/core/lib/debug/trace_flags.yaml`. The format is: ``` my_flag: default: false # the default value; default=false description: Some Description debug_only: false # debug_only flags only work in debug builds; default=false internal: false # internal flags will not show up in documentation; default=false ``` To regenerate the trace flag source code, run `tools/codegen/core/gen_trace_flags.py` (requires mako). This script is also run when sanity checking. This PR also adds two new features: ### Glob-based flag configuration Trace flag configuration now supports `?` (single wildcard character) and `*` (one or more wildcard characters). For example, using `GRPC_TRACE='event_engine*'` will enable all flags that match that glob. It expands to: * event_engine * event_engine_client_channel_resolver * event_engine_dns * event_engine_endpoint * event_engine_endpoint_data * event_engine_poller ### A cleaner trace-logging macro in abseil logging format If your goal is only to add log statements when the `fault_injection_filter` trace flag is enabled, you can use the macro: ``` GRPC_TRACE_LOG(fault_injection, INFO) << "Filtered:" << 42; ``` When the trace flag is enabled, the the log will show something like this: ``` I0000 00:00:1715733657.430042 16 file.cc:174] Filtered:42 ``` ---- Note: just like with the gpr_log to abseil logging conversion, the pre-existing trace logging usages can be replaced with the new tracing macro across multiple PRs. Closes grpc#36576 PiperOrigin-RevId: 641295215
1 parent d63dcc1 commit c9fdef1

File tree

258 files changed

+4768
-4854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+4768
-4854
lines changed

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ src/core/lib/experiments/experiments.h linguist-generated=true
3535
src/core/lib/experiments/experiments.cc linguist-generated=true
3636
bazel/experiments.bzl linguist-generated=true
3737
test/cpp/microbenchmarks/huffman_geometries/** linguist-generated=true
38+
doc/trace_flags.md linguist-generated=true
39+
src/core/lib/debug/trace_flags.h linguist-generated=true
40+
src/core/lib/debug/trace_flags.cc linguist-generated=true
41+
src/python/grpcio_observability/observability_lib_deps.py linguist-generated=true

BUILD

+13-43
Original file line numberDiff line numberDiff line change
@@ -1408,17 +1408,6 @@ grpc_cc_library(
14081408
],
14091409
)
14101410

1411-
grpc_cc_library(
1412-
name = "call_trace",
1413-
hdrs = [
1414-
"//src/core:lib/surface/call_trace.h",
1415-
],
1416-
language = "c++",
1417-
deps = [
1418-
"grpc_trace",
1419-
],
1420-
)
1421-
14221411
grpc_cc_library(
14231412
name = "dynamic_annotations",
14241413
hdrs = [
@@ -1487,9 +1476,6 @@ grpc_cc_library(
14871476

14881477
grpc_cc_library(
14891478
name = "api_trace",
1490-
srcs = [
1491-
"//src/core:lib/surface/api_trace.cc",
1492-
],
14931479
hdrs = [
14941480
"//src/core:lib/surface/api_trace.h",
14951481
],
@@ -1536,7 +1522,6 @@ grpc_cc_library(
15361522
"//src/core:lib/iomgr/ev_epoll1_linux.cc",
15371523
"//src/core:lib/iomgr/ev_poll_posix.cc",
15381524
"//src/core:lib/iomgr/ev_posix.cc",
1539-
"//src/core:lib/iomgr/ev_windows.cc",
15401525
"//src/core:lib/iomgr/fork_posix.cc",
15411526
"//src/core:lib/iomgr/fork_windows.cc",
15421527
"//src/core:lib/iomgr/gethostname_fallback.cc",
@@ -1714,7 +1699,6 @@ grpc_cc_library(
17141699
"//src/core:posix_event_engine_endpoint",
17151700
"//src/core:resolved_address",
17161701
"//src/core:resource_quota",
1717-
"//src/core:resource_quota_trace",
17181702
"//src/core:slice",
17191703
"//src/core:slice_buffer",
17201704
"//src/core:slice_cast",
@@ -2049,7 +2033,6 @@ grpc_cc_library(
20492033
deps = [
20502034
"api_trace",
20512035
"call_combiner",
2052-
"call_trace",
20532036
"call_tracer",
20542037
"channel",
20552038
"channel_arg_names",
@@ -2086,7 +2069,6 @@ grpc_cc_library(
20862069
"//src/core:channel_args_preconditioning",
20872070
"//src/core:channel_fwd",
20882071
"//src/core:channel_init",
2089-
"//src/core:channel_stack_trace",
20902072
"//src/core:channel_stack_type",
20912073
"//src/core:closure",
20922074
"//src/core:compression",
@@ -2116,7 +2098,6 @@ grpc_cc_library(
21162098
"//src/core:pipe",
21172099
"//src/core:poll",
21182100
"//src/core:promise_status",
2119-
"//src/core:promise_trace",
21202101
"//src/core:race",
21212102
"//src/core:ref_counted",
21222103
"//src/core:seq",
@@ -2312,7 +2293,6 @@ grpc_cc_library(
23122293
visibility = ["@grpc:public"],
23132294
deps = [
23142295
"api_trace",
2315-
"call_trace",
23162296
"channel_arg_names",
23172297
"channelz",
23182298
"config",
@@ -2348,7 +2328,6 @@ grpc_cc_library(
23482328
"//src/core:poll",
23492329
"//src/core:ref_counted",
23502330
"//src/core:resource_quota",
2351-
"//src/core:resource_quota_trace",
23522331
"//src/core:seq",
23532332
"//src/core:slice",
23542333
"//src/core:slice_refcount",
@@ -3006,18 +2985,28 @@ grpc_cc_library(
30062985

30072986
grpc_cc_library(
30082987
name = "grpc_trace",
3009-
srcs = ["//src/core:lib/debug/trace.cc"],
3010-
hdrs = ["//src/core:lib/debug/trace.h"],
2988+
srcs = [
2989+
"//src/core:lib/debug/trace.cc",
2990+
"//src/core:lib/debug/trace_flags.cc",
2991+
],
2992+
hdrs = [
2993+
"//src/core:lib/debug/trace.h",
2994+
"//src/core:lib/debug/trace_flags.h",
2995+
"//src/core:lib/debug/trace_impl.h",
2996+
],
30112997
external_deps = [
3012-
"absl/log:log",
2998+
"absl/log",
30132999
"absl/strings",
3000+
"absl/container:flat_hash_map",
30143001
],
30153002
language = "c++",
30163003
visibility = ["@grpc:trace"],
30173004
deps = [
30183005
"config_vars",
30193006
"gpr",
30203007
"grpc_public_hdrs",
3008+
"//src/core:glob",
3009+
"//src/core:no_destruct",
30213010
],
30223011
)
30233012

@@ -4314,7 +4303,6 @@ grpc_cc_library(
43144303
language = "c++",
43154304
visibility = ["@grpc:http"],
43164305
deps = [
4317-
"call_trace",
43184306
"call_tracer",
43194307
"channel_arg_names",
43204308
"config",
@@ -4531,20 +4519,6 @@ grpc_cc_library(
45314519
deps = ["gpr"],
45324520
)
45334521

4534-
grpc_cc_library(
4535-
name = "http_trace",
4536-
srcs = [
4537-
"//src/core:ext/transport/chttp2/transport/http_trace.cc",
4538-
],
4539-
hdrs = [
4540-
"//src/core:ext/transport/chttp2/transport/http_trace.h",
4541-
],
4542-
deps = [
4543-
"gpr_platform",
4544-
"grpc_trace",
4545-
],
4546-
)
4547-
45484522
grpc_cc_library(
45494523
name = "hpack_parser_table",
45504524
srcs = [
@@ -4565,7 +4539,6 @@ grpc_cc_library(
45654539
"gpr_platform",
45664540
"grpc_trace",
45674541
"hpack_parse_result",
4568-
"http_trace",
45694542
"//src/core:hpack_constants",
45704543
"//src/core:metadata_batch",
45714544
"//src/core:no_destruct",
@@ -4668,7 +4641,6 @@ grpc_cc_library(
46684641
"grpc_base",
46694642
"grpc_public_hdrs",
46704643
"grpc_trace",
4671-
"http_trace",
46724644
"//src/core:hpack_constants",
46734645
"//src/core:hpack_encoder_table",
46744646
"//src/core:metadata_batch",
@@ -4801,7 +4773,6 @@ grpc_cc_library(
48014773
"hpack_encoder",
48024774
"hpack_parser",
48034775
"hpack_parser_table",
4804-
"http_trace",
48054776
"httpcli",
48064777
"iomgr",
48074778
"iomgr_buffer_list",
@@ -4838,7 +4809,6 @@ grpc_cc_library(
48384809
"//src/core:random_early_detection",
48394810
"//src/core:ref_counted",
48404811
"//src/core:resource_quota",
4841-
"//src/core:resource_quota_trace",
48424812
"//src/core:slice",
48434813
"//src/core:slice_buffer",
48444814
"//src/core:slice_refcount",

0 commit comments

Comments
 (0)