feat(otel_exporter): expose ubi.* identification fields on OTel Resource#81
Draft
feat(otel_exporter): expose ubi.* identification fields on OTel Resource#81
Conversation
Parse pg_stat_ch.extra_attributes in PopulateResource() and set matching ubi.* keys on the OTel Resource: - instance_ubid → ubi.postgres_resource_ubid - server_ubid → ubi.postgres_server_ubid - server_role → ubi.postgres_server_role - region → cloud.region - cell → cell This lets downstream OTel collectors (e.g. datagres-otelcol) route and validate arrow records against JWT claims without running a resource-enrichment processor on the VM. The same GUC is already consumed by ArrowBatchBuilder for the Arrow payload columns, so one config source populates both.
Add include/export/extra_attr_keys.h defining each recognized key as
a Key{guc_key, resource_attr} struct in a single kAll array.
Both the Arrow batch builder and the OTel exporter now reference these
constants instead of duplicating string literals across files. Adding
a new identification field is now a one-line addition to kAll plus
the Arrow column wiring (which still needs a typed builder per column).
Drive-by: ExtraAttr() now takes string_view instead of const char*.
This reverts commit 75ef37a.
Parse pg_stat_ch.extra_attributes once at exporter init (in ConfigureLogExport) and cache the resulting OTel Resource attribute pairs. PopulateResource now iterates the cached vector instead of re-parsing the GUC string on every batch. Mirrors arrow_batch.cc's parse-once-at-Init pattern. GUC changes require a connection restart.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Parse `pg_stat_ch.extra_attributes` in `PopulateResource()` and set matching identification keys on the OTel Resource so downstream collectors can route/filter arrow records against JWT claims without running a resource-enrichment processor on the VM.
Mapping from `extra_attributes` keys to OTel Resource attributes:
Why
The cell `datagres-otelcol` runs `filter/validate_claims` which compares `resource.attributes["ubi.postgres_resource_ubid"]` to the JWT claim `auth_token_clickgres_postgres_resource_id`. When arrow records skip resource enrichment on the VM (to save CPU), these attributes are missing and the filter silently no-ops via `error_mode: ignore` — auth is effectively bypassed.
With this change, pg_stat_ch emits arrow records with the ubi.* attributes already on the Resource, so:
The same GUC already feeds `ArrowBatchBuilder` for the Arrow payload columns, so one config source populates both.
Test plan