Line data Source code
1 : // Copyright The OpenTelemetry Authors
2 : // SPDX-License-Identifier: Apache-2.0
3 :
4 : import 'env_constants.dart';
5 :
6 : /// Helper function to retrieve String.fromEnvironment values.
7 : ///
8 : /// Since String.fromEnvironment requires compile-time constants, we must
9 : /// explicitly check each possible variable in a switch statement.
10 : ///
11 : /// @param key The environment variable name
12 : /// @return The value from String.fromEnvironment, or null if empty
13 144 : String? getFromEnvironment(String key) {
14 : // We use a switch statement because String.fromEnvironment requires
15 : // compile-time constants. Each case must be explicitly listed.
16 : switch (key) {
17 : // General SDK Configuration
18 144 : case otelSdkDisabled:
19 : return const String.fromEnvironment(otelSdkDisabled);
20 144 : case otelResourceAttributes:
21 : return const String.fromEnvironment(otelResourceAttributes);
22 144 : case otelServiceName:
23 : return const String.fromEnvironment(otelServiceName);
24 143 : case otelLogLevel:
25 : return const String.fromEnvironment(otelLogLevel);
26 143 : case otelDartLogMetrics:
27 : return const String.fromEnvironment(otelDartLogMetrics);
28 143 : case otelDartLogSpans:
29 : return const String.fromEnvironment(otelDartLogSpans);
30 143 : case otelDartLogExport:
31 : return const String.fromEnvironment(otelDartLogExport);
32 143 : case otelPropagators:
33 : return const String.fromEnvironment(otelPropagators);
34 143 : case otelTracesSampler:
35 : return const String.fromEnvironment(otelTracesSampler);
36 143 : case otelTracesSamplerArg:
37 : return const String.fromEnvironment(otelTracesSamplerArg);
38 :
39 : // Logging Configuration
40 :
41 : // General OTLP Configuration
42 143 : case otelExporterOtlpEndpoint:
43 : return const String.fromEnvironment(otelExporterOtlpEndpoint);
44 143 : case otelExporterOtlpProtocol:
45 : return const String.fromEnvironment(otelExporterOtlpProtocol);
46 143 : case otelExporterOtlpHeaders:
47 : return const String.fromEnvironment(otelExporterOtlpHeaders);
48 143 : case otelExporterOtlpInsecure:
49 : return const String.fromEnvironment(otelExporterOtlpInsecure);
50 143 : case otelExporterOtlpTimeout:
51 : return const String.fromEnvironment(otelExporterOtlpTimeout);
52 143 : case otelExporterOtlpCompression:
53 : return const String.fromEnvironment(otelExporterOtlpCompression);
54 143 : case otelExporterOtlpCertificate:
55 : return const String.fromEnvironment(otelExporterOtlpCertificate);
56 143 : case otelExporterOtlpClientKey:
57 : return const String.fromEnvironment(otelExporterOtlpClientKey);
58 143 : case otelExporterOtlpClientCertificate:
59 : return const String.fromEnvironment(otelExporterOtlpClientCertificate);
60 :
61 : // Traces-specific Configuration
62 143 : case otelTracesExporter:
63 : return const String.fromEnvironment(otelTracesExporter);
64 143 : case otelExporterOtlpTracesEndpoint:
65 : return const String.fromEnvironment(otelExporterOtlpTracesEndpoint);
66 143 : case otelExporterOtlpTracesProtocol:
67 : return const String.fromEnvironment(otelExporterOtlpTracesProtocol);
68 143 : case otelExporterOtlpTracesHeaders:
69 : return const String.fromEnvironment(otelExporterOtlpTracesHeaders);
70 143 : case otelExporterOtlpTracesInsecure:
71 : return const String.fromEnvironment(otelExporterOtlpTracesInsecure);
72 143 : case otelExporterOtlpTracesTimeout:
73 : return const String.fromEnvironment(otelExporterOtlpTracesTimeout);
74 143 : case otelExporterOtlpTracesCompression:
75 : return const String.fromEnvironment(otelExporterOtlpTracesCompression);
76 143 : case otelExporterOtlpTracesCertificate:
77 : return const String.fromEnvironment(otelExporterOtlpTracesCertificate);
78 143 : case otelExporterOtlpTracesClientKey:
79 : return const String.fromEnvironment(otelExporterOtlpTracesClientKey);
80 143 : case otelExporterOtlpTracesClientCertificate:
81 : return const String.fromEnvironment(
82 : otelExporterOtlpTracesClientCertificate,
83 : );
84 :
85 : // Metrics-specific Configuration
86 143 : case otelMetricsExporter:
87 : return const String.fromEnvironment(otelMetricsExporter);
88 143 : case otelExporterOtlpMetricsEndpoint:
89 : return const String.fromEnvironment(otelExporterOtlpMetricsEndpoint);
90 143 : case otelExporterOtlpMetricsProtocol:
91 : return const String.fromEnvironment(otelExporterOtlpMetricsProtocol);
92 143 : case otelExporterOtlpMetricsHeaders:
93 : return const String.fromEnvironment(otelExporterOtlpMetricsHeaders);
94 143 : case otelExporterOtlpMetricsInsecure:
95 : return const String.fromEnvironment(otelExporterOtlpMetricsInsecure);
96 143 : case otelExporterOtlpMetricsTimeout:
97 : return const String.fromEnvironment(otelExporterOtlpMetricsTimeout);
98 143 : case otelExporterOtlpMetricsCompression:
99 : return const String.fromEnvironment(otelExporterOtlpMetricsCompression);
100 143 : case otelExporterOtlpMetricsCertificate:
101 : return const String.fromEnvironment(otelExporterOtlpMetricsCertificate);
102 143 : case otelExporterOtlpMetricsClientKey:
103 : return const String.fromEnvironment(otelExporterOtlpMetricsClientKey);
104 143 : case otelExporterOtlpMetricsClientCertificate:
105 : return const String.fromEnvironment(
106 : otelExporterOtlpMetricsClientCertificate,
107 : );
108 :
109 : // Logs-specific Configuration
110 143 : case otelLogsExporter:
111 : return const String.fromEnvironment(otelLogsExporter);
112 143 : case otelExporterOtlpLogsEndpoint:
113 : return const String.fromEnvironment(otelExporterOtlpLogsEndpoint);
114 143 : case otelExporterOtlpLogsProtocol:
115 : return const String.fromEnvironment(otelExporterOtlpLogsProtocol);
116 143 : case otelExporterOtlpLogsHeaders:
117 : return const String.fromEnvironment(otelExporterOtlpLogsHeaders);
118 143 : case otelExporterOtlpLogsInsecure:
119 : return const String.fromEnvironment(otelExporterOtlpLogsInsecure);
120 143 : case otelExporterOtlpLogsTimeout:
121 : return const String.fromEnvironment(otelExporterOtlpLogsTimeout);
122 143 : case otelExporterOtlpLogsCompression:
123 : return const String.fromEnvironment(otelExporterOtlpLogsCompression);
124 143 : case otelExporterOtlpLogsCertificate:
125 : return const String.fromEnvironment(otelExporterOtlpLogsCertificate);
126 143 : case otelExporterOtlpLogsClientKey:
127 : return const String.fromEnvironment(otelExporterOtlpLogsClientKey);
128 143 : case otelExporterOtlpLogsClientCertificate:
129 : return const String.fromEnvironment(
130 : otelExporterOtlpLogsClientCertificate,
131 : );
132 :
133 : // Batch Span Processor
134 142 : case otelBspScheduleDelay:
135 : return const String.fromEnvironment(otelBspScheduleDelay);
136 142 : case otelBspExportTimeout:
137 : return const String.fromEnvironment(otelBspExportTimeout);
138 142 : case otelBspMaxQueueSize:
139 : return const String.fromEnvironment(otelBspMaxQueueSize);
140 142 : case otelBspMaxExportBatchSize:
141 : return const String.fromEnvironment(otelBspMaxExportBatchSize);
142 :
143 : // Batch LogRecord Processor
144 134 : case otelBlrpScheduleDelay:
145 : return const String.fromEnvironment(otelBlrpScheduleDelay);
146 134 : case otelBlrpExportTimeout:
147 : return const String.fromEnvironment(otelBlrpExportTimeout);
148 134 : case otelBlrpMaxQueueSize:
149 : return const String.fromEnvironment(otelBlrpMaxQueueSize);
150 134 : case otelBlrpMaxExportBatchSize:
151 : return const String.fromEnvironment(otelBlrpMaxExportBatchSize);
152 :
153 : // Attribute Limits
154 125 : case otelAttributeValueLengthLimit:
155 : return const String.fromEnvironment(otelAttributeValueLengthLimit);
156 125 : case otelAttributeCountLimit:
157 : return const String.fromEnvironment(otelAttributeCountLimit);
158 :
159 : // Span Limits
160 125 : case otelSpanAttributeValueLengthLimit:
161 : return const String.fromEnvironment(otelSpanAttributeValueLengthLimit);
162 125 : case otelSpanAttributeCountLimit:
163 : return const String.fromEnvironment(otelSpanAttributeCountLimit);
164 125 : case otelSpanEventCountLimit:
165 : return const String.fromEnvironment(otelSpanEventCountLimit);
166 125 : case otelSpanLinkCountLimit:
167 : return const String.fromEnvironment(otelSpanLinkCountLimit);
168 125 : case otelEventAttributeCountLimit:
169 : return const String.fromEnvironment(otelEventAttributeCountLimit);
170 125 : case otelLinkAttributeCountLimit:
171 : return const String.fromEnvironment(otelLinkAttributeCountLimit);
172 :
173 : // LogRecord Limits
174 125 : case otelLogrecordAttributeValueLengthLimit:
175 : return const String.fromEnvironment(
176 : otelLogrecordAttributeValueLengthLimit,
177 : );
178 125 : case otelLogrecordAttributeCountLimit:
179 : return const String.fromEnvironment(otelLogrecordAttributeCountLimit);
180 :
181 : // Metrics SDK Configuration
182 125 : case otelMetricsExemplarFilter:
183 : return const String.fromEnvironment(otelMetricsExemplarFilter);
184 125 : case otelMetricExportInterval:
185 : return const String.fromEnvironment(otelMetricExportInterval);
186 125 : case otelMetricExportTimeout:
187 : return const String.fromEnvironment(otelMetricExportTimeout);
188 :
189 : // Zipkin Exporter
190 1 : case otelExporterZipkinEndpoint:
191 : return const String.fromEnvironment(otelExporterZipkinEndpoint);
192 1 : case otelExporterZipkinTimeout:
193 : return const String.fromEnvironment(otelExporterZipkinTimeout);
194 :
195 : // Prometheus Exporter
196 1 : case otelExporterPrometheusHost:
197 : return const String.fromEnvironment(otelExporterPrometheusHost);
198 1 : case otelExporterPrometheusPort:
199 : return const String.fromEnvironment(otelExporterPrometheusPort);
200 :
201 : // Deprecated but supported
202 1 : case otelExporterOtlpSpanInsecure:
203 : return const String.fromEnvironment(otelExporterOtlpSpanInsecure);
204 1 : case otelExporterOtlpMetricInsecure:
205 : return const String.fromEnvironment(otelExporterOtlpMetricInsecure);
206 :
207 : default:
208 : return null;
209 : }
210 : }
|