Skip to content

Commit 368cdc7

Browse files
authored
Rename telemetryKind to telemetryType (#2535)
1 parent bc353f0 commit 368cdc7

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public enum SpanKind {
7676
}
7777
}
7878

79-
public enum SamplingTelemetryKind {
80-
// restricted to telemetry kinds that are supported by SamplingOverrides
79+
public enum SamplingTelemetryType {
80+
// restricted to telemetry types that are supported by SamplingOverrides
8181
@JsonProperty("request")
8282
REQUEST,
8383
@JsonProperty("dependency")
@@ -622,7 +622,10 @@ public static class SamplingOverride {
622622

623623
// TODO (trask) make this required when moving out of preview
624624
// for now the default is both "request" and "dependency" for backwards compatibility
625-
@Nullable public SamplingTelemetryKind telemetryKind;
625+
@Nullable public SamplingTelemetryType telemetryType;
626+
627+
// this config option existed in one GA release (3.4.0), and was then replaced by telemetryType
628+
@Deprecated @Nullable public SamplingTelemetryType telemetryKind;
626629

627630
// this config option only existed in one BETA release (3.4.0-BETA)
628631
@Deprecated @Nullable public Boolean includingStandaloneTelemetry;
@@ -635,15 +638,15 @@ public static class SamplingOverride {
635638
public String id; // optional, used for debugging purposes only
636639

637640
public boolean isForRequestTelemetry() {
638-
return telemetryKind == SamplingTelemetryKind.REQUEST
641+
return telemetryType == SamplingTelemetryType.REQUEST
639642
// this part is for backwards compatibility:
640-
|| (telemetryKind == null && spanKind != SpanKind.CLIENT);
643+
|| (telemetryType == null && spanKind != SpanKind.CLIENT);
641644
}
642645

643646
public boolean isForDependencyTelemetry() {
644-
return telemetryKind == SamplingTelemetryKind.DEPENDENCY
647+
return telemetryType == SamplingTelemetryType.DEPENDENCY
645648
// this part is for backwards compatibility:
646-
|| (telemetryKind == null && spanKind != SpanKind.SERVER);
649+
|| (telemetryType == null && spanKind != SpanKind.SERVER);
647650
}
648651

649652
public void validate() {

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,26 @@ private static void logConfigurationWarnings(Configuration config) {
177177
+ " so no need to enable it under preview configuration");
178178
}
179179
for (SamplingOverride override : config.preview.sampling.overrides) {
180+
if (override.telemetryKind != null) {
181+
configurationLogger.warn(
182+
"Sampling overrides \"telemetryKind\" has been deprecated,"
183+
+ " and support for it will be removed in a future release, please transition from"
184+
+ " \"telemetryKind\" to \"telemetryType\".");
185+
if (override.telemetryType == null) {
186+
override.telemetryType = override.telemetryKind;
187+
}
188+
}
180189
if (override.spanKind != null) {
181190
configurationLogger.warn(
182191
"Sampling overrides \"spanKind\" has been deprecated,"
183192
+ " and support for it will be removed in a future release, please transition from"
184-
+ " \"spanKind\" to \"telemetryKind\".");
193+
+ " \"spanKind\" to \"telemetryType\".");
185194
}
186-
if (override.telemetryKind == null) {
195+
if (override.telemetryType == null) {
187196
configurationLogger.warn(
188-
"Sampling overrides \"telemetryKind\" is missing,"
197+
"Sampling overrides \"telemetryType\" is missing,"
189198
+ " and will be required in a future release, please transition to add"
190-
+ " \"telemetryKind\" for sampling overrides.");
199+
+ " \"telemetryType\" for sampling overrides.");
191200
}
192201
if (override.includingStandaloneTelemetry != null) {
193202
configurationLogger.warn(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.microsoft.applicationinsights.agent.internal.common.FriendlyException;
2424
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration;
2525
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration.ProcessorConfig;
26-
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration.SamplingTelemetryKind;
26+
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration.SamplingTelemetryType;
2727
import com.microsoft.applicationinsights.agent.internal.configuration.RpConfiguration;
2828
import com.microsoft.applicationinsights.agent.internal.exporter.AgentLogExporter;
2929
import com.microsoft.applicationinsights.agent.internal.exporter.AgentMetricExporter;
@@ -472,11 +472,11 @@ private static LogExporter createLogExporter(
472472

473473
List<Configuration.SamplingOverride> logSamplingOverrides =
474474
configuration.preview.sampling.overrides.stream()
475-
.filter(override -> override.telemetryKind == SamplingTelemetryKind.TRACE)
475+
.filter(override -> override.telemetryType == SamplingTelemetryType.TRACE)
476476
.collect(Collectors.toList());
477477
List<Configuration.SamplingOverride> exceptionSamplingOverrides =
478478
configuration.preview.sampling.overrides.stream()
479-
.filter(override -> override.telemetryKind == SamplingTelemetryKind.EXCEPTION)
479+
.filter(override -> override.telemetryType == SamplingTelemetryType.EXCEPTION)
480480
.collect(Collectors.toList());
481481

482482
agentLogExporter =

0 commit comments

Comments
 (0)