Skip to content

Commit 6f6212d

Browse files
committed
use app_name to set job.name-format
1 parent 4960fbf commit 6f6212d

6 files changed

Lines changed: 24 additions & 6 deletions

File tree

docs/modules/trino/pages/usage-guide/openlineage.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ spec:
4040
# caCert:
4141
# secretClass: marquez-ca
4242
# namespace: trino-lineage # <3>
43+
# appName: "$QUERY_ID" # <4>
4344
...
4445
----
4546
<1> Adding the `openLineage` block enables OpenLineage event emission. Omit it entirely to leave OpenLineage off (the default).
4647
<2> The OpenLineage backend connection. Use `inline` (shown here) to define the connection directly, or `reference: <name>` to point at an `OpenLineageConnection` resource in the same namespace. Required.
4748
<3> Optional. The OpenLineage namespace events are reported under. Defaults to the cluster's Kubernetes namespace.
48-
49-
NOTE: The shared connection type also accepts an `appName` field. It is ignored for Trino, which is a long-running service rather than a single job and derives an OpenLineage job name per query.
49+
<4> Optional. Sets the OpenLineage job name format (`openlineage-event-listener.job.name-format`). Accepts an arbitrary string with optional `$QUERY_ID`, `$USER`, `$SOURCE` and `$CLIENT_IP` substitution variables. When unset, Trino defaults to `$QUERY_ID`. See the link:https://trino.io/docs/current/admin/event-listeners-openlineage.html[Trino OpenLineage event listener documentation {external-link-icon}^].
5050

5151
The `OpenLineageConnection` resource (`openlineage.stackable.tech`) is a reusable definition of a connection to an OpenLineage backend, provided by the Stackable operator library.
5252
Reference it to share one backend definition across multiple clusters:

extra/crds.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,9 @@ spec:
896896
Emit [OpenLineage](https://openlineage.io/) lineage events for the queries run on this
897897
Trino cluster. The OpenLineage event listener runs on the coordinator only.
898898
The backend connection is either inlined or references an `OpenLineageConnection` resource.
899-
The shared `appName` field is not used by Trino, which derives an OpenLineage job name per
900-
query. See the [OpenLineage usage guide](https://docs.stackable.tech/home/nightly/trino/usage-guide/openlineage).
899+
The shared `appName` field sets the OpenLineage job name format
900+
(`openlineage-event-listener.job.name-format`); when unset Trino defaults to `$QUERY_ID`.
901+
See the [OpenLineage usage guide](https://docs.stackable.tech/home/nightly/trino/usage-guide/openlineage).
901902
nullable: true
902903
properties:
903904
appName:

rust/operator-binary/src/config/open_lineage.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ pub const OPENLINEAGE_TRANSPORT_URL_KEY: &str = "openlineage-event-listener.tran
6161
pub const OPENLINEAGE_TRANSPORT_API_KEY_KEY: &str = "openlineage-event-listener.transport.api-key";
6262
/// The OpenLineage namespace lineage is reported under.
6363
pub const OPENLINEAGE_NAMESPACE_KEY: &str = "openlineage-event-listener.namespace";
64+
/// Format for the emitted OpenLineage job name. Set from `spec.clusterConfig.openLineage.appName`.
65+
/// Accepts an arbitrary string with optional `$QUERY_ID`, `$USER`, `$SOURCE` and `$CLIENT_IP`
66+
/// substitution variables (Trino defaults to `$QUERY_ID` when unset).
67+
pub const OPENLINEAGE_JOB_NAME_FORMAT_KEY: &str = "openlineage-event-listener.job.name-format";
6468
/// The URI identifying this Trino cluster in emitted lineage. Computed from the coordinator service
6569
/// at ConfigMap-build time (see [`crate::controller::build::properties::event_listener_properties`]).
6670
pub const OPENLINEAGE_TRINO_URI_KEY: &str = "openlineage-event-listener.trino.uri";
@@ -148,6 +152,14 @@ impl ResolvedOpenLineageConfig {
148152
.unwrap_or_else(|| namespace.to_string()),
149153
);
150154

155+
// The stable OpenLineage job name format. When unset, Trino defaults to `$QUERY_ID`.
156+
if let Some(app_name) = &open_lineage.app_name {
157+
properties.insert(
158+
OPENLINEAGE_JOB_NAME_FORMAT_KEY.to_string(),
159+
app_name.clone(),
160+
);
161+
}
162+
151163
// Backend TLS: mount and import a `SecretClass` CA into the client truststore. WebPKI and
152164
// no verification need nothing (WebPKI is trusted via the system bundle already seeded into
153165
// the truststore; without server verification the URL is plain `http`).

rust/operator-binary/src/crd/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,9 @@ pub mod versioned {
296296
/// Emit [OpenLineage](https://openlineage.io/) lineage events for the queries run on this
297297
/// Trino cluster. The OpenLineage event listener runs on the coordinator only.
298298
/// The backend connection is either inlined or references an `OpenLineageConnection` resource.
299-
/// The shared `appName` field is not used by Trino, which derives an OpenLineage job name per
300-
/// query. See the [OpenLineage usage guide](DOCS_BASE_URL_PLACEHOLDER/trino/usage-guide/openlineage).
299+
/// The shared `appName` field sets the OpenLineage job name format
300+
/// (`openlineage-event-listener.job.name-format`); when unset Trino defaults to `$QUERY_ID`.
301+
/// See the [OpenLineage usage guide](DOCS_BASE_URL_PLACEHOLDER/trino/usage-guide/openlineage).
301302
#[serde(default, skip_serializing_if = "Option::is_none")]
302303
pub open_lineage: Option<openlineage::v1alpha1::OpenLineageJob>,
303304

tests/templates/kuttl/openlineage/02_trino.yaml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ spec:
5555
{% if test_scenario['values']['openlineage-use-auth'] == 'true' %}
5656
authenticationClassRef: openlineage-auth-$NAMESPACE
5757
{% endif %}
58+
# Sets openlineage-event-listener.job.name-format (asserted in 03-assert.yaml).
59+
appName: "trino-$QUERY_ID"
5860
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
5961
vectorAggregatorConfigMapName: vector-aggregator-discovery
6062
{% endif %}

tests/templates/kuttl/openlineage/03-assert.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ commands:
1212
echo "$CM" | grep -q "event-listener.name=openlineage"
1313
echo "$CM" | grep -q "openlineage-event-listener.transport.url"
1414
echo "$CM" | grep -q "event-listener.config-files=/stackable/rwconfig/event-listener.properties"
15+
# appName maps to the OpenLineage job name format.
16+
echo "$CM" | grep -q "openlineage-event-listener.job.name-format=trino-"
1517
# Workers must NOT get an event listener configured.
1618
- script: |
1719
! kubectl get -n "$NAMESPACE" configmap trino-openlineage-worker-default -o yaml | grep -q "event-listener.properties"

0 commit comments

Comments
 (0)