Add telemetry-to-caas kind for CaaS (Collector as a Service) support - #436
Add telemetry-to-caas kind for CaaS (Collector as a Service) support#436vkozyura wants to merge 30 commits into
Conversation
- Add telemetry-to-caas kind definition in package.json - Add getCredsForCaaS() to extract credentials from caas-service binding - Add augmentCaaSCreds() to configure OTLP endpoint URL - Handle CaaS in tracing and metrics exporters Note: CaaS requires mTLS authentication with SAP-signed certificates. The certificate must be obtained separately via BTP Certificate Service.
There was a problem hiding this comment.
The PR is generally well-structured, but has one logic bug: when only a gRPC OTLP endpoint is present in the CaaS binding, credentials.url is set to undefined (the falsy http value), silently breaking the exporter. Please address the flagged issues before merging.
PR Bot Information
Version: 1.26.5
- Event Trigger:
pull_request.opened - LLM:
anthropic--claude-4.6-sonnet - Correlation ID:
be7942dc-b11a-457c-a83d-2aafac5eb2c3 - File Content Strategy: Full file content
This file should not be committed to the feature branch.
SummaryThe following content is AI-generated and provides a summary of the pull request: Add
|
There was a problem hiding this comment.
The PR adds the telemetry-to-caas kind with reasonable structure, but there are several correctness issues that need attention: the shared OTEL_EXPORTER_OTLP_ENDPOINT env var is clobbered by both signal exporters (traces and metrics overwrite each other), invalid base64 mTLS data is silently accepted before failing at TLS handshake time, and an unsanitised user-provided regex pattern can crash the process at startup.
PR Bot Information
Version: 1.26.11
- LLM:
anthropic--claude-4.6-sonnet - Event Trigger:
pull_request.ready_for_review - Correlation ID:
66d6ae55-ae8a-46ec-9f81-f076100fcf4a - File Content Strategy: Full file content
| // Set OTLP env vars to binding credentials (prevents stale env values from taking precedence) | ||
| process.env.OTEL_EXPORTER_OTLP_ENDPOINT = credentials.baseUrl |
There was a problem hiding this comment.
| // Set OTLP env vars to binding credentials (prevents stale env values from taking precedence) | |
| process.env.OTEL_EXPORTER_OTLP_ENDPOINT = credentials.baseUrl |
they should take precedence and should not be altered
There was a problem hiding this comment.
@sjvans: The forced override is intentional for certificate renewal. During renewal the CaaS service is unbound/rebound and the app is restaged. After cf restage, stale OTEL_EXPORTER_OTLP_ENDPOINT values can persist in the environment while the binding credentials contain the current correct endpoint. Without forcing the binding value, the app would use the stale endpoint, causing connection failures with the renewed certificates.
There was a problem hiding this comment.
@sjvans: I tested certificate renewal as described in https://github.tools.sap/D051920/test_caas/blob/main/assets/CLI_GUIDE.md. It works also without this assignment above. Suggested changes are applied.
| // Set OTLP env vars to binding credentials (prevents stale env values from taking precedence) | ||
| process.env.OTEL_EXPORTER_OTLP_ENDPOINT = credentials.baseUrl |
There was a problem hiding this comment.
| // Set OTLP env vars to binding credentials (prevents stale env values from taking precedence) | |
| process.env.OTEL_EXPORTER_OTLP_ENDPOINT = credentials.baseUrl |
| // Set OTLP env vars to binding credentials (prevents stale env values from taking precedence) | ||
| process.env.OTEL_EXPORTER_OTLP_ENDPOINT = credentials.baseUrl |
There was a problem hiding this comment.
| // Set OTLP env vars to binding credentials (prevents stale env values from taking precedence) | |
| process.env.OTEL_EXPORTER_OTLP_ENDPOINT = credentials.baseUrl |
| // Also set url for backwards compatibility (without path - exporter will append it) | ||
| credentials.url = credentials.otlp.http |
There was a problem hiding this comment.
who needs this backwards compat?
|
|
||
| // Check for mTLS credentials (cert + key) in user-provided service | ||
| const mtlsCreds = getCredsForCaaSMtls() | ||
| if (mtlsCreds && mtlsCreds.cert && mtlsCreds.key) { |
There was a problem hiding this comment.
| if (mtlsCreds && mtlsCreds.cert && mtlsCreds.key) { | |
| if (mtlsCreds) { |
mtlsCreds is only truthy if cert and key were available in getCredsForCaaSMtls
| LOG._error && LOG.error('Failed to configure CaaS mTLS:', err.message) | ||
| } | ||
| } else { | ||
| LOG._warn && LOG.warn('CaaS requires mTLS authentication. No mTLS credentials found. Bind a user-provided service with cert and key (base64 encoded).') |
| 1. **Bind the CaaS service** to your app with subject/issuer configuration: | ||
| ```yaml | ||
| # mta.yaml | ||
| requires: | ||
| - name: my-caas-instance | ||
| parameters: | ||
| config: | ||
| subject: "CN=my-app,..." | ||
| issuer: "CN=SAP PKI Certificate Service Client CA,..." | ||
| ``` | ||
|
|
||
| 2. **Obtain and bind mTLS credentials** via a user-provided service containing `cert` and `key` (base64 encoded): | ||
| ```bash | ||
| cf create-user-provided-service caas-mtls-creds -p '{"cert":"<base64>","key":"<base64>"}' | ||
| cf bind-service my-app caas-mtls-creds | ||
| ``` | ||
|
|
||
| The mTLS certificate must be created (e.g., via `openssl`) and signed through SAP BTP Certificate Service. The certificate must be renewed periodically (typically every 7 days). | ||
|
|
||
| > Note: The user-provided service name must match the pattern configured in `mtls_service_pattern` (default: `caas-mtls|caas-cert`). |
Co-authored-by: sjvans <30337871+sjvans@users.noreply.github.com>
Co-authored-by: sjvans <30337871+sjvans@users.noreply.github.com>
Co-authored-by: sjvans <30337871+sjvans@users.noreply.github.com>
Co-authored-by: sjvans <30337871+sjvans@users.noreply.github.com>
Note: CaaS requires mTLS authentication with SAP-signed certificates. The certificate must be obtained separately via BTP Certificate Service.