Skip to content

Commit

Permalink
Update dependency io.opentelemetry.instrumentation:opentelemetry-inst…
Browse files Browse the repository at this point in the history
…rumentation-bom-alpha to v1.31.0-alpha (#1072)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
  • Loading branch information
renovate[bot] and trask committed Oct 13, 2023
1 parent 5041ea5 commit c2ea609
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ val DEPENDENCY_BOMS = listOf(
"com.linecorp.armeria:armeria-bom:1.25.2",
"org.junit:junit-bom:5.10.0",
"io.grpc:grpc-bom:1.58.0",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.30.0-alpha",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.31.0-alpha",
"org.testcontainers:testcontainers-bom:1.19.1"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.export.CollectionRegistration;
import io.opentelemetry.sdk.metrics.export.MetricReader;
import io.opentelemetry.sdk.metrics.internal.export.MetricProducer;
import io.prometheus.client.Collector;
import io.prometheus.client.CollectorRegistry;
import java.util.ArrayList;
Expand All @@ -28,10 +27,10 @@
public final class PrometheusCollector implements MetricReader {

private final Collector collector;
private volatile MetricProducer metricProducer = MetricProducer.noop();
private volatile CollectionRegistration collectionRegistration = CollectionRegistration.noop();

PrometheusCollector() {
this.collector = new CollectorImpl(() -> getMetricProducer().collectAllMetrics());
this.collector = new CollectorImpl(() -> collectionRegistration.collectAllMetrics());
this.collector.register();
}

Expand All @@ -43,13 +42,9 @@ public static PrometheusCollector create() {
return new PrometheusCollector();
}

private MetricProducer getMetricProducer() {
return metricProducer;
}

@Override
public void register(CollectionRegistration registration) {
this.metricProducer = MetricProducer.asMetricProducer(registration);
this.collectionRegistration = registration;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.export.CollectionRegistration;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableDoublePointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.metrics.internal.export.MetricProducer;
import io.opentelemetry.sdk.resources.Resource;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.exporter.common.TextFormat;
Expand All @@ -36,14 +36,14 @@

@ExtendWith(MockitoExtension.class)
class PrometheusCollectorTest {
@Mock MetricProducer metricProducer;
@Mock CollectionRegistration collectionRegistration;
PrometheusCollector prometheusCollector;

@BeforeEach
void setUp() {
// Apply the SDK metric producer registers with prometheus.
prometheusCollector = new PrometheusCollector();
prometheusCollector.register(metricProducer);
prometheusCollector.register(collectionRegistration);
}

@Test
Expand All @@ -60,7 +60,7 @@ void registerWithSdkMeterProvider() {

@Test
void registerToDefault() throws IOException {
when(metricProducer.collectAllMetrics()).thenReturn(generateTestData());
when(collectionRegistration.collectAllMetrics()).thenReturn(generateTestData());
StringWriter stringWriter = new StringWriter();
TextFormat.write004(stringWriter, CollectorRegistry.defaultRegistry.metricFamilySamples());
assertThat(stringWriter.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ static void moveEntryUpdating(
FileSystem targetFs, String targetPath, JarEntry sourceEntry, JarFile sourceJar)
throws IOException {

if (targetPath.equals(
"META-INF/services/io.opentelemetry.javaagent.tooling.BeforeAgentListener")) {
// TEMPORARY hack to make things pass after a BeforeAgentListener was added in the agent
// in https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/9301
// which then causes conflict with the BeforeAgentListener in this module
return;
}

Path entry = targetFs.getPath("/", targetPath);
Files.createDirectories(entry.getParent());
try (InputStream sourceInput = sourceJar.getInputStream(sourceEntry)) {
Expand Down

0 comments on commit c2ea609

Please sign in to comment.