Skip to content

[File based config] Support for Appd#2498

Merged
robsunday merged 13 commits intosignalfx:mainfrom
robsunday:fbc-appd-bonus
Nov 3, 2025
Merged

[File based config] Support for Appd#2498
robsunday merged 13 commits intosignalfx:mainfrom
robsunday:fbc-appd-bonus

Conversation

@robsunday
Copy link
Copy Markdown
Contributor

@robsunday robsunday commented Oct 27, 2025

This is support for AppD context. It includes service name and deployment environment name, as well as business transaction related data.
To make it working use the following snippet:

instrumentation/development:
  java:
    cisco:
      ctx:
        enabled: true

This implementation utilizes BeforeAgentListener to copy service name and deployment environment name from resource attributes to corresponding fields of Appd context propagator. It is implemented this way for two main reasons:

  1. Environment variable configuration uses resource customizer for this task. Resource customizers are not available in declarative configuration.
  2. Declarative configuration resource detectors are run after all registered DeclarativeConfigurationCustomizerProvider already run. Resource detectors may affect service name and other resource attributes, so our code must run after all the detectors. I'm not aware of any other reliable place to put the code to be executed after SDK is initialized and before any signals are reported.

@robsunday robsunday requested review from a team as code owners October 27, 2025 15:16
@Override
public void beforeAgent(AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk) {
ConfigProperties config = getConfig(autoConfiguredOpenTelemetrySdk);
if (!config.getBoolean("cisco.ctx.enabled", false)) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] Because we need to check "cisco.ctx.enabled" here, there was no point in getting rid of AppdBonusConfigurationCustomizerProvider class which also checks this property and adds appropriate propagator and span processor.

@SuppressWarnings("rawtypes")
@AutoService(ComponentProvider.class)
public class AppdBonusSpanProcessorComponentProvider implements ComponentProvider<SpanProcessor> {
static final String NAME = "appd-bonus";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] YAML naming convention prefers using underscore, but for consistency with environment variables based config I used hyphen in the name.

Resource resource = getResource(autoConfiguredOpenTelemetrySdk);
logger.fine(() -> "Setting up AppdBonusPropagator with resource: " + resource);

AppdBonusPropagator appdBonusPropagator = AppdBonusPropagator.getInstance();
Copy link
Copy Markdown
Contributor Author

@robsunday robsunday Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] This will also run when environment variables based configuration is in use. In such a case these propagator's properties are already set by AppdBonusCustomizer. If you think this is an issue I can cleanup AppdBunusCustomizer . This may make sense only if AppdBonusPropagator and span processor are long term solution, not a temporary one.


private static boolean isFeatureEnabled(
OpenTelemetryConfigurationModel model, Map<String, Object> properties) {
return (getAdditionalPropertyOrDefault(properties, CONFIG_CISCO_CTX_ENABLED, false));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded ()

Comment on lines +91 to +94
compositeList =
compositeList.isEmpty()
? AppdBonusPropagator.NAME
: AppdBonusPropagator.NAME + "," + compositeList;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without declarative config we need to add the default propagators. Just checking whether this is also needed here or is it so that when you don't add propagators to yaml then you don't get any default ones?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I missed that. Fixed now

@robsunday robsunday requested a review from laurit October 30, 2025 14:25
Copy link
Copy Markdown
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a couple small comments, but looks good to me.

Comment on lines +85 to +89
if (compositeList == null) {
compositeList = "";
} else if (!canAddPropagator(compositeList)) {
return false;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else makes it unnecessarily complex. In the null case, canAddPropagator() will return false anyway.

Suggested change
if (compositeList == null) {
compositeList = "";
} else if (!canAddPropagator(compositeList)) {
return false;
}
if (compositeList == null) {
compositeList = "";
}
if (!canAddPropagator(compositeList)) {
return false;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did even more refactoring and then merged it. Let me know if you don't like it. I can always create another PR

@robsunday robsunday merged commit af17570 into signalfx:main Nov 3, 2025
28 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants