Skip to content

Commit

Permalink
Shade testing protobuf dependency (open-telemetry#12782)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
laurit and renovate[bot] authored Nov 25, 2024
1 parent 310eddc commit 792b6da
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 33 deletions.
2 changes: 1 addition & 1 deletion dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ val DEPENDENCIES = listOf(
"io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:${otelContribVersion}",
"io.opentelemetry.contrib:opentelemetry-gcp-resources:${otelContribVersion}",
"io.opentelemetry.contrib:opentelemetry-baggage-processor:${otelContribVersion}",
"io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha",
"io.opentelemetry.proto:opentelemetry-proto:1.4.0-alpha",
"io.opentelemetry:opentelemetry-extension-annotations:1.18.0", // deprecated, no longer part of bom
"org.assertj:assertj-core:3.26.3",
"org.awaitility:awaitility:4.2.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/distro/smoke-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.18.1")
testImplementation("com.google.protobuf:protobuf-java-util:4.28.3")
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha")
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.4.0-alpha")
testImplementation("io.opentelemetry:opentelemetry-api")

testImplementation("ch.qos.logback:logback-classic:1.5.12")
Expand Down
2 changes: 1 addition & 1 deletion examples/extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ dependencies {
testImplementation("com.google.protobuf:protobuf-java-util:4.28.3")
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")
testImplementation("io.opentelemetry:opentelemetry-api")
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha")
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.4.0-alpha")

testImplementation("org.junit.jupiter:junit-jupiter-api:${versions.junit}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junit}")
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ include(":dependencyManagement")
include(":testing:agent-exporter")
include(":testing:agent-for-testing")
include(":testing:armeria-shaded-for-testing")
include(":testing:proto-shaded-for-testing")
include(":testing-common")
include(":testing-common:integration-tests")
include(":testing-common:library-for-integration-tests")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.smoketest

import com.fasterxml.jackson.databind.ObjectMapper
import com.google.protobuf.GeneratedMessageV3
import com.google.protobuf.GeneratedMessage
import com.google.protobuf.util.JsonFormat
import io.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest
import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest
Expand Down Expand Up @@ -42,7 +42,7 @@ class TelemetryRetriever {
return waitForTelemetry("get-logs", { ExportLogsServiceRequest.newBuilder() })
}

private <T extends GeneratedMessageV3, B extends GeneratedMessageV3.Builder> Collection<T> waitForTelemetry(String path, Supplier<B> builderConstructor) {
private <T extends GeneratedMessage, B extends GeneratedMessage.Builder> Collection<T> waitForTelemetry(String path, Supplier<B> builderConstructor) {
def content = waitForContent(path)

return OBJECT_MAPPER.readTree(content).collect {
Expand Down
6 changes: 4 additions & 2 deletions testing-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ sourceSets {
main {
val armeriaShadedDeps = project(":testing:armeria-shaded-for-testing")
output.dir(armeriaShadedDeps.file("build/extracted/shadow"), "builtBy" to ":testing:armeria-shaded-for-testing:extractShadowJar")

val protoShadedDeps = project(":testing:proto-shaded-for-testing")
output.dir(protoShadedDeps.file("build/extracted/shadow"), "builtBy" to ":testing:proto-shaded-for-testing:extractShadowJar")
}
}

Expand Down Expand Up @@ -47,13 +50,12 @@ dependencies {
api("org.slf4j:slf4j-api")

compileOnly(project(":testing:armeria-shaded-for-testing", configuration = "shadow"))
compileOnly(project(":testing:proto-shaded-for-testing", configuration = "shadow"))
compileOnly(project(":javaagent-bootstrap"))

compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")

implementation("io.opentelemetry.proto:opentelemetry-proto")

implementation("net.bytebuddy:byte-buddy")
implementation("ch.qos.logback:logback-classic")
implementation("org.slf4j:log4j-over-slf4j")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import static io.opentelemetry.api.common.AttributeKey.stringArrayKey;
import static java.util.stream.Collectors.toList;

import com.google.protobuf.InvalidProtocolBufferException;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.api.common.Value;
Expand All @@ -23,30 +22,6 @@
import io.opentelemetry.api.trace.TraceFlags;
import io.opentelemetry.api.trace.TraceState;
import io.opentelemetry.api.trace.TraceStateBuilder;
import io.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest;
import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest;
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
import io.opentelemetry.proto.common.v1.AnyValue;
import io.opentelemetry.proto.common.v1.ArrayValue;
import io.opentelemetry.proto.common.v1.InstrumentationScope;
import io.opentelemetry.proto.common.v1.KeyValue;
import io.opentelemetry.proto.common.v1.KeyValueList;
import io.opentelemetry.proto.logs.v1.LogRecord;
import io.opentelemetry.proto.logs.v1.ResourceLogs;
import io.opentelemetry.proto.logs.v1.ScopeLogs;
import io.opentelemetry.proto.logs.v1.SeverityNumber;
import io.opentelemetry.proto.metrics.v1.HistogramDataPoint;
import io.opentelemetry.proto.metrics.v1.Metric;
import io.opentelemetry.proto.metrics.v1.NumberDataPoint;
import io.opentelemetry.proto.metrics.v1.ResourceMetrics;
import io.opentelemetry.proto.metrics.v1.ScopeMetrics;
import io.opentelemetry.proto.metrics.v1.Sum;
import io.opentelemetry.proto.metrics.v1.SummaryDataPoint;
import io.opentelemetry.proto.resource.v1.Resource;
import io.opentelemetry.proto.trace.v1.ResourceSpans;
import io.opentelemetry.proto.trace.v1.ScopeSpans;
import io.opentelemetry.proto.trace.v1.Span;
import io.opentelemetry.proto.trace.v1.Status;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
Expand All @@ -72,6 +47,31 @@
import io.opentelemetry.sdk.trace.data.LinkData;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.opentelemetry.testing.internal.proto.collector.logs.v1.ExportLogsServiceRequest;
import io.opentelemetry.testing.internal.proto.collector.metrics.v1.ExportMetricsServiceRequest;
import io.opentelemetry.testing.internal.proto.collector.trace.v1.ExportTraceServiceRequest;
import io.opentelemetry.testing.internal.proto.common.v1.AnyValue;
import io.opentelemetry.testing.internal.proto.common.v1.ArrayValue;
import io.opentelemetry.testing.internal.proto.common.v1.InstrumentationScope;
import io.opentelemetry.testing.internal.proto.common.v1.KeyValue;
import io.opentelemetry.testing.internal.proto.common.v1.KeyValueList;
import io.opentelemetry.testing.internal.proto.logs.v1.LogRecord;
import io.opentelemetry.testing.internal.proto.logs.v1.ResourceLogs;
import io.opentelemetry.testing.internal.proto.logs.v1.ScopeLogs;
import io.opentelemetry.testing.internal.proto.logs.v1.SeverityNumber;
import io.opentelemetry.testing.internal.proto.metrics.v1.HistogramDataPoint;
import io.opentelemetry.testing.internal.proto.metrics.v1.Metric;
import io.opentelemetry.testing.internal.proto.metrics.v1.NumberDataPoint;
import io.opentelemetry.testing.internal.proto.metrics.v1.ResourceMetrics;
import io.opentelemetry.testing.internal.proto.metrics.v1.ScopeMetrics;
import io.opentelemetry.testing.internal.proto.metrics.v1.Sum;
import io.opentelemetry.testing.internal.proto.metrics.v1.SummaryDataPoint;
import io.opentelemetry.testing.internal.proto.resource.v1.Resource;
import io.opentelemetry.testing.internal.proto.trace.v1.ResourceSpans;
import io.opentelemetry.testing.internal.proto.trace.v1.ScopeSpans;
import io.opentelemetry.testing.internal.proto.trace.v1.Span;
import io.opentelemetry.testing.internal.proto.trace.v1.Status;
import io.opentelemetry.testing.internal.protobuf.InvalidProtocolBufferException;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
Expand Down Expand Up @@ -568,7 +568,8 @@ private static List<ValueAtQuantile> getValues(SummaryDataPoint point) {
}

private static AggregationTemporality getTemporality(
io.opentelemetry.proto.metrics.v1.AggregationTemporality aggregationTemporality) {
io.opentelemetry.testing.internal.proto.metrics.v1.AggregationTemporality
aggregationTemporality) {
switch (aggregationTemporality) {
case AGGREGATION_TEMPORALITY_CUMULATIVE:
return AggregationTemporality.CUMULATIVE;
Expand Down
22 changes: 22 additions & 0 deletions testing/proto-shaded-for-testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id("com.gradleup.shadow")
id("otel.java-conventions")
}

dependencies {
implementation("io.opentelemetry.proto:opentelemetry-proto")
}

tasks {
shadowJar {
relocate("io.opentelemetry.proto", "io.opentelemetry.testing.internal.proto")
relocate("com.google.protobuf", "io.opentelemetry.testing.internal.protobuf")
}

val extractShadowJar by registering(Copy::class) {
dependsOn(shadowJar)
from(zipTree(shadowJar.get().archiveFile))
into("build/extracted/shadow")
includeEmptyDirs = false
}
}

0 comments on commit 792b6da

Please sign in to comment.