-
Notifications
You must be signed in to change notification settings - Fork 158
Common Expression Language (CEL) sampler #1957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@dol this looks nice! @johnbley what do you think of CEL vs JEXL in the context of open-telemetry/opentelemetry-java-instrumentation#13590? |
Just a note to myself. I need to expand the test cases with the following addition.
|
Very interesting! I'll take a look at it! |
As I refined the tests I found some edge cases in the setup and mapping of the CEL engine. I'll mark the PR as work in progress. Sorry for that. |
no worries! you can click "Convert to draft" (hidden under the list of reviewers), and then when you're ready you can click "Ready for review" |
@trask @jack-berg : I wanted you to give an update on the PR. As I was adding more tests cases to PR I encountered a problem with single/double quote parsing on the declarative config. First I though it's an issue with a complex expression input. But after digging deep into the source code of this project and I created the following bug report: open-telemetry/opentelemetry-java#7429 As the chances are very high that a complex expression will need to mix single and double quotes, this bug should be addressed first. |
open-telemetry/opentelemetry-java#7433 should fix this regression. |
The latest version added more unit tests and better coverage. I think the new CEL sampler is ready for an review. |
Build is pretty broken. Can you look at this @dol thanks! |
@breedx-splk I'm waiting for the |
Adds new CelBasedSampler to the OpenTelemetry Java SDK, enabling advanced sampling rules using the Common Expression Language (CEL). It also includes updates to the existing RuleBasedRoutingSampler for consistency and clarity.
This pull request introduces a new
CelBasedSampler
to the OpenTelemetry Java SDK, enabling advanced sampling rules using the Common Expression Language (CEL). It also includes updates to the existingRuleBasedRoutingSampler
for consistency and clarity. Below is a summary of the most important changes grouped by theme:New
CelBasedSampler
Implementation:CelBasedSampler
class, which evaluates CEL expressions to make sampling decisions based on span attributes. It includes a fallback sampler and supports multiple expressions. (samplers/src/main/java/io/opentelemetry/contrib/sampler/CelBasedSampler.java
)CelBasedSamplerBuilder
to constructCelBasedSampler
instances with methods for adding expressions and specifying actions (e.g.,DROP
orRECORD_AND_SAMPLE
). (samplers/src/main/java/io/opentelemetry/contrib/sampler/CelBasedSamplerBuilder.java
)CelBasedSamplingExpression
class to encapsulate individual CEL expressions and their associated samplers. (samplers/src/main/java/io/opentelemetry/contrib/sampler/CelBasedSamplingExpression.java
)CelBasedSampler
, enabling configuration through YAML files. (samplers/src/main/java/io/opentelemetry/contrib/sampler/internal/CelBasedSamplerComponentProvider.java
)Documentation Updates:
samplers/README.md
to document the newCelBasedSampler
, including its usage, schema, and example configurations. (samplers/README.md
) [1] [2]Dependency Additions:
dev.cel:cel:0.9.0
library to enable CEL expression evaluation. (samplers/build.gradle.kts
)Updates to
RuleBasedRoutingSampler
:SamplingRule
toRuleBasedRoutingSamplingRule
for clarity and updated all related references in theRuleBasedRoutingSampler
and its builder. (samplers/src/main/java/io/opentelemetry/contrib/sampler/RuleBasedRoutingSampler.java
,samplers/src/main/java/io/opentelemetry/contrib/sampler/RuleBasedRoutingSamplerBuilder.java
,samplers/src/main/java/io/opentelemetry/contrib/sampler/RuleBasedRoutingSamplingRule.java
) [1] [2] [3] [4] [5] [6] [7]These changes collectively enhance the SDK's sampling capabilities, allowing users to define sophisticated sampling rules using CEL while maintaining compatibility with existing samplers.