equinix-labs / equinix-labs/otel-cli
Adding or partially overriding attributes
- Dominant language
- Go
- Stars
- 716
- Forks
- 57
- PR merge metrics
- No merged PRs in 30d
Description
Unsure whether I'm not spotting the right incantation/flag to do this, or it is a feature request.
Under the following circumstances, it would be useful to be able to append/override attributes instead of overwriting them:
1. When calling `span end` on a span that already has attributes:
```sh
TEST_SOCK=$(mktemp -d)
otel-cli span background \
--name "test" \
--sockdir "${TEST_SOCK}" \
--attr "color=red,size=large" \
&
# ...
otel-cli span end \
--sockdir "${TEST_SOCK}" \
--attr "weight=100,size=small"
# Want span with attributes { color=red, size=small, weight=100 }
````
1. When calling any command with `--attr` when `OTEL_CLI_ATTRIBUTES` is non-empty:
```sh
OTEL_CLI_ATTRIBUTES="color=red,size=large"
otel-cli exec \
--name "test" \
--attr "weight=100,size=small" \
work
# Want span with attributes { color=red, size=small, weight=100 }
````
In OTel terms of other languages/instrumentations, it would give us [Set Attributes][1]-like capabilities. This could be an additional attribute argument (`--add-attr` and `OTEL_CLI_ADDITIONAL_ATTRIBUTES`?), or a flag (`--preserve-attr` and `OTEL_CLI_PRESERVE_EXISTING_ATTRIBUTES`?) modifying the behavior of `--attr`.
[1]: https://opentelemetry.io/docs/specs/otel/trace/api/#set-attributes
Contributor guide
Research direction
Trace attribute handling for `span end` and commands such as `exec`, including `--attr` and `OTEL_CLI_ATTRIBUTES`. Compare the requested append/override behavior with the current attribute precedence, then verify that existing attributes are preserved while later values replace duplicate keys in both scenarios.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, shell
- Domain
- cli, observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100