Skip to content

Expose CEL config on early header mutation extension #45420

@kamalmarhubi

Description

@kamalmarhubi

I would like access to CEL string functions in an early header mutation, but the CEL string extensions are not available in that context, and it can't be configured. The specific use case is to inspect and possibly transform trace context headers before the trace context is extracted and added to the downstream span.

Possible API shape would be to add a formatters config on the early_header_mutation.header_mutation.v3.HeaderMutation:

 // This extension allows for early header mutation by the substitution formatter.
 message HeaderMutation {
   repeated config.common.mutation_rules.v3.HeaderMutation mutations = 1
       [(validate.rules).repeated = {min_items: 1}];
+
+  // Formatter command parsers used for append header values.
+  // [#extension-category: envoy.formatter]
+  repeated config.core.v3.TypedExtensionConfig formatters = 2;
 }

// This extension allows for early header mutation by the substitution formatter.
message HeaderMutation {
repeated config.common.mutation_rules.v3.HeaderMutation mutations = 1
[(validate.rules).repeated = {min_items: 1}];
}

This would also need extensions.formatter.cel.v3.Cel to get an optional CelExpressionConfig so that this can actually be configured.

Alternative API placements:

  • CelExpressionConfig instead of repeated envoy.formatter TypedExtensionConfigs
    • this would be simpler for CEL, but less general in case any formatters grew options or if new ones were added
  • placing it on the mutation_rules.v3.HeaderMutation that uses it instead
    • this would effectively get both early and regular header mutation extensions in one change, though possibly force repetition of the config
    • if a user needs multiple different CEL configs, they can fairly easily have multiple early header mutations (I don't know enough to reason about if having more extensions in that way is dramatically worse)

If doing this the envoy.formatter TypedExtensionConfig way, then it likely makes sense to add it to header_mutation.v3.Mutations as well, so the settings can be used in the regular header mutation filter, including per-route config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions