Skip to content

Update to java sdk 1.13.0 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
}

ext {
openTelemetryVersion = "1.12.0"
openTelemetryAlphaVersion = "1.12.0-alpha"
openTelemetryVersion = "1.13.0"
openTelemetryAlphaVersion = "1.13.0-alpha"

grpcVersion = '1.34.1'
protobufVersion = '3.11.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.opentelemetry.exporter.logging.LoggingSpanExporter;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.export.MetricReaderFactory;
import io.opentelemetry.sdk.metrics.export.MetricReader;
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
Expand All @@ -26,16 +26,16 @@ public final class ExampleConfiguration {
* @return A ready-to-use {@link OpenTelemetry} instance.
*/
public static OpenTelemetry initOpenTelemetry() {
// Create an instance of PeriodicMetricReaderFactory and configure it
// Create an instance of PeriodicMetricReader and configure it
// to export via the logging exporter
MetricReaderFactory periodicReaderFactory =
MetricReader periodicReader =
PeriodicMetricReader.builder(LoggingMetricExporter.create())
.setInterval(Duration.ofMillis(METRIC_EXPORT_INTERVAL_MS))
.newMetricReaderFactory();
.build();

// This will be used to create instruments
SdkMeterProvider meterProvider =
SdkMeterProvider.builder().registerMetricReader(periodicReaderFactory).build();
SdkMeterProvider.builder().registerMetricReader(periodicReader).build();

// Tracer provider configured to export spans with SimpleSpanProcessor using
// the logging exporter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.export.MetricReaderFactory;
import io.opentelemetry.sdk.metrics.export.MetricReader;
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
Expand Down Expand Up @@ -64,13 +64,11 @@ static MeterProvider initOpenTelemetryMetrics() {
// set up the metric exporter and wire it into the SDK and a timed periodic reader.
OtlpGrpcMetricExporter metricExporter = OtlpGrpcMetricExporter.getDefault();

MetricReaderFactory periodicReaderFactory =
PeriodicMetricReader.builder(metricExporter)
.setInterval(Duration.ofMillis(1000))
.newMetricReaderFactory();
MetricReader periodicReader =
PeriodicMetricReader.builder(metricExporter).setInterval(Duration.ofMillis(1000)).build();

SdkMeterProvider sdkMeterProvider =
SdkMeterProvider.builder().registerMetricReader(periodicReaderFactory).build();
SdkMeterProvider.builder().registerMetricReader(periodicReader).build();

Runtime.getRuntime().addShutdownHook(new Thread(sdkMeterProvider::shutdown));
return sdkMeterProvider;
Expand Down
2 changes: 1 addition & 1 deletion prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ These are collected by a Prometheus instance which is configured to pull these m
```
## 2 - Run Prometheus

Start Prometheus instance with a configuration that sets up a HTTP collection job for ```127.0.0.1:19090```
Start Prometheus instance with a configuration that sets up an HTTP collection job for ```127.0.0.1:19090```

See [prometheus.yml](prometheus.yml)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.exporter.prometheus.PrometheusHttpServer;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.export.MetricReaderFactory;
import io.opentelemetry.sdk.metrics.export.MetricReader;
import java.io.IOException;

public final class ExampleConfiguration {
Expand All @@ -20,9 +20,8 @@ public final class ExampleConfiguration {
* @return A MeterProvider for use in instrumentation.
*/
static MeterProvider initializeOpenTelemetry(int prometheusPort) throws IOException {
MetricReaderFactory prometheusReaderFactory =
PrometheusHttpServer.builder().setPort(prometheusPort).newMetricReaderFactory();
MetricReader prometheusReader = PrometheusHttpServer.builder().setPort(prometheusPort).build();

return SdkMeterProvider.builder().registerMetricReader(prometheusReaderFactory).build();
return SdkMeterProvider.builder().registerMetricReader(prometheusReader).build();
}
}