Claus Ibsen created CAMEL-24918:
-----------------------------------
Summary: camel-core: metadata for endpoint options that are
evaluated as a Simple expression per message
Key: CAMEL-24918
URL: https://issues.apache.org/jira/browse/CAMEL-24918
Project: Camel
Issue Type: Improvement
Components: camel-core
Reporter: Claus Ibsen
Camel has no metadata saying which endpoint options are evaluated as a Simple
expression for each message. That knowledge only exists inside the producers,
so every tool that needs it has to guess.
It came up in CAMEL-24917, where the validator says that {{to:}} with
{{$\{...\}}} in the uri path should be {{toD:}}. The check needs to know the
components where an expression in the path is correct, and the only way to
write that today is a hand-maintained exclude list:
{code}
language, sql, sql-stored, elsql, jdbc, spring-jdbc, mybatis, xquery, xslt
{code}
That list is already wrong. {{camel-micrometer}}
({{micrometer:metricsType:metricsName}}) evaluates the metric name for every
message in {{AbstractMicrometerProducer.process}}:
{code:java}
String defaultMetricsName = simple(exchange, getEndpoint().getMetricsName(),
String.class);
{code}
so {{to: micrometer:counter:orders.$\{header.region\}}} is correct and the
validator flags it. {{camel-opentelemetry-metrics}} does the same. Neither is
in the list, and no list written by reading producer code stays right as
components are added.
h3. Proposal
A new attribute on {{@Metadata}}, beside the tooling flags that are already
there ({{supportFileReference}}, {{largeInput}}, {{inputLanguage}}):
{code:java}
@UriPath
@Metadata(supportSimpleExpression = true, description = "Name of the metric")
private String metricsName;
{code}
* {{camel-package-maven-plugin}} writes {{"supportSimpleExpression": true}}
into the component JSON, so it reaches the catalog
* the component documentation table says the option takes a Simple expression
* {{camel-yaml-dsl-validator}} replaces its exclude list with a catalog lookup:
an expression in the path is a mistake only when no path option of that
component supports Simple
* editors and Kaoto can offer expression completion where it is meant, and
nowhere else
h3. Work
# the {{supportSimpleExpression}} attribute and the generator support
# annotate the components that do it, found by looking for producers that
evaluate an endpoint field with the simple language: micrometer,
opentelemetry-metrics, language, sql and its relatives (the {{:#$\{...\}}}
parameters), file and ftp ({{fileName}}), jpa ({{parameters}}), and whatever
else the sweep turns up
# the validator reads the catalog instead of its list
This is worth doing beyond the validator: it is metadata that nothing in Camel
records today, and every tool around Camel - documentation, editors, agents -
has to guess without it.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)