Skip to content

feat(observability-pipelines): add WebSocket source#3855

Draft
Jansen-w wants to merge 3 commits into
masterfrom
jansen-w/websocket-source
Draft

feat(observability-pipelines): add WebSocket source#3855
Jansen-w wants to merge 3 commits into
masterfrom
jansen-w/websocket-source

Conversation

@Jansen-w
Copy link
Copy Markdown

@Jansen-w Jansen-w commented Jun 2, 2026

Summary

Adds the Observability Pipelines WebSocket source — a new websocket source under the datadog_observability_pipeline resource.

  • Model/Expand/Flatten/Schema following the existing source pattern.
  • Authentication: none, basic, bearer, custom.
  • TLS: a mode-discriminated nested block — enabled (TLS without a client certificate) or with_client_cert (mutual TLS; crt_file required, optional ca_file/key_file/key_pass_key).
  • Decoding: bytes/gelf/json/syslog.

Dependency

This uses datadog-api-client-go types for the WebSocket source that are generated from the API specification. Until that spec change is released and the client is regenerated, go build fails on the not-yet-generated types — so this stays a draft until the client is updated, after which it compiles and the acceptance test can run.

Test plan

  • go build ./... once the regenerated client lands
  • Acceptance test for the websocket source against a staging org

🤖 Generated with Claude Code

@datadog-prod-us1-6
Copy link
Copy Markdown

datadog-prod-us1-6 Bot commented Jun 2, 2026

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 19 Pipeline jobs failed

PR Integration Tests | integration-tests   View in Datadog   GitHub Actions

See error Build failed due to undefined types in websocket_source.go: 'datadogV2.NewObservabilityPipelineWebsocketSourceWithDefaults', 'datadogV2.ObservabilityPipelineWebsocketSourceAuthStrategy', 'datadogV2.ObservabilityPipelineWebsocketSourceTls', etc.

Run Tests | all-checks   View in Datadog   GitHub Actions

Run Tests | linter-checks   View in Datadog   GitHub Actions

See error Compilation error in websocket_source.go: undefined types and fields related to datadogV2.

View all 19 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e4d36c3 | Docs | Datadog PR Page | Give us feedback!

Implements the websocket source component: model structs, Expand/Flatten,
schema, and registration in the observability_pipeline resource. Auth
strategies none/basic/bearer/custom; mode-tagged TLS (enabled /
with_client_cert with crt_file required); decoding bytes/gelf/json/syslog.

Depends on the generated datadog-api-client-go websocket types from the API
spec change; the build is blocked until the client is regenerated.
@Jansen-w Jansen-w force-pushed the jansen-w/websocket-source branch from b53af57 to bf5c214 Compare June 2, 2026 20:23
@Jansen-w
Copy link
Copy Markdown
Author

Jansen-w commented Jun 2, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf5c21499f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +208 to +210
"crt_file": schema.StringAttribute{
Optional: true,
Description: "Path to the client certificate file. Required when `mode` is `with_client_cert`.",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce TLS mode-specific fields

When users set tls.mode = "enabled" together with any certificate field, Terraform accepts the config but ExpandWebsocketSource serializes only the mode in that branch, so the API read drops those fields and subsequent plans keep trying to apply them. Conversely, with_client_cert is documented as requiring crt_file but the schema permits omitting it, allowing an invalid empty certificate path to reach the API. Please validate the TLS oneOf shape, or split the modes into mutually exclusive blocks, instead of accepting the same optional fields for both modes.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest commit. Added WebsocketSourceTlsValidator (a validator.Object on the tls nested block, mirroring the existing SocketFramingValidator pattern):

  • mode = enabled: rejects crt_file/ca_file/key_file/key_pass_key if set, so no fields are silently dropped at expand time and there's no perma-diff.
  • mode = with_client_cert: requires a non-empty crt_file, matching the oneOf shape.

Enforced at plan time, so Expand never sees an invalid combination.

Add WebsocketSourceTlsValidator (validator.Object) on the tls nested
block to address code-review feedback:
- mode=enabled: reject crt_file, ca_file, key_file, key_pass_key if set,
  preventing silent field drops and perma-diffs in plans.
- mode=with_client_cert: require crt_file to be non-empty, matching the
  OpenAPI oneOf shape.

Mirrors the SocketFramingValidator pattern already used in this package
(object-level validator on NestedBlockObject.Validators).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jansen-w
Copy link
Copy Markdown
Author

Jansen-w commented Jun 3, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ae9535e2c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +45 to +46
if !exists || attr.IsNull() || attr.IsUnknown() {
return false
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow unknown certificate values during validation

When mode = "with_client_cert" and crt_file is derived from another resource output, Terraform can pass it to validators as unknown during planning; treating unknown as unset here makes the later !isSet("crt_file") check fail the plan even though the value may be known by apply. Provider validators should return without diagnostics for unknown values, so this blocks valid configurations that compute the client certificate path dynamically.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The validator no longer treats unknown values as unset — it now skips validation for any attribute that is unknown at plan time. with_client_cert only errors on a missing crt_file when it's known-and-empty/null (an unknown crt_file, e.g. from another resource's output, passes plan and is checked at apply); enabled only rejects cert fields that are known-and-non-empty. Mirrors the IsUnknown() skip pattern used by ExactlyOneProcessorValidator.

… planning

When cert fields (e.g. crt_file) are derived from another resource's output
they are UNKNOWN at plan time. The previous isSet helper treated unknown the
same as null/missing, which caused the with_client_cert "crt_file required"
check to fire during planning even though the value would be known at apply.

Replace the single isSet helper with two explicit helpers:
- isKnownAndSet: returns true only for known, non-empty values (used for the
  enabled mode "must not be set" checks — unchanged behaviour).
- isKnownAndMissing: returns false for unknown values (skips the check),
  true for null/empty known values (used for the with_client_cert "required"
  check). This prevents false-positive plan errors on dynamic configs.

Addresses code-review feedback about unknown values during planning.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jansen-w
Copy link
Copy Markdown
Author

Jansen-w commented Jun 3, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4d36c3cc9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

func ExpandWebsocketSource(src *WebsocketSourceModel, id string) (datadogV2.ObservabilityPipelineConfigSourceItem, diag.Diagnostics) {
var diags diag.Diagnostics

s := datadogV2.NewObservabilityPipelineWebsocketSourceWithDefaults()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Regenerate the API client before using WebSocket types

This new source is wired directly to datadogV2.NewObservabilityPipelineWebsocketSourceWithDefaults() and related ObservabilityPipelineWebsocketSource* symbols, but the pinned github.com/DataDog/datadog-api-client-go/v2 in this repo does not export those symbols (go doc ...ObservabilityPipelineWebsocketSource reports no symbol). As committed, any build or test of the provider fails before users can use existing resources, so the provider needs the regenerated client/go.mod update in the same change or this code must be gated until that dependency lands.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is expected and called out in the PR description. The WebSocket types (ObservabilityPipelineWebsocketSource*) are generated from the API specification, which is a separate change that hasn't been released yet — so the pinned datadog-api-client-go doesn't export them and the build won't pass until the client is regenerated and the go.mod bumped. That's why this PR is in draft: it's staged to go green once the generated client lands. The provider code here is written against the finalized type/field names so it compiles as soon as the client is updated. Not gating/removing in this PR, since the dependency is part of the planned rollout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant