Commit 8376022
authored
subscriber: fix
## Motivation
Currently, the `reload` layer is generic over both the type of the layer
being reloaded, *and* the type of the subscriber that the layer is
layered onto. This means that the `reload::Handle` type that's used to
reload the value of the layer *also* is parameterized over the
subscriber's type.
The subscriber type parameter makes the `reload` API significantly
harder to use. Any time a `reload::Handle` is returned by a function,
taken as an argument, or stored in a struct, the full type of the
subscriber under the layer must be written out --- and often, it is
quite long. What makes this worse is that sometimes the type of the
subscriber may vary at runtime based on some configuration, while the
type of the layer that's reloaded remains the same. For example, in
Linkerd, we've had to do [this][1], which is really not ideal.
## Solution
This branch removes the `Subscriber` type parameter from `reload::Layer`
and `reload::Handle`. Now, the `Handle` type is only generic over the
type of the inner layer that's being reloaded. It turns out that the
`Subscriber` type parameter was only necessary to add a `L: Layer<S>`
bound to `reload::Layer`'s constructor, which isn't really necessary ---
if the layer does not implement `Layer<S>`, the type error will occur
when `Subscriber::with` is actually used to layer it, which is fine.
I also changed the `with_filter_reloading` option on the `FmtSubscriber`
builder to also work with `LevelFilter`s, since there's no reason for it
not to, and added an example.
Since this breaks existing code, this change has to be made as part of
0.3.
[1]: https://github.com/linkerd/linkerd2-proxy/blob/6c484f6dcdeebda18b68c800b4494263bf98fcdc/linkerd/app/core/src/trace.rs#L19-L36reload ergonomics (#1035)1 parent aef5bd8 commit 8376022
File tree
3 files changed
+63
-62
lines changed- examples/examples
- tracing-subscriber/src
- fmt
3 files changed
+63
-62
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
189 | | - | |
| 188 | + | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 200 | + | |
| 201 | + | |
205 | 202 | | |
206 | 203 | | |
207 | 204 | | |
| |||
214 | 211 | | |
215 | 212 | | |
216 | 213 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 214 | + | |
221 | 215 | | |
222 | 216 | | |
223 | 217 | | |
| |||
252 | 246 | | |
253 | 247 | | |
254 | 248 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
| 249 | + | |
259 | 250 | | |
260 | 251 | | |
261 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| |||
646 | 647 | | |
647 | 648 | | |
648 | 649 | | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
| 650 | + | |
672 | 651 | | |
673 | 652 | | |
674 | 653 | | |
675 | 654 | | |
676 | 655 | | |
677 | | - | |
| 656 | + | |
678 | 657 | | |
679 | 658 | | |
680 | 659 | | |
| |||
814 | 793 | | |
815 | 794 | | |
816 | 795 | | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
817 | 841 | | |
818 | 842 | | |
819 | 843 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | | - | |
| 29 | + | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
| 39 | + | |
42 | 40 | | |
43 | | - | |
44 | 41 | | |
45 | 42 | | |
46 | 43 | | |
| |||
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
60 | | - | |
| 57 | + | |
61 | 58 | | |
62 | 59 | | |
63 | 60 | | |
| |||
113 | 110 | | |
114 | 111 | | |
115 | 112 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 113 | + | |
121 | 114 | | |
122 | 115 | | |
123 | | - | |
| 116 | + | |
124 | 117 | | |
125 | 118 | | |
126 | | - | |
127 | 119 | | |
128 | 120 | | |
129 | 121 | | |
130 | 122 | | |
131 | 123 | | |
132 | 124 | | |
133 | | - | |
| 125 | + | |
134 | 126 | | |
135 | 127 | | |
136 | | - | |
137 | 128 | | |
138 | 129 | | |
139 | 130 | | |
140 | 131 | | |
141 | 132 | | |
142 | 133 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 134 | + | |
148 | 135 | | |
149 | 136 | | |
150 | 137 | | |
| |||
189 | 176 | | |
190 | 177 | | |
191 | 178 | | |
192 | | - | |
| 179 | + | |
193 | 180 | | |
194 | 181 | | |
195 | 182 | | |
196 | | - | |
197 | 183 | | |
198 | 184 | | |
199 | 185 | | |
| |||
0 commit comments