-
Notifications
You must be signed in to change notification settings - Fork 78
Add new Telemetry Drain resource #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8b9cf18
Add new heroku_telemetry_drain resource for fir generation
heroku-johnny 6355a4d
Fix telemetry drain acceptance test configuration
heroku-johnny c76b4d5
Remove space-scoped drain from acceptance test
heroku-johnny 50a6f75
Make headers required for telemetry drains and add space-scoped drain…
heroku-johnny 13f38b9
Fix acceptance test issues for telemetry drains
heroku-johnny 3c8bd8f
Fix flaky VPN connection test - make tunnel count flexible
heroku-johnny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| --- | ||
| layout: "heroku" | ||
| page_title: "Heroku: heroku_telemetry_drain" | ||
| sidebar_current: "docs-heroku-resource-telemetry-drain" | ||
| description: |- | ||
| Provides a Heroku Telemetry Drain resource. | ||
| --- | ||
|
|
||
| # heroku\_telemetry\_drain | ||
|
|
||
| Provides a [Heroku Telemetry Drain](https://devcenter.heroku.com/articles/platform-api-reference#telemetry-drain) resource. | ||
|
|
||
| A telemetry drain forwards OpenTelemetry traces, metrics, and logs from Fir generation apps and spaces to your own consumer endpoint. | ||
|
|
||
| ## Generation Compatibility | ||
|
|
||
| Telemetry drains are **only supported for Fir generation** apps and spaces. Cedar generation apps should use the [`heroku_drain`](./drain.html) resource for log forwarding instead. | ||
|
|
||
| If you attempt to create a telemetry drain for a Cedar generation app or space, the provider will return a clear error message directing you to use the appropriate resource type. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ### App-scoped Telemetry Drain | ||
|
|
||
| ```hcl | ||
| resource "heroku_space" "fir_space" { | ||
| name = "my-fir-space" | ||
| organization = "my-org" | ||
| region = "virginia" | ||
| generation = "fir" | ||
| } | ||
|
|
||
| resource "heroku_app" "fir_app" { | ||
| name = "my-fir-app" | ||
| region = "virginia" | ||
| space = heroku_space.fir_space.name | ||
|
|
||
| organization { | ||
| name = "my-org" | ||
| } | ||
| } | ||
|
|
||
| resource "heroku_telemetry_drain" "app_traces" { | ||
| owner_id = heroku_app.fir_app.id | ||
| owner_type = "app" | ||
| endpoint = "https://api.honeycomb.io/v1/traces" | ||
| exporter_type = "otlphttp" | ||
| signals = ["traces", "metrics"] | ||
|
|
||
| headers = { | ||
| "x-honeycomb-team" = var.honeycomb_api_key | ||
| "x-honeycomb-dataset" = "my-service" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Space-scoped Telemetry Drain | ||
|
|
||
| ```hcl | ||
| resource "heroku_telemetry_drain" "space_observability" { | ||
| owner_id = heroku_space.fir_space.id | ||
| owner_type = "space" | ||
| endpoint = "otel-collector.example.com:4317" | ||
| exporter_type = "otlp" | ||
| signals = ["traces", "metrics", "logs"] | ||
|
|
||
| headers = { | ||
| "Authorization" = "Bearer ${var.collector_token}" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Logs-only Telemetry Drain | ||
|
|
||
| ```hcl | ||
| resource "heroku_telemetry_drain" "app_logs" { | ||
| owner_id = heroku_app.fir_app.id | ||
| owner_type = "app" | ||
| endpoint = "https://logs.datadog.com/api/v2/logs" | ||
| exporter_type = "otlphttp" | ||
| signals = ["logs"] | ||
|
|
||
| headers = { | ||
| "DD-API-KEY" = var.datadog_api_key | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Argument Reference | ||
|
|
||
| The following arguments are supported: | ||
|
|
||
| * `owner_id` - (Required, ForceNew) The UUID of the app or space that owns this telemetry drain. | ||
| * `owner_type` - (Required, ForceNew) The type of owner. Must be either `"app"` or `"space"`. | ||
| * `endpoint` - (Required) The URI of your OpenTelemetry consumer endpoint. | ||
| * `exporter_type` - (Required) The transport type for your OpenTelemetry consumer. Must be either: | ||
| * `"otlphttp"` - HTTP/HTTPS endpoints (e.g., `https://api.example.com/v1/traces`) | ||
| * `"otlp"` - gRPC endpoints in `host:port` format (e.g., `collector.example.com:4317`) | ||
| * `signals` - (Required) A set of OpenTelemetry signals to send to the telemetry drain. Valid values are: | ||
| * `"traces"` - Distributed tracing data | ||
| * `"metrics"` - Application and system metrics | ||
| * `"logs"` - Application and system logs | ||
| * `headers` - (Optional) A map of headers to send to your OpenTelemetry consumer for authentication or configuration. | ||
|
|
||
| ## Attributes Reference | ||
|
|
||
| The following attributes are exported: | ||
|
|
||
| * `id` - The UUID of the telemetry drain. | ||
| * `created_at` - The timestamp when the telemetry drain was created. | ||
| * `updated_at` - The timestamp when the telemetry drain was last updated. | ||
|
|
||
| ## Endpoint Format Requirements | ||
|
|
||
| The `endpoint` format depends on the `exporter_type`: | ||
|
|
||
| * **otlphttp**: Full HTTP/HTTPS URL (e.g., `https://api.honeycomb.io/v1/traces`) | ||
| * **otlp**: Host and port only (e.g., `collector.example.com:4317`) | ||
|
|
||
| ## Headers | ||
|
|
||
| The `headers` field supports custom key-value pairs for authentication and configuration: | ||
|
|
||
| * **Keys**: Must match the pattern `^[A-Za-z0-9\-_]{1,100}$` (alphanumeric, hyphens, underscores, max 100 chars) | ||
| * **Values**: Maximum 1000 characters each | ||
| * **Limit**: Maximum 20 header pairs per telemetry drain | ||
|
|
||
| Common header patterns: | ||
| * **API Keys**: `"Authorization" = "Bearer token"` or `"x-api-key" = "key"` | ||
| * **Content Types**: `"Content-Type" = "application/x-protobuf"` | ||
| * **Service Tags**: `"x-service" = "my-app"`, `"x-environment" = "production"` | ||
|
|
||
| ## Validation | ||
|
|
||
| The provider performs generation-aware validation: | ||
|
|
||
| 1. **Plan-time**: Schema validation for field types, required fields, and enum values | ||
| 2. **Apply-time**: Generation compatibility check via Heroku API | ||
| * Fetches app/space information to determine generation | ||
| * Returns descriptive error if Cedar generation detected | ||
| * Suggests using `heroku_drain` for Cedar apps | ||
|
|
||
| ## Import | ||
|
|
||
| Telemetry drains can be imported using the drain `id`: | ||
|
|
||
| ``` | ||
| $ terraform import heroku_telemetry_drain.example 01234567-89ab-cdef-0123-456789abcdef | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| * **Immutable Owner**: The `owner_id` and `owner_type` cannot be changed after creation (ForceNew) | ||
| * **Updates Supported**: `endpoint`, `exporter_type`, `signals`, and `headers` can be modified | ||
| * **Generation Requirement**: Only works with Fir generation apps and spaces | ||
| * **Multiple Drains**: You can create multiple telemetry drains per app or space | ||
| * **Signal Filtering**: Use different drains to send different signal types to different endpoints |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be passing real context from somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jttyeung this provider is still using original, very old Provider architecture.
Terraform Plugin SDKv2, as used today, does support a context aware interface., but that is not pulled in here yet.
Johnny & I discussed working on SDK/Framework uplift, which will include addressing proper context passthrough, after this initial push to deliver Fir support is complete.