Skip to content

Commit

Permalink
Update to upstream agent 0.10.1 (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga authored Nov 13, 2020
1 parent fa30174 commit a954d64
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 61 deletions.
11 changes: 2 additions & 9 deletions awsagentprovider/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ base {

dependencies {
compileOnly("io.opentelemetry:opentelemetry-sdk")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-spi")
compileOnly("org.slf4j:slf4j-api")

implementation("io.opentelemetry:opentelemetry-sdk-extension-aws-v1-support")
Expand All @@ -48,15 +49,7 @@ tasks {
relocate("io.opentelemetry.instrumentation.api", "io.opentelemetry.javaagent.shaded.instrumentation.api")

// relocate OpenTelemetry API usage
relocate("io.opentelemetry.OpenTelemetry", "io.opentelemetry.javaagent.shaded.io.opentelemetry.OpenTelemetry")
relocate("io.opentelemetry.common", "io.opentelemetry.javaagent.shaded.io.opentelemetry.common")
relocate("io.opentelemetry.baggage", "io.opentelemetry.javaagent.shaded.io.opentelemetry.baggage")
relocate("io.opentelemetry.api", "io.opentelemetry.javaagent.shaded.io.opentelemetry.api")
relocate("io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context")
relocate("io.opentelemetry.internal", "io.opentelemetry.javaagent.shaded.io.opentelemetry.internal")
relocate("io.opentelemetry.metrics", "io.opentelemetry.javaagent.shaded.io.opentelemetry.metrics")
relocate("io.opentelemetry.trace", "io.opentelemetry.javaagent.shaded.io.opentelemetry.trace")

// relocate OpenTelemetry API dependency usage
relocate("io.grpc", "io.opentelemetry.javaagent.shaded.io.grpc")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Amazon.com, Inc. or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package com.softwareaws.xray.opentelemetry.providers;

import io.opentelemetry.javaagent.spi.config.PropertySource;
import java.util.Collections;
import java.util.Map;

public class AwsAgentProperties implements PropertySource {
@Override
public Map<String, String> getProperties() {
return Collections.singletonMap("otel.propagators", "xray,tracecontext,b3");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* permissions and limitations under the License.
*/

package com.softwareaws.xray.opentelemetry.exporters;
package com.softwareaws.xray.opentelemetry.providers;

import io.opentelemetry.sdk.extensions.trace.aws.AwsXRayIdsGenerator;
import io.opentelemetry.api.trace.TracerProvider;
import io.opentelemetry.api.trace.spi.TracerProviderFactory;
import io.opentelemetry.sdk.extension.trace.aws.AwsXrayIdGenerator;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import io.opentelemetry.trace.TracerProvider;
import io.opentelemetry.trace.spi.TracerProviderFactory;

public class AwsTracerProviderFactory implements TracerProviderFactory {

Expand All @@ -32,8 +32,7 @@ public class AwsTracerProviderFactory implements TracerProviderFactory {
}
}

TRACER_PROVIDER =
TracerSdkProvider.builder().setIdsGenerator(new AwsXRayIdsGenerator()).build();
TRACER_PROVIDER = TracerSdkProvider.builder().setIdsGenerator(new AwsXrayIdGenerator()).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# permissions and limitations under the License.
#

com.softwareaws.xray.opentelemetry.exporters.AwsTracerProviderFactory
com.softwareaws.xray.opentelemetry.providers.AwsTracerProviderFactory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.softwareaws.xray.opentelemetry.providers.AwsAgentProperties
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* permissions and limitations under the License.
*/

package com.softwareaws.xray.opentelemetry.exporters;
package com.softwareaws.xray.opentelemetry.providers;

import static org.assertj.core.api.Assertions.assertThat;

import com.google.common.primitives.Ints;
import io.opentelemetry.trace.TracerProvider;
import io.opentelemetry.api.trace.TracerProvider;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.RepeatedTest;

Expand All @@ -31,7 +31,7 @@ class AwsTracerProviderFactoryTest {
void providerGeneratesXrayIds() {
int startTimeSecs = (int) TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
var span = TRACER_PROVIDER.get("test").spanBuilder("test").startSpan();
byte[] traceId = span.getContext().getTraceIdBytes();
byte[] traceId = span.getSpanContext().getTraceIdBytes();
int epoch = Ints.fromBytes(traceId[0], traceId[1], traceId[2], traceId[3]);
assertThat(epoch).isGreaterThanOrEqualTo(startTimeSecs);
}
Expand Down
37 changes: 4 additions & 33 deletions dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ val DEPENDENCY_BOMS = listOf(
"com.google.protobuf:protobuf-bom:3.13.0",
"com.linecorp.armeria:armeria-bom:1.0.0",
"io.grpc:grpc-bom:1.30.2",
"io.opentelemetry:opentelemetry-bom:0.10.0",
"io.zipkin.brave:brave-bom:5.12.3",
"io.zipkin.reporter2:zipkin-reporter-bom:2.15.0",
"org.apache.logging.log4j:log4j-bom:2.13.3",
Expand All @@ -43,40 +44,10 @@ val DEPENDENCY_SETS = listOf(
),
DependencySet(
"io.opentelemetry.javaagent",
"0.9.0",
"0.10.1",
listOf(
"opentelemetry-javaagent"
)
),
DependencySet(
"io.opentelemetry",
"0.9.1",
listOf(
"opentelemetry-api",
"opentelemetry-exporters-logging",
"opentelemetry-exporters-otlp"
)
),
DependencySet(
"io.opentelemetry",
"0.9.1",
listOf(
"opentelemetry-context-prop",
"opentelemetry-extension-trace-propagators",
"opentelemetry-proto",
"opentelemetry-sdk",
"opentelemetry-sdk-extension-aws-v1-support"
)
),
DependencySet(
"io.opentelemetry",
"0.9.1",
listOf(
"opentelemetry-sdk-baggage",
"opentelemetry-sdk-common",
"opentelemetry-sdk-correlation-context",
"opentelemetry-sdk-metrics",
"opentelemetry-sdk-tracing"
"opentelemetry-javaagent",
"opentelemetry-javaagent-spi"
)
),
DependencySet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ public static void premain(final String agentArgs, final Instrumentation inst) {
}

public static void agentmain(final String agentArgs, final Instrumentation inst) {
System.setProperty(
"io.opentelemetry.javaagent.shaded.io.opentelemetry.trace.spi.TracerProviderFactory",
"com.softwareaws.xray.opentelemetry.exporters.AwsTracerProviderFactory");
if (System.getProperty("otel.propagators", "").isEmpty()) {
System.setProperty("otel.propagators", "xray,tracecontext,b3");
}
OpenTelemetryAgent.agentmain(agentArgs, inst);
}
}
2 changes: 0 additions & 2 deletions smoke-tests/runner/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ tasks {
named<Test>("test") {
dependsOn(otelAgentJarTask)

enabled = System.getenv("CI") != null

jvmArgs(
"-Dio.awsobservability.instrumentation.smoketests.runner.agentPath=${otelAgentJarTask.get().archiveFile.get()
.getAsFile().absolutePath}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void hello() {
assertThat(response.status().isSuccess()).isTrue();
assertThat(response.headers())
.extracting(e -> e.getKey().toString())
.contains("received-x-amzn-trace-id", "received-x-b3-traceid", "received-traceparent");
.contains("received-x-amzn-trace-id", "received-b3", "received-traceparent");

var exported = getExported();
assertThat(exported)
Expand Down

0 comments on commit a954d64

Please sign in to comment.