Skip to content

Commit ba23661

Browse files
authored
New preview flag (#1601)
* Better debug logs * Fix sporadic docker networking failure * Update dependency * Build script improvements * Fix test message * Support gradle build with skipWinNative
1 parent 3db77c6 commit ba23661

File tree

72 files changed

+255
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+255
-163
lines changed

.github/workflows/pr.yaml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@ on:
77
- master
88

99
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up Java 11
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 11
18+
- name: Init and update otel submodule
19+
run: |
20+
git submodule init
21+
git submodule update
22+
- name: Restore cache
23+
uses: burrunan/gradle-cache-action@v1
24+
- name: Build otel-fork
25+
run: |
26+
cd otel
27+
# TODO why does this error only happen in GHA, without "-x signMavenPublication"?
28+
# "Cannot perform signing task ':instrumentation-api:signMavenPublication' because it has no configured signatory"
29+
./gradlew publishToMavenLocal -x signMavenPublication
30+
- name: Test
31+
# TODO enable build cache, either --build-cache here, or org.gradle.caching=true in gradle.properties
32+
# TODO enable tests (currently a couple don't pass on linux)
33+
run: ./gradlew check -x test --stacktrace
34+
1035
setup-smoke-test-matrix:
1136
runs-on: ubuntu-latest
1237
outputs:
@@ -40,6 +65,8 @@ jobs:
4065
git submodule update
4166
- name: Restore cache
4267
uses: burrunan/gradle-cache-action@v1
68+
with:
69+
read-only: true
4370
- name: Build otel-fork
4471
run: |
4572
cd otel
@@ -48,10 +75,10 @@ jobs:
4875
./gradlew publishToMavenLocal -x signMavenPublication
4976
- name: Test
5077
# TODO enable build cache, either --build-cache here, or org.gradle.caching=true in gradle.properties
51-
run: ./gradlew ${{ matrix.module }}:smokeTest --no-daemon
78+
run: ./gradlew ${{ matrix.module }}:smokeTest
5279

5380
accept-pr:
54-
needs: smoke-test
81+
needs: [ build, smoke-test ]
5582
runs-on: ubuntu-latest
5683
if: always()
5784
steps:

.pipelines/pipeline.user.windows.buddy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build:
99
- !!buildcommand
1010
name: 'Assemble ApplicationInsights-Java JARs'
1111
command: '.scripts/gradle.cmd'
12-
arguments: 'assemble prepare'
12+
arguments: 'assemble copyLibsToGlobalArtifactsFolder'
1313
artifacts:
1414
- to: 'Artifacts'
1515
include:

.pipelines/pipeline.user.windows.official.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build:
88
- !!buildcommand
99
name: 'Assemble ApplicationInsights-Java JARs'
1010
command: '.scripts/gradle.cmd'
11-
arguments: 'assemble prepare -DisRelease=true -Pai.etw.native.build=release'
11+
arguments: 'assemble copyLibsToGlobalArtifactsFolder -DisRelease=true -Pai.etw.native.build=release'
1212
artifacts:
1313
- to: 'Artifacts'
1414
include:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public String get() {
9191
//it's possible the appId returned is null (e.g. async task is still pending or has failed). In this case, just
9292
//return and let the next request resolve the ikey.
9393
if (appId == null) {
94-
logger.debug("appId has not been retrived yet (e.g. task may be pending or failed)");
94+
logger.debug("appId has not been retrieved yet (e.g. task may be pending or failed)");
9595
return "";
9696
}
9797
return appId;

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/wasbootstrap/OpenTelemetryConfigurer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public void configure(SdkTracerProviderBuilder tracerProvider) {
5454

5555
if (currExporter == null) {
5656
currExporter = processorConfig.type == ProcessorType.attribute ?
57-
new ExporterWithAttributeProcessor(processorConfig, new Exporter(telemetryClient)) :
58-
new ExporterWithSpanProcessor(processorConfig, new Exporter(telemetryClient));
57+
new ExporterWithAttributeProcessor(processorConfig, new Exporter(telemetryClient, config.preview.httpMethodInOperationName)) :
58+
new ExporterWithSpanProcessor(processorConfig, new Exporter(telemetryClient, config.preview.httpMethodInOperationName));
5959

6060
} else {
6161
currExporter = processorConfig.type == ProcessorType.attribute ?
@@ -67,7 +67,7 @@ public void configure(SdkTracerProviderBuilder tracerProvider) {
6767
tracerProvider.addSpanProcessor(SimpleSpanProcessor.create(currExporter));
6868

6969
} else {
70-
tracerProvider.addSpanProcessor(SimpleSpanProcessor.create(new Exporter(telemetryClient)));
70+
tracerProvider.addSpanProcessor(SimpleSpanProcessor.create(new Exporter(telemetryClient, config.preview.httpMethodInOperationName)));
7171
}
7272
}
7373
}

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/wasbootstrap/configuration/Configuration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ public static class PreviewConfiguration {
175175
// ignoreRemoteParentNotSampled is currently needed
176176
// because .NET SDK always propagates trace flags "00" (not sampled)
177177
public boolean ignoreRemoteParentNotSampled = true;
178+
// TODO consider turning this on by default in 3.1.0
179+
public boolean httpMethodInOperationName;
178180
public LiveMetrics liveMetrics = new LiveMetrics();
179181

180182
public ProfilerConfiguration profiler = new ProfilerConfiguration();

agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/LazyConfigurationAccessorTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public class LazyConfigurationAccessorTest {
4141
* VALID NULL Enabled
4242
* NULL TRUE/FALSE/NULL Disabled
4343
*/
44-
private static final String CONNECTION_STRING =
45-
"InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://fakeingestion:60606/";
44+
private static final String CONNECTION_STRING = "InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF";
4645

4746
private static final String INSTRUMENTATION_KEY = "00000000-0000-0000-0000-0FEEDDADBEEF";
4847
private static final String WEBSITE_SITE_NAME = "fake_site_name";

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ public class Exporter implements SpanExporter {
128128

129129
private final TelemetryClient telemetryClient;
130130

131-
public Exporter(TelemetryClient telemetryClient) {
131+
private final boolean httpMethodInOperationName;
132+
133+
public Exporter(TelemetryClient telemetryClient, boolean httpMethodInOperationName) {
132134
this.telemetryClient = telemetryClient;
135+
this.httpMethodInOperationName = httpMethodInOperationName;
133136
}
134137

135138
/**
@@ -204,7 +207,7 @@ private void exportRemoteDependency(SpanData span, boolean inProc) {
204207
RemoteDependencyTelemetry remoteDependencyData = new RemoteDependencyTelemetry();
205208

206209
addLinks(remoteDependencyData.getProperties(), span.getLinks());
207-
remoteDependencyData.setName(span.getName());
210+
remoteDependencyData.setName(getTelemetryName(span));
208211

209212
Attributes attributes = span.getAttributes();
210213

@@ -562,7 +565,7 @@ private void exportRequest(SpanData span) {
562565
requestData.setUrl(httpUrl);
563566
}
564567

565-
String name = span.getName();
568+
String name = getTelemetryName(span);
566569
requestData.setName(name);
567570
requestData.getContext().getOperation().setName(name);
568571
requestData.setId(span.getSpanId());
@@ -604,6 +607,18 @@ private void exportRequest(SpanData span) {
604607
exportEvents(span, samplingPercentage);
605608
}
606609

610+
private String getTelemetryName(SpanData span) {
611+
String name = span.getName();
612+
if (!httpMethodInOperationName || !name.startsWith("/")) {
613+
return name;
614+
}
615+
String httpMethod = span.getAttributes().get(SemanticAttributes.HTTP_METHOD);
616+
if (Strings.isNullOrEmpty(httpMethod)) {
617+
return name;
618+
}
619+
return httpMethod + " " + name;
620+
}
621+
607622
private static String nullAwareConcat(String str1, String str2, String separator) {
608623
if (str1 == null) {
609624
return str2;

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ plugins {
2929
id "org.owasp.dependencycheck" version "6.1.2"
3030
id "com.diffplug.spotless" version "5.8.2"
3131
id "com.github.spotbugs" version "4.6.0" apply false
32+
33+
id "com.github.ben-manes.versions" version "0.38.0"
3234
}
3335

3436
ext.buildScriptsDir = "$rootDir/gradle"

core/src/main/java/com/microsoft/applicationinsights/channel/concrete/TelemetryChannelBase.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ public void send(Telemetry telemetry) {
230230
logger.debug("items sent till now: {}", itemsSent.get());
231231
}
232232

233-
if (isDeveloperMode()) {
234-
writeTelemetryToDebugOutput(telemetry);
233+
if (logger.isTraceEnabled()) {
234+
logger.trace("{} sending telemetry: {}", this.getClass().getSimpleName(), telemetry.toString());
235235
}
236236
}
237237

@@ -242,10 +242,6 @@ public void send(Telemetry telemetry) {
242242
*/
243243
protected abstract boolean doSend(Telemetry telemetry);
244244

245-
private void writeTelemetryToDebugOutput(Telemetry telemetry) {
246-
logger.trace("{} sending telemetry: {}", this.getClass().getSimpleName(), telemetry.toString());
247-
}
248-
249245
protected abstract ConfiguredTransmitterFactory<T> createTransmitterFactory();
250246

251247
protected LimitsEnforcer createDefaultMaxTelemetryBufferCapacityEnforcer(Integer currentValue) {

0 commit comments

Comments
 (0)