Skip to content

Commit 87a9e09

Browse files
committed
Update to latest opentelemetry-auto-instr-java
1 parent f4f07ea commit 87a9e09

File tree

9 files changed

+36
-23
lines changed

9 files changed

+36
-23
lines changed

agent/agent-bootstrap/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ task generateVersionProperties(type: PropsFileGen) {
2424
processResources.dependsOn generateVersionProperties
2525

2626
dependencies {
27-
compile (group: 'io.opentelemetry.auto', name: 'auto-bootstrap', version: '0.4.0-SNAPSHOT') {
27+
compile (group: 'io.opentelemetry.auto', name: 'auto-bootstrap', version: '0.5.0-SNAPSHOT') {
2828
exclude group: 'org.slf4j', module: 'slf4j-simple'
2929
}
3030
compile 'ch.qos.logback:logback-classic:1.2.3'

agent/agent-tooling/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies {
3737

3838
compile 'com.google.guava:guava:27.1-android'
3939

40-
compile 'io.opentelemetry.auto:auto-tooling:0.4.0-SNAPSHOT'
40+
compile 'io.opentelemetry.auto:auto-tooling:0.5.0-SNAPSHOT'
4141
compile 'org.checkerframework:checker-qual-android:3.1.0'
4242

4343
compile(project(':core')) {

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/sampling/FixedRateSampler.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
package com.microsoft.applicationinsights.agent.internal.sampling;
22

3-
import java.util.Collections;
4-
import java.util.List;
5-
import java.util.Map;
6-
import javax.annotation.Nullable;
7-
83
import com.google.common.collect.ImmutableMap;
9-
import io.opentelemetry.sdk.trace.Sampler;
104
import io.opentelemetry.common.AttributeValue;
5+
import io.opentelemetry.sdk.trace.Sampler;
116
import io.opentelemetry.trace.Link;
12-
import io.opentelemetry.trace.Span.Kind;
7+
import io.opentelemetry.trace.Span;
138
import io.opentelemetry.trace.SpanContext;
14-
import io.opentelemetry.trace.SpanId;
159
import io.opentelemetry.trace.TraceId;
10+
import java.util.Collections;
11+
import java.util.List;
12+
import java.util.Map;
13+
import javax.annotation.Nullable;
1614
import org.slf4j.Logger;
1715
import org.slf4j.LoggerFactory;
1816

@@ -37,8 +35,12 @@ public FixedRateSampler(double samplingPercentage) {
3735
}
3836

3937
@Override
40-
public Decision shouldSample(@Nullable SpanContext parentContext, TraceId traceId, SpanId spanId, String name,
41-
Kind spanKind, Map<String, AttributeValue> attributes, List<Link> parentLinks) {
38+
public Decision shouldSample(@Nullable SpanContext parentContext,
39+
TraceId traceId,
40+
String name,
41+
Span.Kind spanKind,
42+
Map<String, AttributeValue> attributes,
43+
List<Link> parentLinks) {
4244
if (SamplingScoreGeneratorV2.getSamplingScore(traceId.toLowerBase16()) >= samplingPercentage) {
4345
logger.debug("Item {} sampled out", name);
4446
return alwaysOffDecision;

agent/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/TracerInstaller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import io.opentelemetry.context.propagation.DefaultContextPropagators;
1010
import io.opentelemetry.sdk.OpenTelemetrySdk;
1111
import io.opentelemetry.sdk.trace.config.TraceConfig;
12-
import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor;
12+
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
1313

1414
public class TracerInstaller {
1515

@@ -32,7 +32,7 @@ public static void installAgentTracer() {
3232
}
3333
// if changing the span processor to something async, flush it in the shutdown hook before flushing TelemetryClient
3434
OpenTelemetrySdk.getTracerProvider()
35-
.addSpanProcessor(SimpleSpansProcessor.create(new Exporter(telemetryClient)));
35+
.addSpanProcessor(SimpleSpanProcessor.newBuilder(new Exporter(telemetryClient)).build());
3636
}
3737

3838
public static void logVersionInfo() {

agent/exporter/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ repositories {
99
}
1010

1111
dependencies {
12-
compile 'io.opentelemetry:opentelemetry-sdk:0.3.0'
12+
compile 'io.opentelemetry:opentelemetry-sdk:0.5.0'
1313

1414
// this is needed in order to access AiAppId in auto-bootstrap for appId exchange data
15-
compileOnly 'io.opentelemetry.auto:auto-bootstrap:0.4.0-SNAPSHOT'
15+
compileOnly 'io.opentelemetry.auto:auto-bootstrap:0.5.0-SNAPSHOT'
1616

1717
compile 'org.slf4j:slf4j-api:1.7.26'
1818

agent/exporter/src/main/java/com/microsoft/applicationinsights/agent/Exporter.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
import io.opentelemetry.common.AttributeValue;
4646
import io.opentelemetry.common.AttributeValue.Type;
4747
import io.opentelemetry.sdk.trace.data.SpanData;
48+
import io.opentelemetry.sdk.trace.data.SpanData.Event;
4849
import io.opentelemetry.sdk.trace.data.SpanData.Link;
49-
import io.opentelemetry.sdk.trace.data.SpanData.TimedEvent;
5050
import io.opentelemetry.sdk.trace.export.SpanExporter;
5151
import io.opentelemetry.trace.Span.Kind;
5252
import io.opentelemetry.trace.SpanId;
@@ -78,7 +78,7 @@ public ResultCode export(Collection<SpanData> spans) {
7878
return ResultCode.SUCCESS;
7979
} catch (Throwable t) {
8080
logger.error(t.getMessage(), t);
81-
return ResultCode.FAILED_NOT_RETRYABLE;
81+
return ResultCode.FAILURE;
8282
}
8383
}
8484

@@ -264,7 +264,7 @@ private void exportLogSpan(SpanData span) {
264264

265265
// currently only gRPC instrumentation creates events, which we export here as logs ("traces")
266266
private void exportEvents(SpanData span, Double samplingPercentage) {
267-
for (TimedEvent event : span.getTimedEvents()) {
267+
for (Event event : span.getEvents()) {
268268
String message = event.getName();
269269
long timeEpochNanos = event.getEpochNanos();
270270
String level = getString(event, "level");
@@ -439,7 +439,7 @@ private static Double getDouble(SpanData span, String attributeName) {
439439
}
440440

441441

442-
private static String getString(TimedEvent event, String attributeName) {
442+
private static String getString(Event event, String attributeName) {
443443
AttributeValue attributeValue = event.getAttributes().get(attributeName);
444444
if (attributeValue == null) {
445445
return null;
@@ -471,6 +471,11 @@ private void track(Telemetry telemetry, Double samplingPercentage) {
471471
telemetryClient.track(telemetry);
472472
}
473473

474+
@Override
475+
public ResultCode flush() {
476+
return null;
477+
}
478+
474479
@Override
475480
public void shutdown() {
476481
}

agent/instrumentation/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ repositories {
88
mavenLocal()
99
}
1010

11-
def instrumentationVersion = '0.4.0-SNAPSHOT'
11+
def instrumentationVersion = '0.5.0-SNAPSHOT'
1212

1313
dependencies {
1414
compile project(':agent:agent-tooling')
1515
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-apache-httpasyncclient-4.0', version: instrumentationVersion
1616
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-apache-httpclient-2.0', version: instrumentationVersion
1717
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-apache-httpclient-4.0', version: instrumentationVersion
1818
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-cassandra-3.0', version: instrumentationVersion
19+
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-cassandra-4.0', version: instrumentationVersion
1920
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-grpc-1.5', version: instrumentationVersion
2021
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-http-url-connection', version: instrumentationVersion
2122
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-java-class-loader', version: instrumentationVersion
@@ -32,7 +33,9 @@ dependencies {
3233
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-jms-1.1', version: instrumentationVersion
3334
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-kafka-clients-0.11', version: instrumentationVersion
3435
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-kafka-streams-0.11', version: instrumentationVersion
36+
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-lettuce-4.0', version: instrumentationVersion
3537
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-lettuce-5.0', version: instrumentationVersion
38+
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-lettuce-5.1', version: instrumentationVersion
3639
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-log4j-1.1', version: instrumentationVersion
3740
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-log4j-2.0', version: instrumentationVersion
3841
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-logback-1.0', version: instrumentationVersion
@@ -47,6 +50,7 @@ dependencies {
4750
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-opentelemetry-api-0.2.4', version: instrumentationVersion
4851
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-opentelemetry-api-0.3', version: instrumentationVersion
4952
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-opentelemetry-api-0.4', version: instrumentationVersion
53+
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-opentelemetry-api-beta', version: instrumentationVersion
5054
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-reactor-3.1', version: instrumentationVersion
5155
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-request-2.3', version: instrumentationVersion
5256
compile group: 'io.opentelemetry.auto.instrumentation', name: 'instrumentation-request-3.0', version: instrumentationVersion

opentelemetry-auto-instr-java

test/smoke/testApps/Lettuce/src/main/java/com/microsoft/applicationinsights/smoketestapp/LettuceTestServlet.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import javax.servlet.http.HttpServletResponse;
88

99
import io.lettuce.core.RedisClient;
10+
import io.lettuce.core.api.sync.RedisCommands;
1011

1112
@WebServlet("/*")
1213
public class LettuceTestServlet extends HttpServlet {
@@ -34,7 +35,8 @@ private void doGetInternal(HttpServletRequest req) throws Exception {
3435
private void lettuce() throws Exception {
3536
String hostname = System.getenv("REDIS");
3637
RedisClient redisClient = RedisClient.create("redis://" + hostname);
37-
redisClient.connect().sync();
38+
RedisCommands<String, String> redisCommands = redisClient.connect().sync();
39+
redisCommands.get("test");
3840
redisClient.shutdown();
3941
}
4042
}

0 commit comments

Comments
 (0)