|
7 | 7 |
|
8 | 8 | import io.opentelemetry.api.OpenTelemetry; |
9 | 9 | import io.opentelemetry.api.common.Attributes; |
10 | | -import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter; |
| 10 | +import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter; |
11 | 11 | import io.opentelemetry.sdk.OpenTelemetrySdk; |
12 | 12 | import io.opentelemetry.sdk.resources.Resource; |
13 | 13 | import io.opentelemetry.sdk.trace.SdkTracerProvider; |
14 | 14 | import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; |
| 15 | +import io.opentelemetry.sdk.trace.export.SpanExporter; |
15 | 16 | import io.opentelemetry.semconv.ServiceAttributes; |
16 | 17 |
|
17 | 18 | public final class ExampleConfiguration { |
18 | 19 |
|
19 | 20 | // Name of the service |
20 | 21 | private static final String SERVICE_NAME = "myExampleService"; |
21 | 22 |
|
22 | | - /** Adds a SimpleSpanProcessor initialized with ZipkinSpanExporter to the TracerSdkProvider */ |
| 23 | + /** Adds a SimpleSpanProcessor initialized with OtlpHttpSpanExporter to the TracerSdkProvider */ |
23 | 24 | static OpenTelemetry initializeOpenTelemetry(String ip, int port) { |
24 | | - String endpoint = String.format("http://%s:%s/api/v2/spans", ip, port); |
25 | | - ZipkinSpanExporter zipkinExporter = ZipkinSpanExporter.builder().setEndpoint(endpoint).build(); |
| 25 | + String endpoint = String.format("http://%s:%s/api/v1/traces", ip, port); |
| 26 | + SpanExporter spanExporter = OtlpHttpSpanExporter.builder().setEndpoint(endpoint).build(); |
26 | 27 |
|
27 | 28 | Resource serviceNameResource = |
28 | 29 | Resource.create(Attributes.of(ServiceAttributes.SERVICE_NAME, SERVICE_NAME)); |
29 | 30 |
|
30 | 31 | // Set to process the spans by the Zipkin Exporter |
31 | 32 | SdkTracerProvider tracerProvider = |
32 | 33 | SdkTracerProvider.builder() |
33 | | - .addSpanProcessor(SimpleSpanProcessor.create(zipkinExporter)) |
| 34 | + .addSpanProcessor(SimpleSpanProcessor.create(spanExporter)) |
34 | 35 | .setResource(Resource.getDefault().merge(serviceNameResource)) |
35 | 36 | .build(); |
36 | 37 | OpenTelemetrySdk openTelemetry = |
|
0 commit comments