Skip to content

Commit 72f5c76

Browse files
Introduce role to application rp configuration. (#1662)
* Introduce role to application rp configuration. * Role doesn't support hot load. * Role can be overrided by environment variables. Signed-off-by: Pan Li <[email protected]> * Make more consistent with app services behavior * oops Co-authored-by: Trask Stalnaker <[email protected]>
1 parent b7fc56c commit 72f5c76

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,14 @@ private static void overlayRpConfiguration(Configuration config, RpConfiguration
291291
if (rpConfiguration.ignoreRemoteParentNotSampled != null) {
292292
config.preview.ignoreRemoteParentNotSampled = rpConfiguration.ignoreRemoteParentNotSampled;
293293
}
294+
if (isTrimEmpty(config.role.name)) {
295+
// only use rp configuration role name as a fallback, similar to WEBSITE_SITE_NAME
296+
config.role.name = rpConfiguration.role.name;
297+
}
298+
if (isTrimEmpty(config.role.instance)) {
299+
// only use rp configuration role name as a fallback, similar to WEBSITE_INSTANCE_ID
300+
config.role.instance = rpConfiguration.role.instance;
301+
}
294302
}
295303

296304
private static String getConfigPath() {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
package com.microsoft.applicationinsights.agent.internal.wasbootstrap.configuration;
2323

24+
import com.microsoft.applicationinsights.agent.internal.wasbootstrap.configuration.Configuration.Role;
25+
import com.microsoft.applicationinsights.agent.internal.wasbootstrap.configuration.Configuration.Sampling;
2426
import org.checkerframework.checker.nullness.qual.Nullable;
2527

2628
import java.nio.file.Path;
@@ -38,12 +40,12 @@ public class RpConfiguration {
3840
// intentionally null, so that we can tell if rp is providing or not
3941
public Sampling sampling = new Sampling();
4042

43+
// this is needed in Azure Spring Cloud because it will set the role name to application name
44+
// on behalf of customers by default.
45+
// Note the role doesn't support hot load due to unnecessary currently.
46+
public Role role = new Role();
47+
4148
// this is needed in Azure Functions because .NET SDK always propagates trace flags "00" (not sampled)
4249
// null means do not override the users selection
4350
public @Nullable Boolean ignoreRemoteParentNotSampled;
44-
45-
public static class Sampling {
46-
47-
public double percentage = 100;
48-
}
4951
}

0 commit comments

Comments
 (0)