| 1 |
|
| MODULE = Punk::OpenTelemetry PACKAGE = Punk::OpenTelemetry::Config |
| 2 |
|
| |
| 3 |
|
| PROTOTYPES: DISABLE |
| 4 |
|
| |
| 5 |
|
| # The OTEL_* environment surface, the precedence merge, and the one line the |
| 6 |
|
| # SDK prints at boot. |
| 7 |
|
| |
| 8 |
|
| # from_env() -> a config hashref, read once. |
| 9 |
|
| SV * |
| 10 |
|
| from_env() |
| 11 |
|
| CODE: |
| 12 |
39 |
| RETVAL = newRV_noinc((SV *)otel_config_from_env(aTHX)); |
| 13 |
|
| OUTPUT: |
| 14 |
|
| RETVAL |
| 15 |
|
| |
| 16 |
|
| # resolve(@layers) -> a config hashref. |
| 17 |
|
| # |
| 18 |
|
| # Layers are merged LOWEST FIRST, so the caller writes them in the order they |
| 19 |
|
| # win: resolve($keyword, $file, $env). Undef layers are skipped, so a caller |
| 20 |
|
| # does not have to test each source before passing it. |
| 21 |
|
| SV * |
| 22 |
|
| resolve(...) |
| 23 |
|
| CODE: |
| 24 |
|
| { |
| 25 |
19 |
| HV *out = newHV(); |
| 26 |
|
| int i; |
| 27 |
76 |
▶ | for (i = items - 1; i >= 0; i--) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = items - 1; i >= 0; i--) { |
57 |
19 |
76 |
|
| 28 |
57 |
| HV *h = otel_hv_of(aTHX_ ST(i)); |
| 29 |
57 |
▶ | if (h) otel_config_merge(aTHX_ out, h); |
Branch: 1 branch
| Branch | True | False | Total |
| if (h) otel_config_merge(aTHX_ out, h); |
39 |
18 |
57 |
|
| 30 |
|
| } |
| 31 |
19 |
| RETVAL = newRV_noinc((SV *)out); |
| 32 |
|
| } |
| 33 |
|
| OUTPUT: |
| 34 |
|
| RETVAL |
| 35 |
|
| |
| 36 |
|
| # diagnostic($config) -> the boot line. Never contains a header value. |
| 37 |
|
| SV * |
| 38 |
|
| diagnostic(config) |
| 39 |
|
| SV *config |
| 40 |
|
| CODE: |
| 41 |
|
| { |
| 42 |
21 |
| HV *h = otel_hv_of(aTHX_ config); |
| 43 |
21 |
▶ | if (!h) croak("Punk::OpenTelemetry::Config::diagnostic: need a hashref"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!h) croak("Punk::OpenTelemetry::Config::diagnostic: need a hashref"); |
0 |
21 |
21 |
|
| 44 |
21 |
| RETVAL = newSVsv(otel_config_diagnostic(aTHX_ h)); |
| 45 |
|
| } |
| 46 |
|
| OUTPUT: |
| 47 |
|
| RETVAL |
| 48 |
|
| |
| 49 |
|
| # disabled($config) -> whether the SDK is off. A separate entry point because |
| 50 |
|
| # it is asked before anything is built, and the answer must not depend on any |
| 51 |
|
| # of it having been built. |
| 52 |
|
| IV |
| 53 |
|
| disabled(config) |
| 54 |
|
| SV *config |
| 55 |
|
| CODE: |
| 56 |
|
| { |
| 57 |
26 |
| HV *h = otel_hv_of(aTHX_ config); |
| 58 |
26 |
▶ | SV *v = h ? otel_h(aTHX_ h, "disabled") : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| SV *v = h ? otel_h(aTHX_ h, "disabled") : NULL; |
26 |
0 |
26 |
|
| 59 |
26 |
▶ | RETVAL = (v && SvTRUE(v)) ? 1 : 0; |
Branch: 3 branches
| Branch | True | False | Total |
| RETVAL = (v && SvTRUE(v)) ? 1 : 0; |
26 |
0 |
26 |
| RETVAL = (v && SvTRUE(v)) ? 1 : 0; |
4 |
22 |
26 |
| RETVAL = (v && SvTRUE(v)) ? 1 : 0; |
23 |
3 |
26 |
|
| 60 |
|
| } |
| 61 |
|
| OUTPUT: |
| 62 |
|
| RETVAL |