This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/main by this push:
new 0eab1a53d2 feat(observability): logging foundations (bootstrap,
bridge, sanitizer) (#5375)
0eab1a53d2 is described below
commit 0eab1a53d2814c2a7dfaa5425b4df01a7baf9017
Author: Matthew B. <[email protected]>
AuthorDate: Sun Oct 25 06:01:49 2026 +0000
feat(observability): logging foundations (bootstrap, bridge, sanitizer)
(#5375)
### What changes were proposed in this PR?
> **In one sentence:** The OpenTelemetry foundation every later
observability PR builds on: off by default and opt-in, and anything
leaving the process is validated or bounded first.
Plumbing only. No dashboards, no metrics instrumentation, no API
changes.
---
#### The three pieces
| Component | Job |
|---|---|
| `OtelInit` | The single entry point. Reads its `OTEL_*` settings from
`observability.conf`, validates them, builds the SDK, registers it
globally. |
| `TexeraOtelLogAppender` | A Logback appender that mirrors app logs
into OTel. A thin shim, all security logic lives in the sanitizer. |
| `LogSanitizer` | Pure functions: redact secrets, strip control chars,
cap size, drop noisy MDC keys (and redact credential-named ones) before
anything ships. |
---
#### How a log record flows
```mermaid
flowchart TD
A["logger.info(...)"] --> B[Logback ROOT]
B --> C["console / file (always)"]
B --> D{appender bound?}
D -- no --> E[no-op]
D -- yes --> F[LogSanitizer]
F --> G["strip ctrl chars · redact secrets · cap 16K chars · filter
MDC"]
G --> H[OTLP exporter] --> I[collector]
```
If the appender is not bound (init off or not yet run), logs still flow
to stdout/file untouched.
---
#### Bootstrap, and how it stays safe
```mermaid
flowchart TD
A[Service.run] --> B{OTEL_SDK_DISABLED == false?}
B -- no --> C[INFO, no-op]
B -- yes --> D{endpoint valid?\nscheme + host allowlist}
D -- no --> E[one WARN, no-op]
D -- yes --> F[build SDK · attrs passthrough, service.name locked]
F --> G[attach appender · shutdown hook]
```
- **Default OFF.** Inert until explicitly enabled with
`OTEL_SDK_DISABLED=false`; while disabled no exporters start and nothing
is emitted (per #5367).
- **Fails quietly, never crashes.** Missing collector or bad config
gives one WARN and a no-op, never a startup exception.
- **No autoconfigure SPI**, on purpose: filtering must run *before* any
exporter is built, so we read every `OTEL_*` setting ourselves through
`observability.conf` (HOCON defaults with `${?OTEL_*}` overrides).
---
#### The reason it is its own PR: every output is validated or bounded
| Guard | Blocks |
|---|---|
| Endpoint scheme + host allowlist | exfiltration to arbitrary
protocols/hosts (scheme is `http`/`https` only; extend hosts via
`TEXERA_OTEL_ALLOWED_HOSTS`) |
| Resource-attribute `service.name` lock | env overriding the service
identity every record is keyed by (other attributes pass through) |
| MDC deny-list + credential-key redaction | noisy bridge fields and
secret-named values reaching exports |
| Secret redaction | Bearer tokens, `password=`, AWS keys printed in
logs (message and stack trace) |
| Control-char strip | CR/LF log forging from user strings |
| Body cap (16K chars via `MaxBodyChars`) + metric-interval fallback |
runaway log lines / busy-loop exporter |
Exception stack traces are appended to the log body, so Dropwizard 500s
stay diagnosable from the dashboard instead of vanishing behind `"Error
handling a request: <id>"`.
---
#### Supporting wiring
- OTel `1.50.0` deps pinned once in the `common/observability` module;
every service inherits them via `dependsOn(Observability)`.
- One-line `OtelInit.init(...)` added to each service entry point.
- The five `OTEL_*` knobs are exposed through `observability.conf`,
`EnvironmentalVariable`, and the single-node `.env` + k8s `values.yaml`
so operators can find and tune them.
- Framework log caps (`pekko`, `iceberg`, `hadoop`, `kafka`, `jetty`,
...) pinned at `WARN` so future TRACE/DEBUG surfaces Texera code, not
the framework firehose.
### Any related issues, documentation, or discussions?
Closes: #5367
Part of #4070. Approach:
https://github.com/apache/texera/discussions/5355
### How was this PR tested?
- Unit specs for all three components: `LogSanitizerSpec` (redaction,
stripping, truncation, MDC deny-list + credential-key redaction),
`OtelInitSpec` (endpoint validation, resource-attribute passthrough with
`service.name` protected, interval fallback, default-off, in-memory
exporter), `TexeraOtelLogAppenderSpec` (throwable-body redaction,
severity mapping, MDC handling), plus `ObservabilityConfigSpec` for the
config defaults.
- `sbt scalafmtCheckAll` passes and the `Config` + `Observability`
modules compile; full compile and tests run in CI.
### Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.8 in compliance with ASF policy.
Co-authored-by: Zuozhi Wang <[email protected]>
---
.github/workflows/build.yml | 2 +-
access-control-service/LICENSE-binary | 20 +
.../access-control-service-web-config.yaml | 13 +
.../texera/service/AccessControlService.scala | 2 +
amber/LICENSE-binary-java | 12 +
.../resources/computing-unit-master-config.yml | 12 +
.../texera-compiling-service-web-config.yml | 12 +
amber/src/main/resources/web-config.yml | 12 +
.../apache/texera/web/ComputingUnitMaster.scala | 1 +
.../apache/texera/web/TexeraWebApplication.scala | 1 +
bin/k8s/values-development.yaml | 15 +
bin/k8s/values.yaml | 15 +
bin/single-node/.env | 12 +
build.sbt | 20 +-
.../config/src/main/resources/observability.conf | 45 +++
.../common/config/EnvironmentalVariable.scala | 7 +
.../texera/common/config/ObservabilityConfig.scala | 38 ++
.../common/config/ObservabilityConfigSpec.scala | 65 ++++
common/observability/build.sbt | 75 ++++
.../apache/texera/observability/LogSanitizer.scala | 122 ++++++
.../org/apache/texera/observability/OtelInit.scala | 422 +++++++++++++++++++++
.../observability/TexeraOtelLogAppender.scala | 154 ++++++++
.../texera/observability/LogSanitizerSpec.scala | 140 +++++++
.../apache/texera/observability/OtelInitSpec.scala | 310 +++++++++++++++
.../observability/TexeraOtelLogAppenderSpec.scala | 243 ++++++++++++
computing-unit-managing-service/LICENSE-binary | 12 +
.../computing-unit-managing-service-config.yaml | 14 +-
.../service/ComputingUnitManagingService.scala | 2 +
config-service/LICENSE-binary | 20 +
.../main/resources/config-service-web-config.yaml | 13 +
.../org/apache/texera/service/ConfigService.scala | 2 +
file-service/LICENSE-binary | 12 +
.../main/resources/file-service-web-config.yaml | 12 +
.../org/apache/texera/service/FileService.scala | 2 +
notebook-migration-service/LICENSE-binary | 22 +-
.../notebook-migration-service-web-config.yaml | 14 +
.../texera/service/NotebookMigrationService.scala | 1 +
workflow-compiling-service/LICENSE-binary | 12 +
.../workflow-compiling-service-config.yaml | 12 +
.../texera/service/WorkflowCompilingService.scala | 2 +
40 files changed, 1911 insertions(+), 11 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e6ef48c184..3d44cc34d7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -329,7 +329,7 @@ jobs:
BACKPORT_TARGET_BRANCH: ${{ inputs.backport_target_branch }}
run: |
# Backport builds filter by the checked-out build.sbt.
- want=(DAO Auth Config Resource Util PyBuilder WorkflowCore
+ want=(DAO Auth Config Observability Resource Util PyBuilder
WorkflowCore
WorkflowOperator WorkflowCompiler WorkflowExecutionService)
tasks=()
if [ -n "${BACKPORT_TARGET_BRANCH}" ]; then
diff --git a/access-control-service/LICENSE-binary
b/access-control-service/LICENSE-binary
index 4f40d12738..abf08120e6 100644
--- a/access-control-service/LICENSE-binary
+++ b/access-control-service/LICENSE-binary
@@ -242,6 +242,9 @@ Scala/Java jars:
-
com.google.guava.listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
- com.google.j2objc.j2objc-annotations-2.8.jar
- com.helger.profiler-1.1.1.jar
+ - com.squareup.okhttp3.okhttp-4.12.0.jar
+ - com.squareup.okio.okio-3.6.0.jar
+ - com.squareup.okio.okio-jvm-3.6.0.jar
- com.thesamet.scalapb.lenses_2.13-0.11.20.jar
- com.thesamet.scalapb.scalapb-json4s_2.13-0.12.0.jar
- com.thesamet.scalapb.scalapb-runtime_2.13-0.11.20.jar
@@ -300,6 +303,18 @@ Scala/Java jars:
- io.fabric8.kubernetes-model-scheduling-6.12.1.jar
- io.fabric8.kubernetes-model-storageclass-6.12.1.jar
- io.fabric8.zjsonpatch-0.3.0.jar
+ - io.opentelemetry.opentelemetry-api-1.50.0.jar
+ - io.opentelemetry.opentelemetry-context-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-sender-okhttp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-extension-autoconfigure-spi-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-logs-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-metrics-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-trace-1.50.0.jar
- io.r2dbc.r2dbc-spi-1.0.0.RELEASE.jar
- jakarta.inject.jakarta.inject-api-2.0.1.jar
- jakarta.validation.jakarta.validation-api-3.0.2.jar
@@ -318,6 +333,11 @@ Scala/Java jars:
- org.hibernate.validator.hibernate-validator-7.0.5.Final.jar
- org.javassist.javassist-3.30.2-GA.jar
- org.jboss.logging.jboss-logging-3.5.3.Final.jar
+ - org.jetbrains.annotations-13.0.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-1.9.10.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-common-1.9.10.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-jdk7-1.9.10.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-jdk8-1.9.10.jar
- org.jooq.jooq-3.19.36.jar
- org.json4s.json4s-ast_2.13-4.0.1.jar
- org.json4s.json4s-jackson-core_2.13-4.0.1.jar
diff --git
a/access-control-service/src/main/resources/access-control-service-web-config.yaml
b/access-control-service/src/main/resources/access-control-service-web-config.yaml
index 8c7895e985..bd78ecaa82 100644
---
a/access-control-service/src/main/resources/access-control-service-web-config.yaml
+++
b/access-control-service/src/main/resources/access-control-service-web-config.yaml
@@ -26,6 +26,19 @@ server:
logging:
level: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
+ loggers:
+ # Cap noisy frameworks at WARN so TRACE/DEBUG surfaces Texera code
+ # (org.apache.texera) without the framework firehose.
+ "org.apache.pekko": WARN
+ "org.apache.iceberg": WARN
+ "org.apache.hadoop": WARN
+ "org.apache.kafka": WARN
+ "org.eclipse.jetty": WARN
+ "org.glassfish.jersey": WARN
+ "io.grpc": WARN
+ "io.netty": WARN
+ "com.zaxxer.hikari": WARN
+ "software.amazon.awssdk": WARN
appenders:
- type: console
threshold: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
diff --git
a/access-control-service/src/main/scala/org/apache/texera/service/AccessControlService.scala
b/access-control-service/src/main/scala/org/apache/texera/service/AccessControlService.scala
index ca2c797ab9..4a48efa7df 100644
---
a/access-control-service/src/main/scala/org/apache/texera/service/AccessControlService.scala
+++
b/access-control-service/src/main/scala/org/apache/texera/service/AccessControlService.scala
@@ -59,6 +59,8 @@ class AccessControlService extends
Application[AccessControlServiceConfiguration
configuration: AccessControlServiceConfiguration,
environment: Environment
): Unit = {
+ // Bridge this service's logs to the OTel collector under its own
service.name.
+ org.apache.texera.observability.OtelInit.init("access-control-service")
// Serve backend at /api
environment.jersey.setUrlPattern("/api/*")
diff --git a/amber/LICENSE-binary-java b/amber/LICENSE-binary-java
index a1eb381270..ef4f7b0a1f 100644
--- a/amber/LICENSE-binary-java
+++ b/amber/LICENSE-binary-java
@@ -363,6 +363,18 @@ Scala/Java jars:
- org.jspecify.jspecify-1.0.0.jar
- io.opencensus.opencensus-api-0.31.1.jar
- io.opencensus.opencensus-contrib-http-util-0.31.1.jar
+ - io.opentelemetry.opentelemetry-api-1.50.0.jar
+ - io.opentelemetry.opentelemetry-context-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-sender-okhttp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-extension-autoconfigure-spi-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-logs-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-metrics-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-trace-1.50.0.jar
- io.perfmark.perfmark-api-0.27.0.jar
- io.r2dbc.r2dbc-spi-1.0.0.RELEASE.jar
- io.reactivex.rxjava3.rxjava-3.1.12.jar
diff --git a/amber/src/main/resources/computing-unit-master-config.yml
b/amber/src/main/resources/computing-unit-master-config.yml
index 0dba594b8a..ee578c3cf9 100644
--- a/amber/src/main/resources/computing-unit-master-config.yml
+++ b/amber/src/main/resources/computing-unit-master-config.yml
@@ -34,6 +34,18 @@ logging:
level: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
loggers:
"io.dropwizard": ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
+ # Cap noisy frameworks at WARN so TRACE/DEBUG surfaces Texera code
+ # (org.apache.texera) without the framework firehose.
+ "org.apache.pekko": WARN
+ "org.apache.iceberg": WARN
+ "org.apache.hadoop": WARN
+ "org.apache.kafka": WARN
+ "org.eclipse.jetty": WARN
+ "org.glassfish.jersey": WARN
+ "io.grpc": WARN
+ "io.netty": WARN
+ "com.zaxxer.hikari": WARN
+ "software.amazon.awssdk": WARN
appenders:
- type: console
logFormat: "[%date{ISO8601}] [%level] [%logger] [%thread] - %msg %n"
diff --git a/amber/src/main/resources/texera-compiling-service-web-config.yml
b/amber/src/main/resources/texera-compiling-service-web-config.yml
index ea2c1b9c1e..c0b6e8aa76 100644
--- a/amber/src/main/resources/texera-compiling-service-web-config.yml
+++ b/amber/src/main/resources/texera-compiling-service-web-config.yml
@@ -43,6 +43,18 @@ logging:
level: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
loggers:
"io.dropwizard": ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
+ # Cap noisy frameworks at WARN so TRACE/DEBUG surfaces Texera code
+ # (org.apache.texera) without the framework firehose.
+ "org.apache.pekko": WARN
+ "org.apache.iceberg": WARN
+ "org.apache.hadoop": WARN
+ "org.apache.kafka": WARN
+ "org.eclipse.jetty": WARN
+ "org.glassfish.jersey": WARN
+ "io.grpc": WARN
+ "io.netty": WARN
+ "com.zaxxer.hikari": WARN
+ "software.amazon.awssdk": WARN
appenders:
- type: console
logFormat: "[%date{ISO8601}] [%level] [%logger] [%thread] - %msg %n"
diff --git a/amber/src/main/resources/web-config.yml
b/amber/src/main/resources/web-config.yml
index 9fde1d078e..9b3c743c89 100644
--- a/amber/src/main/resources/web-config.yml
+++ b/amber/src/main/resources/web-config.yml
@@ -43,6 +43,18 @@ logging:
level: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
loggers:
"io.dropwizard": ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
+ # Cap noisy frameworks at WARN so TRACE/DEBUG surfaces Texera code
+ # (org.apache.texera) without the framework firehose.
+ "org.apache.pekko": WARN
+ "org.apache.iceberg": WARN
+ "org.apache.hadoop": WARN
+ "org.apache.kafka": WARN
+ "org.eclipse.jetty": WARN
+ "org.glassfish.jersey": WARN
+ "io.grpc": WARN
+ "io.netty": WARN
+ "com.zaxxer.hikari": WARN
+ "software.amazon.awssdk": WARN
appenders:
- type: console
logFormat: "[%date{ISO8601}] [%level] [%logger] [%thread] - %msg %n"
diff --git
a/amber/src/main/scala/org/apache/texera/web/ComputingUnitMaster.scala
b/amber/src/main/scala/org/apache/texera/web/ComputingUnitMaster.scala
index 6f49fe1c3d..b5bdcbf557 100644
--- a/amber/src/main/scala/org/apache/texera/web/ComputingUnitMaster.scala
+++ b/amber/src/main/scala/org/apache/texera/web/ComputingUnitMaster.scala
@@ -138,6 +138,7 @@ class ComputingUnitMaster extends
io.dropwizard.Application[Configuration] with
}
override def run(configuration: Configuration, environment: Environment):
Unit = {
+ org.apache.texera.observability.OtelInit.init("computing-unit-master")
ObjectMapperUtils.warmupObjectMapperForOperatorsSerde()
SqlServer.initConnection(
diff --git
a/amber/src/main/scala/org/apache/texera/web/TexeraWebApplication.scala
b/amber/src/main/scala/org/apache/texera/web/TexeraWebApplication.scala
index 4a1d33f62e..07e07856e9 100644
--- a/amber/src/main/scala/org/apache/texera/web/TexeraWebApplication.scala
+++ b/amber/src/main/scala/org/apache/texera/web/TexeraWebApplication.scala
@@ -101,6 +101,7 @@ class TexeraWebApplication
}
override def run(configuration: TexeraWebConfiguration, environment:
Environment): Unit = {
+ org.apache.texera.observability.OtelInit.init("texera-web-application")
ObjectMapperUtils.warmupObjectMapperForOperatorsSerde()
// serve backend at /api
diff --git a/bin/k8s/values-development.yaml b/bin/k8s/values-development.yaml
index 5cbda8ee0d..accf9f39c9 100644
--- a/bin/k8s/values-development.yaml
+++ b/bin/k8s/values-development.yaml
@@ -435,6 +435,21 @@ texeraEnvVars:
# same value, so this is a fixed shared string rather than a per-pod
random one.
# Production environments MUST override this with a securely generated
secret.
value: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ # OpenTelemetry (observability). Disabled by default; set OTEL_SDK_DISABLED
to
+ # "false" and point the endpoint at a reachable OTLP collector (http/https
only) to enable.
+ - name: OTEL_SDK_DISABLED
+ value: "true"
+ - name: OTEL_EXPORTER_OTLP_ENDPOINT
+ value: "http://127.0.0.1:4317"
+ # Comma-separated resource attributes (k1=v1,k2=v2); service.name is set per
service.
+ - name: OTEL_RESOURCE_ATTRIBUTES
+ value: ""
+ # Comma-separated extra hosts allowed for the OTLP endpoint (loopback
allowed by default).
+ - name: TEXERA_OTEL_ALLOWED_HOSTS
+ value: ""
+ # Metric export interval in ms.
+ - name: OTEL_METRIC_EXPORT_INTERVAL
+ value: "30000"
yWebsocketServer:
name: y-websocket-server
diff --git a/bin/k8s/values.yaml b/bin/k8s/values.yaml
index 2058b2a0f8..4be79adf73 100644
--- a/bin/k8s/values.yaml
+++ b/bin/k8s/values.yaml
@@ -545,6 +545,21 @@ texeraEnvVars:
# If using VMs for CUs change this to the desired runtime otherwise leave
as "". Recommended: "kata-qemu-nvidia-gpu-runtime-rs"
# Note: kata containers must be installed to use
kata-qemu-nvidia-gpu-runtime-r
value: ""
+ # OpenTelemetry (observability). Disabled by default; set OTEL_SDK_DISABLED
to
+ # "false" and point the endpoint at a reachable OTLP collector (http/https
only) to enable.
+ - name: OTEL_SDK_DISABLED
+ value: "true"
+ - name: OTEL_EXPORTER_OTLP_ENDPOINT
+ value: "http://127.0.0.1:4317"
+ # Comma-separated resource attributes (k1=v1,k2=v2); service.name is set per
service.
+ - name: OTEL_RESOURCE_ATTRIBUTES
+ value: ""
+ # Comma-separated extra hosts allowed for the OTLP endpoint (loopback
allowed by default).
+ - name: TEXERA_OTEL_ALLOWED_HOSTS
+ value: ""
+ # Metric export interval in ms.
+ - name: OTEL_METRIC_EXPORT_INTERVAL
+ value: "30000"
yWebsocketServer:
name: y-websocket-server
diff --git a/bin/single-node/.env b/bin/single-node/.env
index 69a9ceeecb..40098c54c0 100644
--- a/bin/single-node/.env
+++ b/bin/single-node/.env
@@ -101,6 +101,18 @@
TEXERA_DASHBOARD_SERVICE_ENDPOINT=http://dashboard-service:8080
WORKFLOW_COMPILING_SERVICE_ENDPOINT=http://workflow-compiling-service:9090
WORKFLOW_EXECUTION_SERVICE_ENDPOINT=http://workflow-runtime-coordinator-service:8085
+# OpenTelemetry (observability). Disabled by default; the SDK stays inert until
+# OTEL_SDK_DISABLED=false. Point the endpoint at a reachable OTLP collector
+# (http/https only) before enabling.
+OTEL_SDK_DISABLED=true
+OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317
+# Comma-separated resource attributes (k1=v1,k2=v2); service.name is set per
service.
+OTEL_RESOURCE_ATTRIBUTES=
+# Comma-separated extra hosts allowed for the OTLP endpoint (loopback allowed
by default).
+TEXERA_OTEL_ALLOWED_HOSTS=
+# Metric export interval in ms.
+OTEL_METRIC_EXPORT_INTERVAL=30000
+
# Notebook migration tool
# Toggles the tool in the GUI; the migration itself needs an LLM key above.
GUI_WORKFLOW_WORKSPACE_PYTHON_NOTEBOOK_MIGRATION_ENABLED=true
diff --git a/build.sbt b/build.sbt
index d89f7a7508..2fd6b526fe 100644
--- a/build.sbt
+++ b/build.sbt
@@ -122,6 +122,11 @@ ThisBuild / excludeDependencies += ExclusionRule("log4j",
"log4j")
lazy val Util = (project in file("common/util")).settings(commonModuleSettings)
lazy val DAO = (project in file("common/dao")).settings(commonModuleSettings)
lazy val Config = (project in
file("common/config")).settings(commonModuleSettings)
+// OpenTelemetry bootstrap (OtelInit, log appender, sanitizer) shared by every
+// service entry point; pins the OTel dependency versions in one place. Depends
+// on Config to read OTEL_* settings from observability.conf.
+lazy val Observability =
+ (project in
file("common/observability")).settings(commonModuleSettings).dependsOn(Config)
lazy val Resource = (project in
file("common/resource")).settings(commonModuleSettings).dependsOn(DAO)
lazy val Auth = (project in file("common/auth"))
.settings(commonModuleSettings)
@@ -129,7 +134,7 @@ lazy val Auth = (project in file("common/auth"))
.dependsOn(DAO, Config)
.dependsOn(DAO % "test->test") // reuse MockTexeraDB embedded Postgres in
tests
lazy val ConfigService = (project in file("config-service"))
- .dependsOn(Auth, Config, DAO, Resource)
+ .dependsOn(Auth, Config, DAO, Resource, Observability)
.dependsOn(DAO % "test->test") // reuse MockTexeraDB embedded Postgres in
tests
.settings(commonModuleSettings)
.settings(
@@ -139,7 +144,7 @@ lazy val ConfigService = (project in file("config-service"))
)
)
lazy val AccessControlService = (project in file("access-control-service"))
- .dependsOn(Auth, Config, DAO, Resource)
+ .dependsOn(Auth, Config, DAO, Resource, Observability)
.settings(commonModuleSettings)
.settings(
dependencyOverrides ++= Seq(
@@ -163,7 +168,7 @@ lazy val WorkflowCore = (project in
file("common/workflow-core"))
.configs(Test)
.dependsOn(DAO % "test->test") // test scope dependency
lazy val ComputingUnitManagingService = (project in
file("computing-unit-managing-service"))
- .dependsOn(WorkflowCore, Auth, Config, Resource)
+ .dependsOn(WorkflowCore, Auth, Config, Resource, Observability)
.configs(Test)
.dependsOn(DAO % "test->test") // reuse MockTexeraDB embedded Postgres in
tests
.settings(commonModuleSettings)
@@ -210,7 +215,7 @@ lazy val ComputingUnitManagingService = (project in
file("computing-unit-managin
)
lazy val FileService = (project in file("file-service"))
.settings(commonModuleSettings)
- .dependsOn(WorkflowCore, Auth, Config, Resource, Util)
+ .dependsOn(WorkflowCore, Auth, Config, Resource, Util, Observability)
.configs(Test)
.dependsOn(DAO % "test->test") // test scope dependency
.dependsOn(WorkflowCore % "test->test") // reuse RustFSContainer in
MockLakeFS
@@ -241,7 +246,7 @@ lazy val WorkflowCompiler = (project in
file("common/workflow-compiler"))
.configs(Test)
.dependsOn(WorkflowOperator)
lazy val WorkflowCompilingService = (project in
file("workflow-compiling-service"))
- .dependsOn(WorkflowCompiler, Auth, Config, Resource)
+ .dependsOn(WorkflowCompiler, Auth, Config, Resource, Observability)
.settings(commonModuleSettings)
.settings(
dependencyOverrides ++= Seq(
@@ -253,7 +258,7 @@ lazy val WorkflowCompilingService = (project in
file("workflow-compiling-service
)
lazy val WorkflowExecutionService = (project in file("amber"))
- .dependsOn(WorkflowCompiler, Auth, Config)
+ .dependsOn(WorkflowCompiler, Auth, Config, Observability)
.settings(commonModuleSettings)
.settings(
dependencyOverrides ++= Seq(
@@ -272,7 +277,7 @@ lazy val WorkflowExecutionService = (project in
file("amber"))
.configs(Test)
.dependsOn(DAO % "test->test", Auth % "test->test") // test scope dependency
lazy val NotebookMigrationService = (project in
file("notebook-migration-service"))
- .dependsOn(Auth, Config, DAO, Resource)
+ .dependsOn(Auth, Config, DAO, Resource, Observability)
.settings(commonModuleSettings)
.settings(
dependencyOverrides ++= Seq(
@@ -288,6 +293,7 @@ lazy val TexeraProject = (project in file("."))
// common libraries
Auth,
Config,
+ Observability,
Resource,
Util,
DAO,
diff --git a/common/config/src/main/resources/observability.conf
b/common/config/src/main/resources/observability.conf
new file mode 100644
index 0000000000..2bf7a4e10d
--- /dev/null
+++ b/common/config/src/main/resources/observability.conf
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# OpenTelemetry SDK bootstrap settings, consumed by OtelInit. Each value has a
+# safe default and an optional environment override, so an operator can find
and
+# tune every knob here instead of in code.
+observability {
+ # Master switch. Disabled by default: no exporters start and no telemetry
is
+ # emitted until this is set to false (i.e. OTEL_SDK_DISABLED=false).
+ sdk-disabled = "true"
+ sdk-disabled = ${?OTEL_SDK_DISABLED}
+
+ # OTLP collector endpoint. http/https only; loopback-only host allowlist by
+ # default (extend via allowed-hosts below).
+ endpoint = "http://127.0.0.1:4317"
+ endpoint = ${?OTEL_EXPORTER_OTLP_ENDPOINT}
+
+ # Comma-separated resource attributes (k1=v1,k2=v2). service.name is set by
+ # the service and cannot be overridden here.
+ resource-attributes = ""
+ resource-attributes = ${?OTEL_RESOURCE_ATTRIBUTES}
+
+ # Comma-separated extra hosts added to the endpoint allowlist.
+ allowed-hosts = ""
+ allowed-hosts = ${?TEXERA_OTEL_ALLOWED_HOSTS}
+
+ # Metric export interval in milliseconds; out-of-range values fall back to
+ # the default.
+ metric-export-interval-ms = "30000"
+ metric-export-interval-ms = ${?OTEL_METRIC_EXPORT_INTERVAL}
+}
diff --git
a/common/config/src/main/scala/org/apache/texera/common/config/EnvironmentalVariable.scala
b/common/config/src/main/scala/org/apache/texera/common/config/EnvironmentalVariable.scala
index e1006c3fb5..6d82d666f1 100644
---
a/common/config/src/main/scala/org/apache/texera/common/config/EnvironmentalVariable.scala
+++
b/common/config/src/main/scala/org/apache/texera/common/config/EnvironmentalVariable.scala
@@ -48,6 +48,13 @@ object EnvironmentalVariable {
val ENV_USER_JWT_TOKEN = "USER_JWT_TOKEN"
val ENV_AUTH_JWT_SECRET = "AUTH_JWT_SECRET"
+ // OpenTelemetry observability (see observability.conf)
+ val ENV_OTEL_SDK_DISABLED = "OTEL_SDK_DISABLED"
+ val ENV_OTEL_EXPORTER_OTLP_ENDPOINT = "OTEL_EXPORTER_OTLP_ENDPOINT"
+ val ENV_OTEL_RESOURCE_ATTRIBUTES = "OTEL_RESOURCE_ATTRIBUTES"
+ val ENV_OTEL_METRIC_EXPORT_INTERVAL = "OTEL_METRIC_EXPORT_INTERVAL"
+ val ENV_TEXERA_OTEL_ALLOWED_HOSTS = "TEXERA_OTEL_ALLOWED_HOSTS"
+
/**
* Dataset-mount vars injected into the CU pod. The mount is performed by
the per-node
* mounter and reaches the pod through mount propagation, so the pod only
needs to know
diff --git
a/common/config/src/main/scala/org/apache/texera/common/config/ObservabilityConfig.scala
b/common/config/src/main/scala/org/apache/texera/common/config/ObservabilityConfig.scala
new file mode 100644
index 0000000000..29d121dbd4
--- /dev/null
+++
b/common/config/src/main/scala/org/apache/texera/common/config/ObservabilityConfig.scala
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.texera.common.config
+
+import com.typesafe.config.{Config, ConfigFactory}
+
+/**
+ * Typed view over observability.conf. Each field carries the HOCON default
+ * already merged with its OTEL_* environment override, so OtelInit reads its
+ * settings from one place instead of calling System.getenv directly. Values
+ * are kept as strings and interpreted by OtelInit, which tolerates malformed
+ * input without throwing.
+ */
+object ObservabilityConfig {
+ private val conf: Config =
ConfigFactory.parseResources("observability.conf").resolve()
+
+ val sdkDisabled: String = conf.getString("observability.sdk-disabled")
+ val endpoint: String = conf.getString("observability.endpoint")
+ val resourceAttributes: String =
conf.getString("observability.resource-attributes")
+ val allowedHosts: String = conf.getString("observability.allowed-hosts")
+ val metricExportIntervalMs: String =
conf.getString("observability.metric-export-interval-ms")
+}
diff --git
a/common/config/src/test/scala/org/apache/texera/common/config/ObservabilityConfigSpec.scala
b/common/config/src/test/scala/org/apache/texera/common/config/ObservabilityConfigSpec.scala
new file mode 100644
index 0000000000..659485bbc9
--- /dev/null
+++
b/common/config/src/test/scala/org/apache/texera/common/config/ObservabilityConfigSpec.scala
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.common.config
+
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+/**
+ * Spec for [[ObservabilityConfig]]. Reading each value forces resolution from
+ * observability.conf, so a renamed key surfaces here as a ConfigException.
+ * Exact-value assertions are guarded on the OTEL_* override being unset.
+ */
+class ObservabilityConfigSpec extends AnyFlatSpec with Matchers {
+
+ // `${?VAR}` in HOCON can be satisfied by an OS env var or a JVM system
property.
+ private def isOverridden(name: String): Boolean =
+ sys.env.contains(name) || sys.props.contains(name)
+
+ "ObservabilityConfig" should "default to disabled per issue #5367" in {
+ if (!isOverridden(EnvironmentalVariable.ENV_OTEL_SDK_DISABLED)) {
+ ObservabilityConfig.sdkDisabled shouldBe "true"
+ } else {
+ ObservabilityConfig.sdkDisabled should not be empty
+ }
+ }
+
+ it should "default to a loopback OTLP endpoint" in {
+ if (!isOverridden(EnvironmentalVariable.ENV_OTEL_EXPORTER_OTLP_ENDPOINT)) {
+ ObservabilityConfig.endpoint shouldBe "http://127.0.0.1:4317"
+ } else {
+ ObservabilityConfig.endpoint should not be empty
+ }
+ }
+
+ it should "default the metric export interval to 30s" in {
+ if (!isOverridden(EnvironmentalVariable.ENV_OTEL_METRIC_EXPORT_INTERVAL)) {
+ ObservabilityConfig.metricExportIntervalMs shouldBe "30000"
+ } else {
+ ObservabilityConfig.metricExportIntervalMs should not be empty
+ }
+ }
+
+ it should "resolve resource-attributes and allowed-hosts without error" in {
+ // Empty by default; the point is that the keys exist and resolve.
+ noException should be thrownBy ObservabilityConfig.resourceAttributes
+ noException should be thrownBy ObservabilityConfig.allowedHosts
+ }
+}
diff --git a/common/observability/build.sbt b/common/observability/build.sbt
new file mode 100644
index 0000000000..6b6f71f652
--- /dev/null
+++ b/common/observability/build.sbt
@@ -0,0 +1,75 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import scala.collection.Seq
+
+name := "observability"
+
+
+enablePlugins(JavaAppPackaging)
+
+// Enable semanticdb for Scalafix
+ThisBuild / semanticdbEnabled := true
+ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
+
+// Manage dependency conflicts by always using the latest revision
+ThisBuild / conflictManager := ConflictManager.latestRevision
+
+// Restrict parallel execution of tests to avoid conflicts
+Global / concurrentRestrictions += Tags.limit(Tags.Test, 1)
+
+/////////////////////////////////////////////////////////////////////////////
+// Compiler Options
+/////////////////////////////////////////////////////////////////////////////
+
+// Scala compiler options
+Compile / scalacOptions ++= Seq(
+ "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as
the threshold
+ "-feature", // Check feature warnings
+ "-deprecation", // Check deprecation warnings
+ "-Ywarn-unused:imports" // Check for unused imports
+)
+
+/////////////////////////////////////////////////////////////////////////////
+// Dependencies
+/////////////////////////////////////////////////////////////////////////////
+
+// OpenTelemetry version is pinned here as the single source of truth; every
+// service picks it up via dependsOn(Observability). Bump deliberately.
+val openTelemetryVersion = "1.50.0"
+
+libraryDependencies ++= Seq(
+ "com.typesafe.scala-logging" %% "scala-logging" % "3.9.5", // for
LazyLogging in OtelInit
+ // OpenTelemetry SDK bootstrap (Apache-2.0). We deliberately do NOT use
+ // sdk-extension-autoconfigure: endpoint validation (scheme + host allowlist)
+ // must run before any exporter is configured, and we build the providers
+ // explicitly rather than let anything be wired from the environment behind
+ // our back.
+ "io.opentelemetry" % "opentelemetry-api" % openTelemetryVersion,
+ "io.opentelemetry" % "opentelemetry-sdk" % openTelemetryVersion,
+ "io.opentelemetry" % "opentelemetry-exporter-otlp" % openTelemetryVersion,
+ // Logback Classic is needed at compile time to write the OTel log
+ // appender. Marked `provided` because every service already brings
+ // Logback in transitively (via Dropwizard / SLF4J), so we don't
+ // bundle a second copy.
+ "ch.qos.logback" % "logback-classic" % "1.2.13" % "provided",
+ // Test-only: in-memory exporter for OtelInitSpec; avoids hitting a real
+ // collector during unit tests.
+ "io.opentelemetry" % "opentelemetry-sdk-testing" % openTelemetryVersion %
Test,
+ "ch.qos.logback" % "logback-classic" % "1.2.13" % Test,
+ "org.scalatest" %% "scalatest" % "3.2.15" % Test // ScalaTest (for unit
tests)
+)
diff --git
a/common/observability/src/main/scala/org/apache/texera/observability/LogSanitizer.scala
b/common/observability/src/main/scala/org/apache/texera/observability/LogSanitizer.scala
new file mode 100644
index 0000000000..3cc3713c23
--- /dev/null
+++
b/common/observability/src/main/scala/org/apache/texera/observability/LogSanitizer.scala
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.observability
+
+import scala.jdk.CollectionConverters._
+
+/**
+ * Pure functions that sanitize log bodies and MDC before export:
+ * strip control characters, redact secrets, cap body size, and
+ * filter MDC down by dropping denied keys.
+ */
+object LogSanitizer {
+
+ /** Per-record body length cap, in chars. */
+ val MaxBodyChars: Int = 16 * 1024
+
+ /** Suffix appended to truncated bodies. */
+ val TruncatedMarker: String = "...[truncated]"
+
+ /** C0 control characters except TAB (0x09), plus DEL (0x7F). */
+ private val C0ControlRegex = "[\\x00-\\x08\\x0A-\\x1F\\x7F]".r
+
+ /** Secret patterns, redacted from bodies. Most specific first. */
+ private val SecretPatterns: Seq[scala.util.matching.Regex] = Seq(
+ // Bearer token
+ """(?i)Bearer\s+[A-Za-z0-9._\-/+=]{8,}""".r,
+ // password=... or password: ...
+ """(?i)password\s*[=:]\s*[^\s,;"']+""".r,
+ // AWS access key ID
+ """AKIA[0-9A-Z]{16}""".r,
+ // labelled AWS secret access key
+ """(?i)aws_secret_access_key\s*[=:]\s*[A-Za-z0-9/+=]{20,}""".r
+ )
+
+ /** MDC keys never forwarded to OTel log attributes. Default-allow: any key
+ * our instrumentation sets is exported, so adding a new correlation field
+ * needs no edit here. Only the noisy keys Pekko's SLF4J bridge injects are
+ * dropped, since they are redundant with the log body and would bloat
every
+ * exported record. Values that pass through are still run through
+ * [[sanitize]], so secret-shaped content is redacted regardless of key; a
+ * key whose name looks credential-bearing (see [[isSecretKey]]) has its
+ * value redacted wholesale.
+ */
+ val DeniedMdcKeys: Set[String] = Set(
+ "sourceThread",
+ "pekkoSource",
+ "pekkoAddress",
+ "pekkoTimestamp",
+ "sourceActorSystem"
+ )
+
+ /** Substrings marking an MDC key as credential-bearing. A matching key has
+ * its value redacted whole, since the value alone (e.g. a bare password)
+ * need not match any [[SecretPatterns]] regex to be a secret.
+ */
+ private val SecretKeySubstrings: Seq[String] =
+ Seq(
+ "password",
+ "passwd",
+ "pwd",
+ "secret",
+ "token",
+ "apikey",
+ "api_key",
+ "authorization",
+ "credential"
+ )
+
+ private def isSecretKey(key: String): Boolean = {
+ val k = key.toLowerCase
+ SecretKeySubstrings.exists(k.contains)
+ }
+
+ /** Strip C0 control characters (except TAB) and DEL. Null-safe. */
+ def stripControlChars(body: String): String =
+ if (body == null) "" else C0ControlRegex.replaceAllIn(body, "")
+
+ /** Redact secret-shaped substrings. Null-safe, idempotent. */
+ def redactSecrets(body: String): String =
+ if (body == null) ""
+ else SecretPatterns.foldLeft(body)((acc, p) => p.replaceAllIn(acc,
"[REDACTED]"))
+
+ /** Strip control chars, redact secrets, then truncate. Idempotent. */
+ def sanitize(body: String): String = {
+ if (body == null || body.isEmpty) return ""
+ truncate(redactSecrets(stripControlChars(body)))
+ }
+
+ /** Truncate to MaxBodyChars, appending the marker if cut. */
+ def truncate(body: String): String = {
+ if (body.length <= MaxBodyChars) body
+ else body.substring(0, MaxBodyChars - TruncatedMarker.length) +
TruncatedMarker
+ }
+
+ /** Drop denied MDC keys, sanitize the surviving values. A key whose name is
+ * credential-bearing has its value redacted whole. Null-safe.
+ */
+ def filterMdc(mdc: java.util.Map[String, String]): Map[String, String] = {
+ if (mdc == null) return Map.empty
+ mdc.asScala.iterator.collect {
+ case (k, v) if k != null && v != null && !DeniedMdcKeys.contains(k) =>
+ if (isSecretKey(k)) k -> "[REDACTED]" else k -> sanitize(v)
+ }.toMap
+ }
+}
diff --git
a/common/observability/src/main/scala/org/apache/texera/observability/OtelInit.scala
b/common/observability/src/main/scala/org/apache/texera/observability/OtelInit.scala
new file mode 100644
index 0000000000..43d00481aa
--- /dev/null
+++
b/common/observability/src/main/scala/org/apache/texera/observability/OtelInit.scala
@@ -0,0 +1,422 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.observability
+
+import com.typesafe.scalalogging.LazyLogging
+import org.apache.texera.common.config.{EnvironmentalVariable,
ObservabilityConfig}
+import io.opentelemetry.api.{GlobalOpenTelemetry, OpenTelemetry}
+import io.opentelemetry.api.common.{AttributeKey, Attributes}
+import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter
+import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter
+import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter
+import io.opentelemetry.sdk.OpenTelemetrySdk
+import io.opentelemetry.sdk.logs.SdkLoggerProvider
+import io.opentelemetry.sdk.logs.`export`.{BatchLogRecordProcessor,
LogRecordExporter}
+import io.opentelemetry.sdk.metrics.SdkMeterProvider
+import io.opentelemetry.sdk.metrics.`export`.{MetricExporter,
PeriodicMetricReader}
+import io.opentelemetry.sdk.resources.Resource
+import io.opentelemetry.sdk.trace.SdkTracerProvider
+import io.opentelemetry.sdk.trace.`export`.{BatchSpanProcessor, SpanExporter}
+
+import java.net.URI
+import java.time.Duration
+import scala.util.{Failure, Success, Try}
+
+/**
+ * Bootstraps the OpenTelemetry SDK for a Texera service.
+ *
+ * Disabled by default; set OTEL_SDK_DISABLED=false to enable it. Reads its
+ * settings from observability.conf (each defaulted, each OTEL_*-overridable),
+ * validates the endpoint against an allowlist, builds tracer/log/metric
+ * providers, and attaches a Logback appender. Returns None when disabled or
+ * misconfigured; never throws.
+ */
+object OtelInit extends LazyLogging {
+
+ /** Endpoint schemes we accept. OTLP-over-gRPC uses http/https endpoints;
+ * the exporter rejects a `grpc://` scheme outright, so it is not allowed.
+ */
+ private[observability] val AllowedSchemes: Set[String] = Set("http", "https")
+
+ /** Hosts we accept for the OTLP endpoint by default. */
+ private[observability] val DefaultAllowedHosts: Set[String] = Set(
+ "localhost",
+ "127.0.0.1",
+ "[::1]"
+ )
+
+ /** Default endpoint. 127.0.0.1 (not "localhost") to force IPv4 so a
+ * natively-run service reaches the collector on dual-stack hosts.
+ */
+ private val DefaultEndpoint = "http://127.0.0.1:4317"
+
+ /** Metric export interval bounds; out-of-range values fall back to the
+ * default (see clampIntervalMs).
+ */
+ private[observability] val MinMetricIntervalMs: Long = 1000L
+ private[observability] val MaxMetricIntervalMs: Long = 10L * 60L * 1000L
+ private[observability] val DefaultMetricIntervalMs: Long = 30L * 1000L
+
+ // Idempotency guard: init() is a no-op after the first call.
+ @volatile private var initialized: Option[OpenTelemetry] = None
+
+ /**
+ * Initialize the SDK for the given service name. Returns Some on
+ * success, None when disabled or misconfigured. When enabled, also
+ * attaches a [[TexeraOtelLogAppender]] to the Logback ROOT logger.
+ */
+ def init(serviceName: String): Option[OpenTelemetry] =
+ synchronized {
+ if (initialized.isDefined) return initialized
+
+ // Guard the whole body: reading observability.conf
(ObservabilityConfig's
+ // eager vals) and building the SDK are the fallible steps. A missing or
+ // malformed config would otherwise escape as
ExceptionInInitializerError,
+ // even when telemetry is disabled, breaking init()'s "never throws"
+ // contract. On any failure, disable telemetry with one WARN and return
None.
+ Try {
+ // Source the OTEL_* settings from observability.conf (HOCON defaults
+ // already merged with any env override); fall back to the raw
environment
+ // for anything else.
+ val env = (key: String) =>
+ key match {
+ case EnvironmentalVariable.ENV_OTEL_SDK_DISABLED =>
+ Some(ObservabilityConfig.sdkDisabled)
+ case EnvironmentalVariable.ENV_OTEL_EXPORTER_OTLP_ENDPOINT =>
+ Some(ObservabilityConfig.endpoint)
+ case EnvironmentalVariable.ENV_OTEL_RESOURCE_ATTRIBUTES =>
+ Some(ObservabilityConfig.resourceAttributes)
+ case EnvironmentalVariable.ENV_TEXERA_OTEL_ALLOWED_HOSTS =>
+ Some(ObservabilityConfig.allowedHosts)
+ case EnvironmentalVariable.ENV_OTEL_METRIC_EXPORT_INTERVAL =>
+ Some(ObservabilityConfig.metricExportIntervalMs)
+ case other => Option(System.getenv(other))
+ }
+ val result = initInternal(
+ serviceName = serviceName,
+ envProvider = env,
+ spanExporterFactory = buildOtlpSpanExporter,
+ logExporterFactory = endpoint =>
Some(buildOtlpLogExporter(endpoint)),
+ metricExporterFactory = endpoint =>
Some(buildOtlpMetricExporter(endpoint)),
+ logbackAttacher = LogbackBinder.attach
+ )
+ // Register globally so OTel-aware code can use GlobalOpenTelemetry
+ // without threading the SDK through callsites. set() throws on a
+ // second call; wrap defensively.
+ result.foreach { sdk =>
+ Try(GlobalOpenTelemetry.set(sdk)).failed.foreach { t =>
+ logger.warn(
+ s"GlobalOpenTelemetry already set; using the existing instance:
${t.getMessage}"
+ )
+ }
+ }
+ result
+ } match {
+ case Success(result) => result
+ case Failure(t) =>
+ logger.warn(
+ s"OpenTelemetry SDK initialization failed; continuing without
telemetry: ${t.getMessage}"
+ )
+ None
+ }
+ }
+
+ /**
+ * Test-only entry point: injects an env-var map and exporters so the
+ * SDK makes no network connection. Does not attach the Logback appender.
+ */
+ private[observability] def initForTest(
+ serviceName: String,
+ envOverride: Map[String, String],
+ exporter: SpanExporter,
+ metricExporter: Option[MetricExporter] = None
+ ): Option[OpenTelemetry] =
+ synchronized {
+ initInternal(
+ serviceName = serviceName,
+ envProvider = envOverride.get,
+ spanExporterFactory = _ => exporter,
+ logExporterFactory = _ => None,
+ metricExporterFactory = _ => metricExporter,
+ logbackAttacher = (_, _) => () // no-op in tests
+ )
+ }
+
+ /** Test-only: forget any previously-installed SDK. Does not unregister
+ * shutdown hooks (the previous SDK is closed instead).
+ */
+ private[observability] def resetForTest(): Unit =
+ synchronized {
+ initialized.foreach {
+ case sdk: OpenTelemetrySdk =>
+ Try(sdk.getSdkTracerProvider.close())
+ Try(sdk.getSdkLoggerProvider.close())
+ Try(sdk.getSdkMeterProvider.close())
+ case _ => ()
+ }
+ initialized = None
+ }
+
+ private def initInternal(
+ serviceName: String,
+ envProvider: String => Option[String],
+ spanExporterFactory: String => SpanExporter,
+ logExporterFactory: String => Option[LogRecordExporter],
+ metricExporterFactory: String => Option[MetricExporter],
+ logbackAttacher: (String, OpenTelemetry) => Unit
+ ): Option[OpenTelemetry] = {
+ if (initialized.isDefined) return initialized
+
+ // Disabled by default (issue #5367): stay inert unless OTEL_SDK_DISABLED
is
+ // explicitly false. An unreachable endpoint drops records without
crashing.
+ val disabled =
envProvider(EnvironmentalVariable.ENV_OTEL_SDK_DISABLED).getOrElse("true")
+ if (!disabled.equalsIgnoreCase("false")) {
+ logger.info(
+ "OpenTelemetry SDK disabled (OTEL_SDK_DISABLED not false). No
telemetry will be emitted."
+ )
+ return None
+ }
+
+ val endpoint =
+
envProvider(EnvironmentalVariable.ENV_OTEL_EXPORTER_OTLP_ENDPOINT).getOrElse(DefaultEndpoint)
+ val extraAllowed =
envProvider(EnvironmentalVariable.ENV_TEXERA_OTEL_ALLOWED_HOSTS)
+
.map(_.split(',').iterator.map(_.trim.toLowerCase).filter(_.nonEmpty).toSet)
+ .getOrElse(Set.empty)
+ val allowedHosts = DefaultAllowedHosts ++ extraAllowed
+
+ validateEndpoint(endpoint, allowedHosts) match {
+ case Left(reason) =>
+ // One WARN; no telemetry is emitted.
+ logger.warn(
+ s"OpenTelemetry SDK disabled: invalid OTEL_EXPORTER_OTLP_ENDPOINT,
$reason. " +
+ "Set TEXERA_OTEL_ALLOWED_HOSTS to extend the allowlist."
+ )
+ return None
+ case Right(_) => // ok
+ }
+
+ val rawAttrs =
envProvider(EnvironmentalVariable.ENV_OTEL_RESOURCE_ATTRIBUTES).getOrElse("")
+ val resource = buildResource(serviceName, rawAttrs)
+
+ val spanExporter = spanExporterFactory(endpoint)
+ val tracerProvider = SdkTracerProvider
+ .builder()
+ .setResource(resource)
+ .addSpanProcessor(BatchSpanProcessor.builder(spanExporter).build())
+ .build()
+
+ val sdkBuilder =
OpenTelemetrySdk.builder().setTracerProvider(tracerProvider)
+
+ // Logger provider is optional; the factory returns None in tests.
+ val loggerProviderOpt = logExporterFactory(endpoint).map { logExporter =>
+ val lp = SdkLoggerProvider
+ .builder()
+ .setResource(resource)
+
.addLogRecordProcessor(BatchLogRecordProcessor.builder(logExporter).build())
+ .build()
+ sdkBuilder.setLoggerProvider(lp)
+ lp
+ }
+
+ // Meter provider is optional too; interval falls back to the default
+ // when out of range.
+ val intervalMs =
+
clampIntervalMs(envProvider(EnvironmentalVariable.ENV_OTEL_METRIC_EXPORT_INTERVAL))
+ val meterProviderOpt = metricExporterFactory(endpoint).map {
metricExporter =>
+ val reader = PeriodicMetricReader
+ .builder(metricExporter)
+ .setInterval(Duration.ofMillis(intervalMs))
+ .build()
+ val mp = SdkMeterProvider
+ .builder()
+ .setResource(resource)
+ .registerMetricReader(reader)
+ .build()
+ sdkBuilder.setMeterProvider(mp)
+ mp
+ }
+
+ val sdk = sdkBuilder.build()
+
+ // One startup span carrying only service.name.
+ val span =
sdk.getTracer("texera.bootstrap").spanBuilder("service.start").startSpan()
+ Try(span.setAttribute("service.name", serviceName))
+ span.end()
+
+ // Wire the Logback appender; failure here must not crash the service.
+ Try(logbackAttacher(serviceName, sdk)).failed.foreach { t =>
+ logger.warn(s"Failed to attach OTel Logback appender (logs not
exported): ${t.getMessage}")
+ }
+
+ // Flush providers on shutdown. Added after the SDK is fully built.
+ Runtime.getRuntime.addShutdownHook(
+ new Thread(
+ () => {
+ Try(tracerProvider.close())
+ loggerProviderOpt.foreach(lp => Try(lp.close()))
+ meterProviderOpt.foreach(mp => Try(mp.close()))
+ ()
+ },
+ "otel-shutdown"
+ )
+ )
+
+ initialized = Some(sdk)
+ logger.info(s"OpenTelemetry SDK initialized for service '$serviceName'
(endpoint=$endpoint).")
+ initialized
+ }
+
+ /**
+ * Validate the endpoint is parseable and uses an allowlisted scheme
+ * and host. Pure function.
+ */
+ private[observability] def validateEndpoint(
+ endpoint: String,
+ allowedHosts: Set[String]
+ ): Either[String, Unit] = {
+ Try(URI.create(endpoint)) match {
+ case Failure(e) =>
+ Left(s"unparseable URI (${e.getClass.getSimpleName})")
+ case Success(uri) =>
+ val scheme = Option(uri.getScheme).map(_.toLowerCase).getOrElse("")
+ if (scheme.isEmpty) {
+ Left("missing scheme")
+ } else if (!AllowedSchemes.contains(scheme)) {
+ Left(
+ s"scheme '$scheme' not in allowlist
${AllowedSchemes.toSeq.sorted.mkString("{", ",", "}")}"
+ )
+ } else {
+ val host = Option(uri.getHost).map(_.toLowerCase).getOrElse("")
+ if (host.isEmpty) {
+ Left("missing host")
+ } else if (!allowedHosts.contains(host)) {
+ Left(s"host '$host' not in allowlist")
+ } else {
+ Right(())
+ }
+ }
+ }
+ }
+
+ /**
+ * Build a Resource from the service name and OTEL_RESOURCE_ATTRIBUTES.
+ * Every parsed attribute is applied so new resource fields need no edit
+ * here; the one exception is service.name, which the argument controls
+ * and env cannot override.
+ */
+ private[observability] def buildResource(serviceName: String, rawAttrs:
String): Resource = {
+ val builder = Attributes.builder()
+ builder.put(AttributeKey.stringKey("service.name"), serviceName)
+ // A per-process instance id so processes that share a service.name (every
+ // computing-unit JVM defaults to the same one) stay distinguishable in
+ // logs, metrics, and traces. OTEL_RESOURCE_ATTRIBUTES may override it
below.
+ builder.put(AttributeKey.stringKey("service.instance.id"),
java.util.UUID.randomUUID().toString)
+
+ parseAttrs(rawAttrs).foreach {
+ case (key, value) if key != "service.name" =>
+ builder.put(AttributeKey.stringKey(key), value)
+ case _ => // env cannot override service.name
+ }
+
+ Resource.create(builder.build())
+ }
+
+ /** Parse a `k1=v1,k2=v2` string. Malformed entries are skipped. */
+ private[observability] def parseAttrs(raw: String): Seq[(String, String)] = {
+ if (raw == null || raw.isEmpty) return Seq.empty
+ raw
+ .split(',')
+ .iterator
+ .map(_.trim)
+ .filter(_.nonEmpty)
+ .flatMap { entry =>
+ val idx = entry.indexOf('=')
+ if (idx <= 0 || idx == entry.length - 1) None
+ else Some(entry.substring(0, idx).trim -> entry.substring(idx +
1).trim)
+ }
+ .toSeq
+ }
+
+ private def buildOtlpSpanExporter(endpoint: String): SpanExporter =
+ OtlpGrpcSpanExporter.builder().setEndpoint(endpoint).build()
+
+ private def buildOtlpLogExporter(endpoint: String): LogRecordExporter =
+ OtlpGrpcLogRecordExporter.builder().setEndpoint(endpoint).build()
+
+ private def buildOtlpMetricExporter(endpoint: String): MetricExporter =
+ OtlpGrpcMetricExporter.builder().setEndpoint(endpoint).build()
+
+ /**
+ * Parse and clamp OTEL_METRIC_EXPORT_INTERVAL (ms). Out-of-range or
+ * unparseable input falls back to the default with one WARN.
+ */
+ private[observability] def clampIntervalMs(raw: Option[String]): Long = {
+ raw match {
+ case None => DefaultMetricIntervalMs
+ case Some(value) =>
+ Try(value.trim.toLong) match {
+ case Failure(_) =>
+ logger.warn(
+ s"OTEL_METRIC_EXPORT_INTERVAL '$value' is not a number; " +
+ s"using default ${DefaultMetricIntervalMs}ms."
+ )
+ DefaultMetricIntervalMs
+ case Success(ms) if ms < MinMetricIntervalMs || ms >
MaxMetricIntervalMs =>
+ logger.warn(
+ s"OTEL_METRIC_EXPORT_INTERVAL=${ms}ms out of range " +
+ s"[${MinMetricIntervalMs}, ${MaxMetricIntervalMs}]; " +
+ s"using default ${DefaultMetricIntervalMs}ms."
+ )
+ DefaultMetricIntervalMs
+ case Success(ms) => ms
+ }
+ }
+ }
+}
+
+/**
+ * Isolates the Logback attach step so [[OtelInit]] does not import
+ * Logback types directly, keeping SDK init testable with a mock attacher.
+ */
+private[observability] object LogbackBinder extends LazyLogging {
+
+ /** Attach a [[TexeraOtelLogAppender]] bound to `otel` to the Logback
+ * ROOT logger. Emits one WARN and returns if Logback is not the
+ * active SLF4J binding.
+ */
+ def attach(serviceName: String, otel: OpenTelemetry): Unit = {
+ val factory = org.slf4j.LoggerFactory.getILoggerFactory
+ factory match {
+ case ctx: ch.qos.logback.classic.LoggerContext =>
+ val root = ctx.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME)
+ val appender = new TexeraOtelLogAppender()
+ appender.setContext(ctx)
+ appender.setName(s"texera-otel-$serviceName")
+ appender.bind(otel)
+ appender.start()
+ root.addAppender(appender)
+ case other =>
+ logger.warn(
+ s"SLF4J binding is not Logback (${other.getClass.getName}); " +
+ "OTel log export is not wired. Application logs to stdout/file are
unaffected."
+ )
+ }
+ }
+}
diff --git
a/common/observability/src/main/scala/org/apache/texera/observability/TexeraOtelLogAppender.scala
b/common/observability/src/main/scala/org/apache/texera/observability/TexeraOtelLogAppender.scala
new file mode 100644
index 0000000000..276923b655
--- /dev/null
+++
b/common/observability/src/main/scala/org/apache/texera/observability/TexeraOtelLogAppender.scala
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.observability
+
+import ch.qos.logback.classic.Level
+import ch.qos.logback.classic.spi.{ILoggingEvent, IThrowableProxy,
ThrowableProxyUtil}
+import ch.qos.logback.core.UnsynchronizedAppenderBase
+import io.opentelemetry.api.OpenTelemetry
+import io.opentelemetry.api.common.AttributeKey
+import io.opentelemetry.api.logs.{Logger, Severity}
+import io.opentelemetry.api.trace.Span
+import io.opentelemetry.context.Context
+
+import java.util.concurrent.TimeUnit
+
+/**
+ * Logback appender that sanitizes each event via [[LogSanitizer]] and
+ * emits it as an OTel LogRecord. [[append]] is a no-op until [[bind]]
+ * is called and after [[stop]].
+ *
+ * This is internal plumbing, not the developer logging API. Code logs
+ * through the normal SLF4J / scala-logging interface and adds correlation
+ * ids via MDC; [[OtelInit.init]] attaches this appender to the ROOT logger
+ * so those records also reach OTel:
+ *
+ * {{{
+ * class Foo extends LazyLogging {
+ * MDC.put("workflowId", id) // forwarded as an OTel log attribute
+ * try logger.info("started") // body + severity + trace context
+ * finally MDC.remove("workflowId")
+ * }
+ * }}}
+ */
+class TexeraOtelLogAppender extends UnsynchronizedAppenderBase[ILoggingEvent] {
+
+ // @volatile so a late bind() is visible to appender threads.
+ @volatile private var otelLogger: Option[Logger] = None
+
+ def bind(otel: OpenTelemetry): Unit = {
+ otelLogger = Some(otel.getLogsBridge.get("texera.logback"))
+ }
+
+ override def stop(): Unit = {
+ otelLogger = None
+ super.stop()
+ }
+
+ override def append(event: ILoggingEvent): Unit = {
+ otelLogger match {
+ case None => () // not bound
+ case Some(_) if isSelfDiagnostic(event) =>
+ () // drop the exporter's own diagnostics to avoid a feedback loop
+ case Some(logger) =>
+ try {
+ emit(logger, event)
+ } catch {
+ // An appender must not throw into the calling thread.
+ case t: Throwable =>
+ addError("OTel log emission failed", t)
+ }
+ }
+ }
+
+ /** OTel's own components report export failures through JUL, which the
+ * jul-to-slf4j bridge routes to Logback ROOT and back into this appender.
+ * Re-exporting them to the collector that just failed would feed the
failure
+ * back on itself, so drop any record from an io.opentelemetry logger.
+ */
+ private def isSelfDiagnostic(event: ILoggingEvent): Boolean = {
+ val name = event.getLoggerName
+ name != null && name.startsWith("io.opentelemetry")
+ }
+
+ private def emit(logger: Logger, event: ILoggingEvent): Unit = {
+ // Control-strip the message only (trace newlines must survive), then
append
+ // the stack trace, redact secrets across the whole body, and cap length.
+ val message = LogSanitizer.stripControlChars(event.getFormattedMessage)
+ val combined = Option(event.getThrowableProxy) match {
+ case Some(proxy) => message + "\n" + formatThrowable(proxy)
+ case None => message
+ }
+ val body = LogSanitizer.truncate(LogSanitizer.redactSecrets(combined))
+ val builder = logger
+ .logRecordBuilder()
+ .setBody(body)
+ .setSeverity(severityFromLevel(event.getLevel))
+ .setSeverityText(event.getLevel.toString)
+ .setTimestamp(event.getTimeStamp, TimeUnit.MILLISECONDS)
+
+ // Surviving (deny-list filtered) MDC keys as typed attributes.
+ LogSanitizer.filterMdc(event.getMDCPropertyMap).foreach {
+ case (k, v) => builder.setAttribute(AttributeKey.stringKey(k), v)
+ }
+
+ builder.setAttribute(AttributeKey.stringKey("logger.name"),
event.getLoggerName)
+ builder.setAttribute(AttributeKey.stringKey("thread.name"),
event.getThreadName)
+
+ // Exception semantic-convention attributes so backends key error identity
+ // off exception.type / exception.message instead of parsing the body. The
+ // message and stack trace are redacted like the body.
+ Option(event.getThrowableProxy).foreach { proxy =>
+ builder.setAttribute(AttributeKey.stringKey("exception.type"),
proxy.getClassName)
+ builder.setAttribute(
+ AttributeKey.stringKey("exception.message"),
+ LogSanitizer.redactSecrets(proxy.getMessage)
+ )
+ builder.setAttribute(
+ AttributeKey.stringKey("exception.stacktrace"),
+
LogSanitizer.truncate(LogSanitizer.redactSecrets(formatThrowable(proxy)))
+ )
+ }
+
+ // Attach trace context so the SDK sets trace_id / span_id.
+ val span = Span.current()
+ if (span.getSpanContext.isValid) {
+ builder.setContext(Context.current())
+ }
+
+ builder.emit()
+ }
+
+ /** Format a throwable proxy as a Logback-style stack trace. */
+ private def formatThrowable(proxy: IThrowableProxy): String =
+ ThrowableProxyUtil.asString(proxy)
+
+ private def severityFromLevel(level: Level): Severity = {
+ if (level == null) return Severity.UNDEFINED_SEVERITY_NUMBER
+ level.toInt match {
+ case Level.TRACE_INT => Severity.TRACE
+ case Level.DEBUG_INT => Severity.DEBUG
+ case Level.INFO_INT => Severity.INFO
+ case Level.WARN_INT => Severity.WARN
+ case Level.ERROR_INT => Severity.ERROR
+ case _ => Severity.UNDEFINED_SEVERITY_NUMBER
+ }
+ }
+}
diff --git
a/common/observability/src/test/scala/org/apache/texera/observability/LogSanitizerSpec.scala
b/common/observability/src/test/scala/org/apache/texera/observability/LogSanitizerSpec.scala
new file mode 100644
index 0000000000..cade55e99a
--- /dev/null
+++
b/common/observability/src/test/scala/org/apache/texera/observability/LogSanitizerSpec.scala
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.observability
+
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+import scala.jdk.CollectionConverters._
+
+class LogSanitizerSpec extends AnyFlatSpec with Matchers {
+
+ // ----- sanitize: control characters ----------------------------------
+
+ "sanitize" should "strip CR/LF so a user-supplied message cannot forge a new
log line" in {
+ val crlfPayload = "hello\r\nFAKE LOG LINE\r\nworld"
+ LogSanitizer.sanitize(crlfPayload) shouldBe "helloFAKE LOG LINEworld"
+ }
+
+ it should "strip other C0 control characters but preserve TAB" in {
+ val payload = "before\u0000NUL\u0007BEL\tTAB\u001bafter\u007fdel"
+ LogSanitizer.sanitize(payload) shouldBe "beforeNULBEL\tTABafterdel"
+ }
+
+ it should "handle empty / null bodies cleanly" in {
+ LogSanitizer.sanitize("") shouldBe ""
+ LogSanitizer.sanitize(null) shouldBe ""
+ }
+
+ // ----- sanitize: secret scrubbing ------------------------------------
+
+ it should "redact Bearer tokens regardless of case" in {
+ LogSanitizer.sanitize("Authorization: Bearer abc123XYZ.foo") should
include("[REDACTED]")
+ LogSanitizer.sanitize("Authorization: Bearer abc123XYZ.foo") should not
include "abc123XYZ"
+ LogSanitizer.sanitize("auth = bearer eyJhbGci.tok") should
include("[REDACTED]")
+ }
+
+ it should "redact password=... key/value forms" in {
+ val out = LogSanitizer.sanitize("connecting: user=alice password=hunter2
host=db")
+ out should include("[REDACTED]")
+ out should not include "hunter2"
+ // surrounding context preserved
+ out should include("user=alice")
+ out should include("host=db")
+ }
+
+ it should "redact AWS access key IDs" in {
+ val out = LogSanitizer.sanitize("found key AKIAIOSFODNN7EXAMPLE in env")
+ out should include("[REDACTED]")
+ out should not include "AKIAIOSFODNN7EXAMPLE"
+ }
+
+ it should "redact AWS secret access keys when explicitly labelled" in {
+ val out = LogSanitizer.sanitize(
+ "aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY some
text"
+ )
+ out should include("[REDACTED]")
+ out should not include "wJalrXUtnFEMI"
+ }
+
+ it should "leave already-redacted content alone (idempotent)" in {
+ val once = LogSanitizer.sanitize("Authorization: Bearer abc12345.deadbeef")
+ val twice = LogSanitizer.sanitize(once)
+ twice shouldBe once
+ }
+
+ // ----- sanitize: size cap --------------------------------------------
+
+ it should "truncate bodies larger than MaxBodyChars and append the marker"
in {
+ val oversize = "a" * (LogSanitizer.MaxBodyChars * 4) // ~64 KiB
+ val out = LogSanitizer.sanitize(oversize)
+ out.length shouldBe LogSanitizer.MaxBodyChars
+ out should endWith(LogSanitizer.TruncatedMarker)
+ }
+
+ it should "leave bodies at or below the cap unchanged in length" in {
+ val rightAtCap = "x" * LogSanitizer.MaxBodyChars
+ LogSanitizer.sanitize(rightAtCap).length shouldBe LogSanitizer.MaxBodyChars
+ }
+
+ // ----- filterMdc -----------------------------------------------------
+
+ "filterMdc" should "drop denied Pekko keys and pass every other key through"
in {
+ val mdc = Map(
+ "trace_id" -> "abc",
+ "span_id" -> "def",
+ "texera.workflow.id" -> "42",
+ "app.new.tag" -> "kept",
+ "sourceThread" -> "dispatcher-3",
+ "pekkoSource" -> "akka://sys/user/actor"
+ ).asJava
+ val out = LogSanitizer.filterMdc(mdc)
+ out.keySet shouldBe Set("trace_id", "span_id", "texera.workflow.id",
"app.new.tag")
+ }
+
+ it should "scrub secret-shaped values on keys that pass through" in {
+ val mdc = Map("note" -> "password=p4ssw0rd").asJava
+ LogSanitizer.filterMdc(mdc)("note") should not include "p4ssw0rd"
+ }
+
+ it should "redact the value of a credential-named key even when the value
itself is benign" in {
+ val mdc = Map(
+ "password" -> "hunter2",
+ "user.api_key" -> "abcdef",
+ "authToken" -> "xyz",
+ "trace_id" -> "keep-me"
+ ).asJava
+ val out = LogSanitizer.filterMdc(mdc)
+ out("password") shouldBe "[REDACTED]"
+ out("user.api_key") shouldBe "[REDACTED]"
+ out("authToken") shouldBe "[REDACTED]"
+ out("trace_id") shouldBe "keep-me"
+ }
+
+ it should "tolerate null map and null values" in {
+ LogSanitizer.filterMdc(null) shouldBe empty
+
+ val javaMap = new java.util.HashMap[String, String]()
+ javaMap.put("trace_id", null)
+ javaMap.put("texera.user.id", "7")
+ val out = LogSanitizer.filterMdc(javaMap)
+ out shouldBe Map("texera.user.id" -> "7")
+ }
+}
diff --git
a/common/observability/src/test/scala/org/apache/texera/observability/OtelInitSpec.scala
b/common/observability/src/test/scala/org/apache/texera/observability/OtelInitSpec.scala
new file mode 100644
index 0000000000..e58fe75d3c
--- /dev/null
+++
b/common/observability/src/test/scala/org/apache/texera/observability/OtelInitSpec.scala
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.observability
+
+import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter
+import org.scalatest.BeforeAndAfterEach
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+import scala.jdk.CollectionConverters._
+
+class OtelInitSpec extends AnyFlatSpec with Matchers with BeforeAndAfterEach {
+
+ override def beforeEach(): Unit = {
+ OtelInit.resetForTest()
+ }
+
+ override def afterEach(): Unit = {
+ OtelInit.resetForTest()
+ }
+
+ // ----- validateEndpoint: pure function, exhaustive cases -------------
+
+ "validateEndpoint" should "accept loopback OTLP http(s) URLs" in {
+ OtelInit.validateEndpoint("http://localhost:4317",
OtelInit.DefaultAllowedHosts) shouldBe Right(
+ ()
+ )
+ OtelInit.validateEndpoint("http://127.0.0.1:4317",
OtelInit.DefaultAllowedHosts) shouldBe Right(
+ ()
+ )
+ OtelInit.validateEndpoint(
+ "https://localhost:4318",
+ OtelInit.DefaultAllowedHosts
+ ) shouldBe Right(())
+ }
+
+ it should "reject a grpc:// endpoint (the OTLP exporter accepts only
http/https)" in {
+ val result = OtelInit.validateEndpoint("grpc://127.0.0.1:4317",
OtelInit.DefaultAllowedHosts)
+ result.isLeft shouldBe true
+ result.left.toOption.get should include("scheme")
+ }
+
+ it should "reject file:// schemes (path traversal style attack)" in {
+ val result = OtelInit.validateEndpoint("file:///etc/passwd",
OtelInit.DefaultAllowedHosts)
+ result.isLeft shouldBe true
+ result.left.toOption.get should include("scheme")
+ }
+
+ it should "reject arbitrary remote hosts not in the allowlist" in {
+ val result = OtelInit.validateEndpoint(
+ "http://attacker.example.com:4317",
+ OtelInit.DefaultAllowedHosts
+ )
+ result.isLeft shouldBe true
+ result.left.toOption.get should include("host")
+ }
+
+ it should "accept hosts added to the allowlist" in {
+ val widened = OtelInit.DefaultAllowedHosts + "collector.internal"
+ OtelInit.validateEndpoint("http://collector.internal:4317", widened)
shouldBe Right(())
+ }
+
+ it should "reject endpoints with no scheme" in {
+ val result = OtelInit.validateEndpoint("localhost:4317",
OtelInit.DefaultAllowedHosts)
+ result.isLeft shouldBe true
+ }
+
+ it should "reject endpoints with no host" in {
+ val result = OtelInit.validateEndpoint("http:///path",
OtelInit.DefaultAllowedHosts)
+ result.isLeft shouldBe true
+ }
+
+ it should "reject completely malformed input" in {
+ val result = OtelInit.validateEndpoint("not a uri at all :: bad",
OtelInit.DefaultAllowedHosts)
+ result.isLeft shouldBe true
+ }
+
+ // ----- buildResource: passthrough with service.name protected ---------
+
+ "buildResource" should "always include the service.name from the argument"
in {
+ val r = OtelInit.buildResource("my-service", "")
+ Option(
+
r.getAttribute(io.opentelemetry.api.common.AttributeKey.stringKey("service.name"))
+ ) shouldBe Some(
+ "my-service"
+ )
+ }
+
+ it should "honor keys from OTEL_RESOURCE_ATTRIBUTES" in {
+ val r = OtelInit.buildResource("svc",
"service.version=1.2.3,deployment.environment=staging")
+ Option(
+
r.getAttribute(io.opentelemetry.api.common.AttributeKey.stringKey("service.version"))
+ ) shouldBe Some(
+ "1.2.3"
+ )
+ Option(
+
r.getAttribute(io.opentelemetry.api.common.AttributeKey.stringKey("deployment.environment"))
+ ) shouldBe Some("staging")
+ }
+
+ it should "pass custom keys through so new resource fields need no code
edit" in {
+ val r = OtelInit.buildResource(
+ "svc",
+ "service.version=1.0,custom.tag=team-a,texera.region.id=us-west"
+ )
+ val attrs: Map[String, String] =
r.getAttributes.asMap.asScala.iterator.map {
+ case (k, v) => k.getKey -> v.toString
+ }.toMap
+
+ attrs("service.version") shouldBe "1.0"
+ attrs("custom.tag") shouldBe "team-a"
+ attrs("texera.region.id") shouldBe "us-west"
+ }
+
+ it should "refuse to let OTEL_RESOURCE_ATTRIBUTES override service.name" in {
+ val r = OtelInit.buildResource("real-svc", "service.name=spoofed")
+ Option(
+
r.getAttribute(io.opentelemetry.api.common.AttributeKey.stringKey("service.name"))
+ ) shouldBe Some(
+ "real-svc"
+ )
+ }
+
+ it should "default a distinct service.instance.id per process so same-named
processes stay apart" in {
+ val key =
io.opentelemetry.api.common.AttributeKey.stringKey("service.instance.id")
+ val id1 = OtelInit.buildResource("computing-unit-master",
"").getAttribute(key)
+ val id2 = OtelInit.buildResource("computing-unit-master",
"").getAttribute(key)
+ id1 should not be null
+ id1 should not be id2
+ }
+
+ it should "let OTEL_RESOURCE_ATTRIBUTES override service.instance.id" in {
+ val r = OtelInit.buildResource("svc", "service.instance.id=cu-7")
+ Option(
+
r.getAttribute(io.opentelemetry.api.common.AttributeKey.stringKey("service.instance.id"))
+ ) shouldBe Some("cu-7")
+ }
+
+ it should "carry the texera.* resource attrs so a CU JVM auto-tags every
emitted record" in {
+ val r = OtelInit.buildResource(
+ "texera-computing-unit-master",
+
"texera.computing_unit.id=8,texera.workflow.id=441,texera.execution.id=1234"
+ )
+ val attrs: Map[String, String] =
r.getAttributes.asMap.asScala.iterator.map {
+ case (k, v) => k.getKey -> v.toString
+ }.toMap
+ attrs("texera.computing_unit.id") shouldBe "8"
+ attrs("texera.workflow.id") shouldBe "441"
+ attrs("texera.execution.id") shouldBe "1234"
+ }
+
+ it should "ignore malformed pairs without crashing" in {
+ val r = OtelInit.buildResource("svc",
",,,=,foo,service.version=,=bar,service.version=1.0,")
+ Option(
+
r.getAttribute(io.opentelemetry.api.common.AttributeKey.stringKey("service.version"))
+ ) shouldBe Some(
+ "1.0"
+ )
+ }
+
+ it should "handle empty / null input cleanly" in {
+ OtelInit.parseAttrs("") shouldBe empty
+ OtelInit.parseAttrs(null) shouldBe empty
+ }
+
+ // ----- end-to-end init: span emission + disable behaviour -------------
+
+ "init" should "be a no-op when OTEL_SDK_DISABLED is explicitly set to true"
in {
+ val exporter = InMemorySpanExporter.create()
+ val result = OtelInit.initForTest("svc", Map("OTEL_SDK_DISABLED" ->
"true"), exporter)
+ result shouldBe None
+ exporter.getFinishedSpanItems.asScala shouldBe empty
+ }
+
+ it should "stay inert by default when OTEL_SDK_DISABLED is unset (issue
#5367)" in {
+ val exporter = InMemorySpanExporter.create()
+ val result = OtelInit.initForTest(
+ "svc",
+ Map(
+ // OTEL_SDK_DISABLED omitted; the SDK stays disabled by default.
+ "OTEL_EXPORTER_OTLP_ENDPOINT" -> "http://localhost:4317"
+ ),
+ exporter
+ )
+ result shouldBe None
+ exporter.getFinishedSpanItems.asScala shouldBe empty
+ }
+
+ it should "stay inert for any OTEL_SDK_DISABLED value other than an explicit
false" in {
+ val exporter = InMemorySpanExporter.create()
+ val result = OtelInit.initForTest(
+ "svc",
+ Map("OTEL_SDK_DISABLED" -> "", "OTEL_EXPORTER_OTLP_ENDPOINT" ->
"http://localhost:4317"),
+ exporter
+ )
+ result shouldBe None
+ }
+
+ it should "emit a single service.start span when enabled with a valid
endpoint" in {
+ val exporter = InMemorySpanExporter.create()
+ val result = OtelInit.initForTest(
+ "my-service",
+ Map(
+ "OTEL_SDK_DISABLED" -> "false",
+ "OTEL_EXPORTER_OTLP_ENDPOINT" -> "http://localhost:4317"
+ ),
+ exporter
+ )
+ result.isDefined shouldBe true
+
+ // BatchSpanProcessor is async; flush before reading.
+ result.get
+ .asInstanceOf[io.opentelemetry.sdk.OpenTelemetrySdk]
+ .getSdkTracerProvider
+ .forceFlush()
+ .join(2, java.util.concurrent.TimeUnit.SECONDS)
+
+ val spans = exporter.getFinishedSpanItems.asScala
+ spans should have size 1
+ spans.head.getName shouldBe "service.start"
+ }
+
+ it should "refuse to initialize when the endpoint scheme is file://" in {
+ val exporter = InMemorySpanExporter.create()
+ val result = OtelInit.initForTest(
+ "svc",
+ Map(
+ "OTEL_SDK_DISABLED" -> "false",
+ "OTEL_EXPORTER_OTLP_ENDPOINT" -> "file:///etc/passwd"
+ ),
+ exporter
+ )
+ result shouldBe None
+ exporter.getFinishedSpanItems.asScala shouldBe empty
+ }
+
+ it should "refuse to initialize when the endpoint host is off-allowlist" in {
+ val exporter = InMemorySpanExporter.create()
+ val result = OtelInit.initForTest(
+ "svc",
+ Map(
+ "OTEL_SDK_DISABLED" -> "false",
+ "OTEL_EXPORTER_OTLP_ENDPOINT" -> "http://attacker.example.com:4317"
+ ),
+ exporter
+ )
+ result shouldBe None
+ exporter.getFinishedSpanItems.asScala shouldBe empty
+ }
+
+ it should "be idempotent — second init returns the same instance" in {
+ val exporter = InMemorySpanExporter.create()
+ val env = Map(
+ "OTEL_SDK_DISABLED" -> "false",
+ "OTEL_EXPORTER_OTLP_ENDPOINT" -> "http://localhost:4317"
+ )
+ val first = OtelInit.initForTest("svc", env, exporter)
+ val second = OtelInit.initForTest("svc", env, exporter)
+ second shouldBe first
+ }
+
+ // ----- clampIntervalMs: parse + range fallback ------------------------
+
+ "clampIntervalMs" should "fall back to the default when the value is absent"
in {
+ OtelInit.clampIntervalMs(None) shouldBe OtelInit.DefaultMetricIntervalMs
+ }
+
+ it should "fall back to the default when the value is not a number" in {
+ OtelInit.clampIntervalMs(Some("not-a-number")) shouldBe
OtelInit.DefaultMetricIntervalMs
+ }
+
+ it should "fall back to the default when the value is below the minimum" in {
+ OtelInit.clampIntervalMs(Some((OtelInit.MinMetricIntervalMs -
1).toString)) shouldBe
+ OtelInit.DefaultMetricIntervalMs
+ }
+
+ it should "fall back to the default when the value is above the maximum" in {
+ OtelInit.clampIntervalMs(Some((OtelInit.MaxMetricIntervalMs +
1).toString)) shouldBe
+ OtelInit.DefaultMetricIntervalMs
+ }
+
+ it should "keep an in-range value" in {
+ val inRange = OtelInit.MinMetricIntervalMs + 1234
+ OtelInit.clampIntervalMs(Some(inRange.toString)) shouldBe inRange
+ }
+
+ it should "accept the range boundaries" in {
+ OtelInit.clampIntervalMs(Some(OtelInit.MinMetricIntervalMs.toString))
shouldBe
+ OtelInit.MinMetricIntervalMs
+ OtelInit.clampIntervalMs(Some(OtelInit.MaxMetricIntervalMs.toString))
shouldBe
+ OtelInit.MaxMetricIntervalMs
+ }
+}
diff --git
a/common/observability/src/test/scala/org/apache/texera/observability/TexeraOtelLogAppenderSpec.scala
b/common/observability/src/test/scala/org/apache/texera/observability/TexeraOtelLogAppenderSpec.scala
new file mode 100644
index 0000000000..27b6a7ce2c
--- /dev/null
+++
b/common/observability/src/test/scala/org/apache/texera/observability/TexeraOtelLogAppenderSpec.scala
@@ -0,0 +1,243 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.observability
+
+import ch.qos.logback.classic.{Level, Logger, LoggerContext}
+import ch.qos.logback.classic.spi.LoggingEvent
+import io.opentelemetry.api.OpenTelemetry
+import io.opentelemetry.api.logs.Severity
+import io.opentelemetry.sdk.OpenTelemetrySdk
+import io.opentelemetry.sdk.logs.SdkLoggerProvider
+import io.opentelemetry.sdk.logs.`export`.SimpleLogRecordProcessor
+import io.opentelemetry.sdk.testing.exporter.InMemoryLogRecordExporter
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+import org.slf4j.LoggerFactory
+
+import scala.jdk.CollectionConverters._
+
+class TexeraOtelLogAppenderSpec extends AnyFlatSpec with Matchers {
+
+ /** Build an OpenTelemetry SDK whose LoggerProvider drains to the
+ * given in-memory exporter via the synchronous SimpleLogRecordProcessor,
+ * so tests don't depend on batch timing.
+ */
+ private def newFixture(): (OpenTelemetry, InMemoryLogRecordExporter,
TexeraOtelLogAppender) = {
+ val exporter = InMemoryLogRecordExporter.create()
+ val lp = SdkLoggerProvider
+ .builder()
+ .addLogRecordProcessor(SimpleLogRecordProcessor.create(exporter))
+ .build()
+ val sdk = OpenTelemetrySdk.builder().setLoggerProvider(lp).build()
+ val appender = new TexeraOtelLogAppender()
+
appender.setContext(LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext])
+ appender.bind(sdk)
+ appender.start()
+ (sdk, exporter, appender)
+ }
+
+ private def makeEvent(
+ message: String,
+ level: Level = Level.INFO,
+ mdc: Map[String, String] = Map.empty
+ ): LoggingEvent = {
+ val ctx = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
+ val logger = ctx.getLogger("test.logger").asInstanceOf[Logger]
+ val ev = new LoggingEvent("fqcn", logger, level, message, null, null)
+ if (mdc.nonEmpty) ev.setMDCPropertyMap(mdc.asJava)
+ ev
+ }
+
+ // ----- positive paths -------------------------------------------------
+
+ "TexeraOtelLogAppender" should "emit an INFO record with body + severity" in
{
+ val (_, exporter, appender) = newFixture()
+ appender.doAppend(makeEvent("hello world"))
+
+ val records = exporter.getFinishedLogRecordItems.asScala
+ records should have size 1
+ records.head.getBodyValue.asString shouldBe "hello world"
+ records.head.getSeverity shouldBe Severity.INFO
+ records.head.getSeverityText shouldBe "INFO"
+ }
+
+ it should "map every log level to a distinct OTel severity" in {
+ val (_, exporter, appender) = newFixture()
+ Seq(Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR).foreach
{ lvl =>
+ appender.doAppend(makeEvent(s"msg-$lvl", lvl))
+ }
+ val severities =
exporter.getFinishedLogRecordItems.asScala.map(_.getSeverity).toSet
+ severities shouldBe Set(
+ Severity.TRACE,
+ Severity.DEBUG,
+ Severity.INFO,
+ Severity.WARN,
+ Severity.ERROR
+ )
+ }
+
+ // ----- security: sanitisation happens at the boundary -----------------
+
+ it should "strip CRLF from a forged log-injection payload before emission"
in {
+ val (_, exporter, appender) = newFixture()
+ appender.doAppend(makeEvent("hello\r\nFAKE LOG LINE\r\nworld"))
+
+ val body =
exporter.getFinishedLogRecordItems.asScala.head.getBodyValue.asString
+ body shouldBe "helloFAKE LOG LINEworld"
+ body should not include "\n"
+ body should not include "\r"
+ }
+
+ it should "redact Bearer tokens at emission time" in {
+ val (_, exporter, appender) = newFixture()
+ appender.doAppend(makeEvent("Authorization: Bearer abc123XYZ.foo"))
+
+ val body =
exporter.getFinishedLogRecordItems.asScala.head.getBodyValue.asString
+ body should include("[REDACTED]")
+ body should not include "abc123XYZ"
+ }
+
+ it should "redact secrets inside an attached stack trace, not just the
message" in {
+ val (_, exporter, appender) = newFixture()
+ val ctx = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
+ val logger = ctx.getLogger("test.logger").asInstanceOf[Logger]
+ val boom = new RuntimeException("db connect failed for password=hunter2")
+ val ev = new LoggingEvent("fqcn", logger, Level.ERROR, "operation failed",
boom, null)
+ appender.doAppend(ev)
+
+ val body =
exporter.getFinishedLogRecordItems.asScala.head.getBodyValue.asString
+ body should include("[REDACTED]")
+ body should not include "hunter2"
+ // The stack trace's newlines are preserved (only the message is
C0-stripped).
+ body should include("\n")
+ }
+
+ it should "truncate a 1 MiB body to MaxBodyChars with the marker" in {
+ val (_, exporter, appender) = newFixture()
+ val oversize = "x" * (1024 * 1024)
+ appender.doAppend(makeEvent(oversize))
+
+ val body =
exporter.getFinishedLogRecordItems.asScala.head.getBodyValue.asString
+ body.length shouldBe LogSanitizer.MaxBodyChars
+ body should endWith(LogSanitizer.TruncatedMarker)
+ }
+
+ // ----- security: MDC deny-list ----------------------------------------
+
+ private def attrsOf(record: io.opentelemetry.sdk.logs.data.LogRecordData):
Map[String, String] =
+ record.getAttributes.asMap.asScala.iterator.map { case (k, v) => k.getKey
-> v.toString }.toMap
+
+ it should "forward arbitrary correlation MDC keys (deny-list, not
allow-list)" in {
+ val (_, exporter, appender) = newFixture()
+ appender.doAppend(
+ makeEvent(
+ "msg",
+ mdc = Map(
+ "trace_id" -> "abc",
+ "texera.workflow.id" -> "42",
+ "some.new.key" -> "kept"
+ )
+ )
+ )
+
+ val attrs = attrsOf(exporter.getFinishedLogRecordItems.asScala.head)
+ attrs.keySet should contain allOf ("trace_id", "texera.workflow.id",
"some.new.key")
+ attrs("some.new.key") shouldBe "kept"
+ }
+
+ it should "drop the noisy Pekko bridge MDC keys" in {
+ val (_, exporter, appender) = newFixture()
+ val denied = LogSanitizer.DeniedMdcKeys.iterator.map(_ -> "noise").toMap
+ appender.doAppend(makeEvent("msg", mdc = denied + ("trace_id" -> "abc")))
+
+ val attrs = attrsOf(exporter.getFinishedLogRecordItems.asScala.head)
+ attrs.keySet should contain("trace_id")
+ attrs.keySet should contain noElementsOf LogSanitizer.DeniedMdcKeys
+ }
+
+ it should "redact a secret-shaped MDC value while keeping its key" in {
+ val (_, exporter, appender) = newFixture()
+ appender.doAppend(makeEvent("msg", mdc = Map("authz" -> "Bearer
abc123XYZ.foo")))
+
+ val attrs = attrsOf(exporter.getFinishedLogRecordItems.asScala.head)
+ attrs.keySet should contain("authz")
+ attrs("authz") should include("[REDACTED]")
+ attrs("authz") should not include "abc123XYZ"
+ }
+
+ it should "redact the value of a credential-named MDC key even when the
value looks benign" in {
+ val (_, exporter, appender) = newFixture()
+ appender.doAppend(makeEvent("msg", mdc = Map("password" -> "p4ssw0rd",
"api_key" -> "plain")))
+
+ val attrs = attrsOf(exporter.getFinishedLogRecordItems.asScala.head)
+ attrs("password") shouldBe "[REDACTED]"
+ attrs("api_key") shouldBe "[REDACTED]"
+ attrs.values should contain noElementsOf Seq("p4ssw0rd", "plain")
+ }
+
+ // ----- exception attributes + self-diagnostic guard -------------------
+
+ it should "set exception.* semantic attributes with the message and trace
redacted" in {
+ val (_, exporter, appender) = newFixture()
+ val ctx = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
+ val logger = ctx.getLogger("test.logger").asInstanceOf[Logger]
+ val boom = new IllegalStateException("connect failed for password=hunter2")
+ val ev = new LoggingEvent("fqcn", logger, Level.ERROR, "operation failed",
boom, null)
+ appender.doAppend(ev)
+
+ val attrs = attrsOf(exporter.getFinishedLogRecordItems.asScala.head)
+ attrs("exception.type") shouldBe "java.lang.IllegalStateException"
+ attrs("exception.message") should include("[REDACTED]")
+ attrs("exception.message") should not include "hunter2"
+ attrs.keySet should contain("exception.stacktrace")
+ attrs("exception.stacktrace") should not include "hunter2"
+ }
+
+ it should "drop records from io.opentelemetry loggers to avoid a feedback
loop" in {
+ val (_, exporter, appender) = newFixture()
+ val ctx = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
+ val otelLogger =
+
ctx.getLogger("io.opentelemetry.exporter.internal.grpc.GrpcExporter").asInstanceOf[Logger]
+ val ev = new LoggingEvent("fqcn", otelLogger, Level.WARN, "Failed to
export spans", null, null)
+ appender.doAppend(ev)
+
+ exporter.getFinishedLogRecordItems.asScala shouldBe empty
+ }
+
+ // ----- lifecycle ------------------------------------------------------
+
+ it should "be a silent no-op when not yet bound to an OpenTelemetry
instance" in {
+ val unbound = new TexeraOtelLogAppender()
+
unbound.setContext(LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext])
+ unbound.start()
+ // Should not throw, even though no SDK is wired.
+ noException should be thrownBy unbound.doAppend(makeEvent("hello"))
+ }
+
+ it should "stop emitting after stop() is called" in {
+ val (_, exporter, appender) = newFixture()
+ appender.doAppend(makeEvent("first"))
+ appender.stop()
+ appender.doAppend(makeEvent("second"))
+
+ val bodies =
exporter.getFinishedLogRecordItems.asScala.map(_.getBodyValue.asString)
+ bodies should contain only "first"
+ }
+}
diff --git a/computing-unit-managing-service/LICENSE-binary
b/computing-unit-managing-service/LICENSE-binary
index 0b8e4c1286..bf057b8c40 100644
--- a/computing-unit-managing-service/LICENSE-binary
+++ b/computing-unit-managing-service/LICENSE-binary
@@ -369,6 +369,18 @@ Scala/Java jars:
- io.netty.netty-transport-native-epoll-4.2.15.Final.jar
- io.netty.netty-transport-native-unix-common-4.2.15.Final.jar
- org.jspecify.jspecify-1.0.0.jar
+ - io.opentelemetry.opentelemetry-api-1.50.0.jar
+ - io.opentelemetry.opentelemetry-context-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-sender-okhttp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-extension-autoconfigure-spi-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-logs-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-metrics-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-trace-1.50.0.jar
- io.perfmark.perfmark-api-0.27.0.jar
- io.r2dbc.r2dbc-spi-1.0.0.RELEASE.jar
- io.swagger.swagger-annotations-1.6.14.jar
diff --git
a/computing-unit-managing-service/src/main/resources/computing-unit-managing-service-config.yaml
b/computing-unit-managing-service/src/main/resources/computing-unit-managing-service-config.yaml
index 523b419798..ea428fcadc 100644
---
a/computing-unit-managing-service/src/main/resources/computing-unit-managing-service-config.yaml
+++
b/computing-unit-managing-service/src/main/resources/computing-unit-managing-service-config.yaml
@@ -30,4 +30,16 @@ server:
logging:
level: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
loggers:
- "com.example": ${TEXERA_SERVICE_LOG_LEVEL:-DEBUG}
\ No newline at end of file
+ "com.example": ${TEXERA_SERVICE_LOG_LEVEL:-DEBUG}
+ # Cap noisy frameworks at WARN so TRACE/DEBUG surfaces Texera code
+ # (org.apache.texera) without the framework firehose.
+ "org.apache.pekko": WARN
+ "org.apache.iceberg": WARN
+ "org.apache.hadoop": WARN
+ "org.apache.kafka": WARN
+ "org.eclipse.jetty": WARN
+ "org.glassfish.jersey": WARN
+ "io.grpc": WARN
+ "io.netty": WARN
+ "com.zaxxer.hikari": WARN
+ "software.amazon.awssdk": WARN
\ No newline at end of file
diff --git
a/computing-unit-managing-service/src/main/scala/org/apache/texera/service/ComputingUnitManagingService.scala
b/computing-unit-managing-service/src/main/scala/org/apache/texera/service/ComputingUnitManagingService.scala
index 785c719fe3..0d36a99bcb 100644
---
a/computing-unit-managing-service/src/main/scala/org/apache/texera/service/ComputingUnitManagingService.scala
+++
b/computing-unit-managing-service/src/main/scala/org/apache/texera/service/ComputingUnitManagingService.scala
@@ -90,6 +90,8 @@ class ComputingUnitManagingService extends
Application[ComputingUnitManagingServ
configuration: ComputingUnitManagingServiceConfiguration,
environment: Environment
): Unit = {
+ // Bridge this service's logs to the OTel collector under its own
service.name.
+
org.apache.texera.observability.OtelInit.init("computing-unit-managing-service")
// Register http resources
environment.jersey.setUrlPattern("/api/*")
environment.jersey.register(classOf[HealthCheckResource])
diff --git a/config-service/LICENSE-binary b/config-service/LICENSE-binary
index 93348da932..5f93f2b678 100644
--- a/config-service/LICENSE-binary
+++ b/config-service/LICENSE-binary
@@ -242,6 +242,9 @@ Scala/Java jars:
-
com.google.guava.listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
- com.google.j2objc.j2objc-annotations-2.8.jar
- com.helger.profiler-1.1.1.jar
+ - com.squareup.okhttp3.okhttp-4.12.0.jar
+ - com.squareup.okio.okio-3.6.0.jar
+ - com.squareup.okio.okio-jvm-3.6.0.jar
- com.thesamet.scalapb.lenses_2.13-0.11.20.jar
- com.thesamet.scalapb.scalapb-json4s_2.13-0.12.0.jar
- com.thesamet.scalapb.scalapb-runtime_2.13-0.11.20.jar
@@ -274,6 +277,18 @@ Scala/Java jars:
- io.dropwizard.metrics.metrics-json-4.2.25.jar
- io.dropwizard.metrics.metrics-jvm-4.2.25.jar
- io.dropwizard.metrics.metrics-logback-4.2.25.jar
+ - io.opentelemetry.opentelemetry-api-1.50.0.jar
+ - io.opentelemetry.opentelemetry-context-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-sender-okhttp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-extension-autoconfigure-spi-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-logs-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-metrics-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-trace-1.50.0.jar
- io.r2dbc.r2dbc-spi-1.0.0.RELEASE.jar
- jakarta.inject.jakarta.inject-api-2.0.1.jar
- jakarta.validation.jakarta.validation-api-3.0.2.jar
@@ -292,6 +307,11 @@ Scala/Java jars:
- org.hibernate.validator.hibernate-validator-7.0.5.Final.jar
- org.javassist.javassist-3.30.2-GA.jar
- org.jboss.logging.jboss-logging-3.5.3.Final.jar
+ - org.jetbrains.annotations-13.0.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-1.9.10.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-common-1.9.10.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-jdk7-1.9.10.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-jdk8-1.9.10.jar
- org.jooq.jooq-3.19.36.jar
- org.json4s.json4s-ast_2.13-4.0.1.jar
- org.json4s.json4s-jackson-core_2.13-4.0.1.jar
diff --git a/config-service/src/main/resources/config-service-web-config.yaml
b/config-service/src/main/resources/config-service-web-config.yaml
index 4aa67af82e..8559e1fd50 100644
--- a/config-service/src/main/resources/config-service-web-config.yaml
+++ b/config-service/src/main/resources/config-service-web-config.yaml
@@ -26,6 +26,19 @@ server:
logging:
level: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
+ loggers:
+ # Cap noisy frameworks at WARN so TRACE/DEBUG surfaces Texera code
+ # (org.apache.texera) without the framework firehose.
+ "org.apache.pekko": WARN
+ "org.apache.iceberg": WARN
+ "org.apache.hadoop": WARN
+ "org.apache.kafka": WARN
+ "org.eclipse.jetty": WARN
+ "org.glassfish.jersey": WARN
+ "io.grpc": WARN
+ "io.netty": WARN
+ "com.zaxxer.hikari": WARN
+ "software.amazon.awssdk": WARN
appenders:
- type: console
threshold: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
diff --git
a/config-service/src/main/scala/org/apache/texera/service/ConfigService.scala
b/config-service/src/main/scala/org/apache/texera/service/ConfigService.scala
index a7e9b61d99..df7335d21f 100644
---
a/config-service/src/main/scala/org/apache/texera/service/ConfigService.scala
+++
b/config-service/src/main/scala/org/apache/texera/service/ConfigService.scala
@@ -53,6 +53,8 @@ class ConfigService extends
Application[ConfigServiceConfiguration] with LazyLog
}
override def run(configuration: ConfigServiceConfiguration, environment:
Environment): Unit = {
+ // Bridge this service's logs to the OTel collector under its own
service.name.
+ org.apache.texera.observability.OtelInit.init("config-service")
// Serve backend at /api
environment.jersey.setUrlPattern("/api/*")
diff --git a/file-service/LICENSE-binary b/file-service/LICENSE-binary
index b84e5912d6..681bf5444a 100644
--- a/file-service/LICENSE-binary
+++ b/file-service/LICENSE-binary
@@ -334,6 +334,18 @@ Scala/Java jars:
- io.netty.netty-transport-native-epoll-4.2.15.Final.jar
- io.netty.netty-transport-native-unix-common-4.2.15.Final.jar
- org.jspecify.jspecify-1.0.0.jar
+ - io.opentelemetry.opentelemetry-api-1.50.0.jar
+ - io.opentelemetry.opentelemetry-context-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-sender-okhttp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-extension-autoconfigure-spi-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-logs-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-metrics-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-trace-1.50.0.jar
- io.perfmark.perfmark-api-0.27.0.jar
- io.r2dbc.r2dbc-spi-1.0.0.RELEASE.jar
- jakarta.inject.jakarta.inject-api-2.0.1.jar
diff --git a/file-service/src/main/resources/file-service-web-config.yaml
b/file-service/src/main/resources/file-service-web-config.yaml
index 41f8d1b174..db5a7ec664 100644
--- a/file-service/src/main/resources/file-service-web-config.yaml
+++ b/file-service/src/main/resources/file-service-web-config.yaml
@@ -28,6 +28,18 @@ logging:
level: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
loggers:
"io.dropwizard": ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
+ # Cap noisy frameworks at WARN so TRACE/DEBUG surfaces Texera code
+ # (org.apache.texera) without the framework firehose.
+ "org.apache.pekko": WARN
+ "org.apache.iceberg": WARN
+ "org.apache.hadoop": WARN
+ "org.apache.kafka": WARN
+ "org.eclipse.jetty": WARN
+ "org.glassfish.jersey": WARN
+ "io.grpc": WARN
+ "io.netty": WARN
+ "com.zaxxer.hikari": WARN
+ "software.amazon.awssdk": WARN
appenders:
- type: console
- type: file
diff --git
a/file-service/src/main/scala/org/apache/texera/service/FileService.scala
b/file-service/src/main/scala/org/apache/texera/service/FileService.scala
index 63cee25a7a..086a45480d 100644
--- a/file-service/src/main/scala/org/apache/texera/service/FileService.scala
+++ b/file-service/src/main/scala/org/apache/texera/service/FileService.scala
@@ -65,6 +65,8 @@ class FileService extends
Application[FileServiceConfiguration] with LazyLogging
}
override def run(configuration: FileServiceConfiguration, environment:
Environment): Unit = {
+ // Bridge this service's logs to the OTel collector under its own
service.name.
+ org.apache.texera.observability.OtelInit.init("file-service")
// Serve backend at /api
environment.jersey.setUrlPattern("/api/*")
SqlServer.initConnection(
diff --git a/notebook-migration-service/LICENSE-binary
b/notebook-migration-service/LICENSE-binary
index 7b9b8f84b4..d8ae431354 100644
--- a/notebook-migration-service/LICENSE-binary
+++ b/notebook-migration-service/LICENSE-binary
@@ -243,8 +243,9 @@ Scala/Java jars:
- com.google.j2objc.j2objc-annotations-2.8.jar
- com.helger.profiler-1.1.1.jar
- com.squareup.okhttp3.logging-interceptor-3.12.12.jar
- - com.squareup.okhttp3.okhttp-3.12.12.jar
- - com.squareup.okio.okio-1.15.0.jar
+ - com.squareup.okhttp3.okhttp-4.12.0.jar
+ - com.squareup.okio.okio-3.6.0.jar
+ - com.squareup.okio.okio-jvm-3.6.0.jar
- com.thesamet.scalapb.lenses_2.13-0.11.20.jar
- com.thesamet.scalapb.scalapb-json4s_2.13-0.12.0.jar
- com.thesamet.scalapb.scalapb-runtime_2.13-0.11.20.jar
@@ -303,6 +304,18 @@ Scala/Java jars:
- io.fabric8.kubernetes-model-scheduling-6.12.1.jar
- io.fabric8.kubernetes-model-storageclass-6.12.1.jar
- io.fabric8.zjsonpatch-0.3.0.jar
+ - io.opentelemetry.opentelemetry-api-1.50.0.jar
+ - io.opentelemetry.opentelemetry-context-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-sender-okhttp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-extension-autoconfigure-spi-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-logs-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-metrics-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-trace-1.50.0.jar
- io.r2dbc.r2dbc-spi-1.0.0.RELEASE.jar
- jakarta.inject.jakarta.inject-api-2.0.1.jar
- jakarta.validation.jakarta.validation-api-3.0.2.jar
@@ -321,6 +334,11 @@ Scala/Java jars:
- org.hibernate.validator.hibernate-validator-7.0.5.Final.jar
- org.javassist.javassist-3.30.2-GA.jar
- org.jboss.logging.jboss-logging-3.5.3.Final.jar
+ - org.jetbrains.annotations-13.0.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-1.9.10.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-common-1.9.10.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-jdk7-1.9.10.jar
+ - org.jetbrains.kotlin.kotlin-stdlib-jdk8-1.9.10.jar
- org.jooq.jooq-3.19.36.jar
- org.json4s.json4s-ast_2.13-4.0.1.jar
- org.json4s.json4s-jackson-core_2.13-4.0.1.jar
diff --git
a/notebook-migration-service/src/main/resources/notebook-migration-service-web-config.yaml
b/notebook-migration-service/src/main/resources/notebook-migration-service-web-config.yaml
index 947dd59c4f..6c8d061ab9 100644
---
a/notebook-migration-service/src/main/resources/notebook-migration-service-web-config.yaml
+++
b/notebook-migration-service/src/main/resources/notebook-migration-service-web-config.yaml
@@ -26,6 +26,20 @@ server:
logging:
level: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
+ loggers:
+ "io.dropwizard": ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
+ # Cap noisy frameworks at WARN so TRACE/DEBUG surfaces Texera code
+ # (org.apache.texera) without the framework firehose.
+ "org.apache.pekko": WARN
+ "org.apache.iceberg": WARN
+ "org.apache.hadoop": WARN
+ "org.apache.kafka": WARN
+ "org.eclipse.jetty": WARN
+ "org.glassfish.jersey": WARN
+ "io.grpc": WARN
+ "io.netty": WARN
+ "com.zaxxer.hikari": WARN
+ "software.amazon.awssdk": WARN
appenders:
- type: console
threshold: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
diff --git
a/notebook-migration-service/src/main/scala/org/apache/texera/service/NotebookMigrationService.scala
b/notebook-migration-service/src/main/scala/org/apache/texera/service/NotebookMigrationService.scala
index 567cf2b4c6..d9d883b6cc 100644
---
a/notebook-migration-service/src/main/scala/org/apache/texera/service/NotebookMigrationService.scala
+++
b/notebook-migration-service/src/main/scala/org/apache/texera/service/NotebookMigrationService.scala
@@ -62,6 +62,7 @@ class NotebookMigrationService
configuration: NotebookMigrationServiceConfiguration,
environment: Environment
): Unit = {
+ org.apache.texera.observability.OtelInit.init("notebook-migration-service")
// Refuse to boot a misconfigured per-user Jupyter rather than failing per
request.
JupyterTokenDeriver.validateConfiguration()
diff --git a/workflow-compiling-service/LICENSE-binary
b/workflow-compiling-service/LICENSE-binary
index 96c723694a..90befd23b9 100644
--- a/workflow-compiling-service/LICENSE-binary
+++ b/workflow-compiling-service/LICENSE-binary
@@ -336,6 +336,18 @@ Scala/Java jars:
- io.netty.netty-transport-native-epoll-4.2.15.Final.jar
- io.netty.netty-transport-native-unix-common-4.2.15.Final.jar
- org.jspecify.jspecify-1.0.0.jar
+ - io.opentelemetry.opentelemetry-api-1.50.0.jar
+ - io.opentelemetry.opentelemetry-context-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-otlp-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-exporter-sender-okhttp-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-common-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-extension-autoconfigure-spi-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-logs-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-metrics-1.50.0.jar
+ - io.opentelemetry.opentelemetry-sdk-trace-1.50.0.jar
- io.perfmark.perfmark-api-0.27.0.jar
- io.r2dbc.r2dbc-spi-1.0.0.RELEASE.jar
- jakarta.inject.jakarta.inject-api-2.0.1.jar
diff --git
a/workflow-compiling-service/src/main/resources/workflow-compiling-service-config.yaml
b/workflow-compiling-service/src/main/resources/workflow-compiling-service-config.yaml
index 5b9016af1b..37e413c15b 100644
---
a/workflow-compiling-service/src/main/resources/workflow-compiling-service-config.yaml
+++
b/workflow-compiling-service/src/main/resources/workflow-compiling-service-config.yaml
@@ -28,6 +28,18 @@ logging:
level: ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
loggers:
"io.dropwizard": ${TEXERA_SERVICE_LOG_LEVEL:-INFO}
+ # Cap noisy frameworks at WARN so TRACE/DEBUG surfaces Texera code
+ # (org.apache.texera) without the framework firehose.
+ "org.apache.pekko": WARN
+ "org.apache.iceberg": WARN
+ "org.apache.hadoop": WARN
+ "org.apache.kafka": WARN
+ "org.eclipse.jetty": WARN
+ "org.glassfish.jersey": WARN
+ "io.grpc": WARN
+ "io.netty": WARN
+ "com.zaxxer.hikari": WARN
+ "software.amazon.awssdk": WARN
appenders:
- type: console
- type: file
diff --git
a/workflow-compiling-service/src/main/scala/org/apache/texera/service/WorkflowCompilingService.scala
b/workflow-compiling-service/src/main/scala/org/apache/texera/service/WorkflowCompilingService.scala
index 01faed615c..50673337b3 100644
---
a/workflow-compiling-service/src/main/scala/org/apache/texera/service/WorkflowCompilingService.scala
+++
b/workflow-compiling-service/src/main/scala/org/apache/texera/service/WorkflowCompilingService.scala
@@ -50,6 +50,8 @@ class WorkflowCompilingService extends
Application[WorkflowCompilingServiceConfi
configuration: WorkflowCompilingServiceConfiguration,
environment: Environment
): Unit = {
+ // Bridge this service's logs to the OTel collector under its own
service.name.
+ org.apache.texera.observability.OtelInit.init("workflow-compiling-service")
ObjectMapperUtils.warmupObjectMapperForOperatorsSerde()
// serve backend at /api