open-telemetry / open-telemetry/weaver

Add the optional argument `fallback_policy` to the `map_text` filter

Open
#210 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement template engine
Dominant language
Rust
Stars
486
Forks
108
Avg merge
3d 4h
Merged PRs (30d)
40

Description

This PR describes the addition of a new optional argument to the map_text filter to define the behavior of this filter when an entry doesn’t exist in the weaver.yaml config file.

The map_text filter already supports the following arguments: map_text("<text_map_id>" [, "<default_value>"]).

This issue adds the concept of a fallback policy, defining more precisely the behavior of this filter when the input doesn't match any entries in the text_maps configuration.

The new optional parameter fallback_policy will accept one of the three possible configurations:

  • input: When this behavior is set, and there is no entry matching the input, the input is returned by the filter. This was the behavior of the filter when no default value was provided.
  • default: When this behavior is set, and there is no entry matching the input, the default value is returned by the filter. This was the behavior of the filter when a default value was provided. Using fallback_policy=default and not providing a default_value is considered an error, and the filter will emit an error.
  • error: When this behavior is set, and there is no entry matching the input, the filter will emit an error. This specific configuration was not supported in the previous version of the map_text filter.

By making the fallback policy explicit, it is now possible, for example, to specify that we want to fail the doc/code generation if the text_map configuration is incomplete.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the map_text filter and the text_maps configuration handling, then inspect how its existing default argument is parsed and applied. The work is done when input, default, and error fallback policies are supported, including validation for default without a default value and the corresponding error behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.