Skip to content

Conversation

@anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Nov 20, 2025

I was curious if I can update config to start implementing the composite samplers in file config and little did I realize what I was getting myself into ;) But having started, went ahead and chugged through it. Not sure what the right time for this is so will leave it in draft but let me know whenever we should go forward with it, or also feel free to do an initial review even while draft if desired. /cc @jack-berg

@anuraaga anuraaga requested a review from a team as a code owner November 20, 2025 07:33
@anuraaga anuraaga marked this pull request as draft November 20, 2025 07:33
@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

❌ Patch coverage is 88.42105% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.08%. Comparing base (04642a0) to head (bc11574).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
.../fileconfig/ComposableRuleBasedSamplerFactory.java 89.88% 5 Missing and 4 partials ⚠️
...incubator/fileconfig/ComposableSamplerFactory.java 66.66% 4 Missing and 2 partials ⚠️
...extension/incubator/fileconfig/FileConfigUtil.java 0.00% 4 Missing ⚠️
...extension/incubator/fileconfig/SamplerFactory.java 85.71% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7861      +/-   ##
============================================
- Coverage     90.10%   90.08%   -0.02%     
- Complexity     7325     7393      +68     
============================================
  Files           825      829       +4     
  Lines         22051    22395     +344     
  Branches       2179     2228      +49     
============================================
+ Hits          19868    20174     +306     
- Misses         1504     1528      +24     
- Partials        679      693      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zeitlinger
Copy link
Member

I also want to add support for open-telemetry/opentelemetry-configuration#376

@anuraaga
Copy link
Contributor Author

Thanks for the pointer @zeitlinger - this PR allows parsing them but doesn't update PrometheusComponentProvider. From what I can tell, the entire exporter needs to be updated to undeprecate this?

https://github.com/open-telemetry/opentelemetry-java/blob/main/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerBuilder.java#L87

I'm not sure if we would first do that before updating configuration, or do it together, happy to go with any approach.

@zeitlinger
Copy link
Member

to undeprecate this?

it was deprecated because it had a different meaning

  • old: disable scope metric
  • new: disable scope label

I think it's fine to the change together - happy to help out

@anuraaga
Copy link
Contributor Author

Thanks @zeitlinger - IIUC, there is currently no knob for the labels either

https://github.com/open-telemetry/opentelemetry-java/pull/7398/files#diff-bbf676997f34316d365def54b1ca5e2e4e65ecf892a045ca4008b353e1e2838eR460

If the knobs were already there, wiring them into declarative config would be simple, but if we need to add (or restore) new ones, I guess we should use a separate PR since they're for public API?

@zeitlinger
Copy link
Member

Thanks @zeitlinger - IIUC, there is currently no knob for the labels either

correct

If the knobs were already there, wiring them into declarative config would be simple, but if we need to add (or restore) new ones, I guess we should use a separate PR since they're for public API?

I think it doesn't matter if it's public API, because we would document it either way - but a separate PR is also fine

resource = model.getOtlpHttp();
}
if (model.getOtlpGrpc() != null) {
requireNullResource(resource, RESOURCE_NAME, model.getAdditionalProperties());
Copy link
Member

Choose a reason for hiding this comment

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

Adding strictness here to fail fast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think I understand the intent: if oitlp_http is present, make sure no other span exporters are set. But the implementation seems not quite right. requireNullResource produces an error message like Invalid configuration - multiple " + resourceName + "s set: " + additionalProperties.keySet().stream().collect(joining(",", "[", "]" based on additional properties, when its model.getOtlpHttp() which is causing the conflict.

Copy link
Member

Choose a reason for hiding this comment

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

The old implementation works because I was sort of cheating and moving all the well known exporter model definitions to additionalProperties.

Copy link
Member

Choose a reason for hiding this comment

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

I pushed bc11574 which sort of reverts this change but does it without polluting additionalProperties.

Thinking about this, I need to go apply this pattern to SamplerFactory, LgRecordProcessorFactory, SpanProcessorFactory, TextMapPropagatorFactory, AggregationFactory. In all these cases, exactly one key value pair is expected but the implementations tolerate multiple. Will do this in a followup PR.

Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

Thanks a lot, looks good! Can't merge it until opentelemetry-configuration cuts a release, but we can use this as a working branch.

import java.util.function.Predicate;
import javax.annotation.Nullable;

final class ComposableRuleBasedSamplerFactory
Copy link
Member

Choose a reason for hiding this comment

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

@anuraaga went ahead and implemented the ExperimentalComposableRuleBasedSampler type.

One thing that caught me by surprise was that you can't say something like WHERE http.request.method = GET AND http.route = /users/:id, since the attribute conditions can only match against a single attribute key. Well, technically you could match against two attribute keys by setting both .attribute_values and .attribute_patterns. WDYT? Am I overestimating how common this type of thing will be?

}
return new AttributeMatcher(
requireNonNull(attributeValuesModel.getKey(), "attribute_values key"),
IncludeExcludePredicate.createExactMatching(attributeValuesModel.getValues(), null));
Copy link
Member

Choose a reason for hiding this comment

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

Leaning on this IncludeExcludePredicate utility even when attribute_values doesn't have an exclude list because its convenient and already has a toString() implemented, which we declarative config tests rely on.

@jack-berg
Copy link
Member

Anyone other @open-telemetry/java-approvers planning on looking at this?

@jkwatson
Copy link
Contributor

Anyone other @open-telemetry/java-approvers planning on looking at this?

not I!

@jack-berg jack-berg changed the title Update to latest unreleased opentelemetry-configuration Update to opentelemetry-configuration 1.0.0-rc.3 Dec 18, 2025
Copy link
Contributor Author

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Thanks @jack-berg - can't approve my own PR but LGTM

resource = model.getOtlpHttp();
}
if (model.getOtlpGrpc() != null) {
requireNullResource(resource, RESOURCE_NAME, model.getAdditionalProperties());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jack-berg jack-berg merged commit 44af6c6 into open-telemetry:main Dec 19, 2025
27 checks passed
@otelbot
Copy link
Contributor

otelbot bot commented Dec 19, 2025

Thank you for your contribution @anuraaga! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants