-
Notifications
You must be signed in to change notification settings - Fork 774
/
NotOnClasspathTest.java
229 lines (208 loc) · 8.25 KB
/
NotOnClasspathTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.sdk.autoconfigure;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import java.util.Collections;
import org.junit.jupiter.api.Test;
class NotOnClasspathTest {
private static final ConfigProperties EMPTY =
DefaultConfigProperties.createForTest(Collections.emptyMap());
@Test
void otlpGrpcSpans() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
"otlp", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"OTLP gRPC Trace Exporter enabled but opentelemetry-exporter-otlp not found on "
+ "classpath");
}
@Test
void otlpHttpSpans() {
ConfigProperties config =
DefaultConfigProperties.createForTest(
Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf"));
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
"otlp", config, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"OTLP HTTP Trace Exporter enabled but opentelemetry-exporter-otlp-http-trace not found on "
+ "classpath");
}
@Test
void jaeger() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
"jaeger", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"Jaeger gRPC Exporter enabled but opentelemetry-exporter-jaeger not found on "
+ "classpath");
}
@Test
void zipkin() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
"zipkin", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"Zipkin Exporter enabled but opentelemetry-exporter-zipkin not found on classpath");
}
@Test
void loggingSpans() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
"logging", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.traces.exporter set to \"logging\" but opentelemetry-exporter-logging not found on classpath."
+ " Make sure to add it as a dependency.");
}
@Test
void loggingSpansOtlp() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
"logging-otlp", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"OTLP JSON Logging Trace Exporter enabled but opentelemetry-exporter-logging-otlp not found on "
+ "classpath");
}
@Test
void loggingMetrics() {
assertThatThrownBy(
() ->
MetricExporterConfiguration.configureExporter(
"logging",
EMPTY,
MetricExporterConfiguration.class.getClassLoader(),
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.metrics.exporter set to \"logging\" but opentelemetry-exporter-logging not found on classpath."
+ " Make sure to add it as a dependency.");
}
@Test
void loggingMetricsOtlp() {
assertThatThrownBy(
() ->
MetricExporterConfiguration.configureExporter(
"logging-otlp",
EMPTY,
MetricExporterConfiguration.class.getClassLoader(),
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"OTLP JSON Logging Metrics Exporter enabled but opentelemetry-exporter-logging-otlp not found on "
+ "classpath");
}
@Test
void loggingLogs() {
assertThatThrownBy(
() ->
LogRecordExporterConfiguration.configureExporter(
"logging", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.logs.exporter set to \"logging\" but opentelemetry-exporter-logging not found on classpath."
+ " Make sure to add it as a dependency.");
}
@Test
void loggingLogsOtlp() {
assertThatThrownBy(
() ->
LogRecordExporterConfiguration.configureExporter(
"logging-otlp", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"OTLP JSON Logging Log Exporter enabled but opentelemetry-exporter-logging-otlp not found on "
+ "classpath");
}
@Test
void otlpGrpcMetrics() {
assertThatCode(
() ->
MetricExporterConfiguration.configureExporter(
"otlp",
EMPTY,
MetricExporterConfiguration.class.getClassLoader(),
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"OTLP gRPC Metrics Exporter enabled but opentelemetry-exporter-otlp not found on "
+ "classpath");
}
@Test
void otlpHttpMetrics() {
ConfigProperties config =
DefaultConfigProperties.createForTest(
Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf"));
assertThatCode(
() ->
MetricExporterConfiguration.configureExporter(
"otlp",
config,
MetricExporterConfiguration.class.getClassLoader(),
(a, unused) -> a))
.hasMessageContaining(
"OTLP HTTP Metrics Exporter enabled but opentelemetry-exporter-otlp-http-metrics not found on classpath");
}
@Test
void prometheus() {
assertThatThrownBy(
() ->
MetricExporterConfiguration.configureExporter(
"prometheus",
EMPTY,
MetricExporterConfiguration.class.getClassLoader(),
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"Prometheus Metrics Server enabled but opentelemetry-exporter-prometheus not found on "
+ "classpath");
}
@Test
void b3propagator() {
assertThatThrownBy(
() ->
PropagatorConfiguration.configurePropagators(
DefaultConfigProperties.createForTest(
Collections.singletonMap("otel.propagators", "b3")),
PropagatorConfiguration.class.getClassLoader(),
(a, config) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Unrecognized value for otel.propagators: b3");
}
@Test
void otlpGrpcLogs() {
assertThatCode(
() ->
LogRecordExporterConfiguration.configureExporter(
"otlp", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.doesNotThrowAnyException();
}
@Test
void otlpHttpLogs() {
ConfigProperties config =
DefaultConfigProperties.createForTest(
Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf"));
assertThatCode(
() ->
LogRecordExporterConfiguration.configureExporter(
"otlp", config, NamedSpiManager.createEmpty(), MeterProvider.noop()))
.doesNotThrowAnyException();
}
}