Skip to content
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

[pkg/ottl] Add IsBool Converter #27897

Closed
4 tasks
TylerHelmuth opened this issue Oct 20, 2023 · 2 comments
Closed
4 tasks

[pkg/ottl] Add IsBool Converter #27897

TylerHelmuth opened this issue Oct 20, 2023 · 2 comments
Assignees
Labels
Contribfest enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed pkg/ottl priority:p2 Medium

Comments

@TylerHelmuth
Copy link
Member

TylerHelmuth commented Oct 20, 2023

Component(s)

pkg/ottl

Is your feature request related to a problem? Please describe.

OTTL has no way to check if a value is an bool type.

Describe the solution you'd like

Add a new Converter, IsBool that returns true if the given type is a bool (or equivalent type). It will work similarly to the IsString function.

The implementing PR should

  • Implement the function
  • Add new unit tests for the function
  • Add the function to pkg/ottl/ottlfuncs/functions.go
  • Update the README at pkg/ottl/ottlfuncs/README.md
@TylerHelmuth TylerHelmuth added enhancement New feature or request needs triage New item requiring triage help wanted Extra attention is needed good first issue Good for newcomers priority:p2 Medium Contribfest and removed needs triage New item requiring triage labels Oct 20, 2023
@TylerHelmuth TylerHelmuth changed the title [pkg/ottl] Add IsDouble Converter [pkg/ottl] Add IsBool Converter Oct 20, 2023
@TylerHelmuth TylerHelmuth added pkg/ottl and removed help wanted Extra attention is needed good first issue Good for newcomers labels Oct 21, 2023
@els0r
Copy link

els0r commented Nov 8, 2023

I'd love to have a look at this.

@codeboten
Copy link
Contributor

All yours @els0r, thanks!

TylerHelmuth pushed a commit that referenced this issue Nov 13, 2023
**Description:**
This PR focuses on adding a new feature to the pkg/ottl package—namely,
the `IsBool` converter, along with its prerequisites, `BoolGetter` and
`BoolLikeGetter`. The series of commits implement the core logic, unit
tests, and documentation to ensure that the `IsBool` converter is
seamlessly integrated into the OTTL framework. By using this feature,
users can conveniently determine whether a given value is a boolean or
not.

**Link to tracking Issue:** 
#27897

**Testing:**

- A comprehensive set of unit tests were added to validate the
functionality of the `IsBool` converter. The tests cover native boolean
values, `pcommon.ValueTypeBool` objects, and incorrect types such as
integers and slices.
- Tests for `BoolGetter` and `BoolLikeGetter` were also included to
verify their behavior and error handling mechanisms. Detailed test
implementations can be found in
[pkg/ottl/expression_test.go](https://github.com/Dennis40816/opentelemetry-collector-contrib/blob/0d1c2c0216f5647404573a6cfe66ebc0081a4167/pkg/ottl/expression_test.go#L1452).

**Documentation:**
- Updated README.md in the `pkg/ottl/ottlfuncs` directory to include
detailed descriptions, usage guidelines, and examples for the `IsBool`
converter.
- The README file also reflects the addition of `BoolGetter` and
`BoolLikeGetter` to the list of supported types for single-value
parameters in OTTL functions.
RoryCrispin pushed a commit to ClickHouse/opentelemetry-collector-contrib that referenced this issue Nov 24, 2023
**Description:**
This PR focuses on adding a new feature to the pkg/ottl package—namely,
the `IsBool` converter, along with its prerequisites, `BoolGetter` and
`BoolLikeGetter`. The series of commits implement the core logic, unit
tests, and documentation to ensure that the `IsBool` converter is
seamlessly integrated into the OTTL framework. By using this feature,
users can conveniently determine whether a given value is a boolean or
not.

**Link to tracking Issue:** 
open-telemetry#27897

**Testing:**

- A comprehensive set of unit tests were added to validate the
functionality of the `IsBool` converter. The tests cover native boolean
values, `pcommon.ValueTypeBool` objects, and incorrect types such as
integers and slices.
- Tests for `BoolGetter` and `BoolLikeGetter` were also included to
verify their behavior and error handling mechanisms. Detailed test
implementations can be found in
[pkg/ottl/expression_test.go](https://github.com/Dennis40816/opentelemetry-collector-contrib/blob/0d1c2c0216f5647404573a6cfe66ebc0081a4167/pkg/ottl/expression_test.go#L1452).

**Documentation:**
- Updated README.md in the `pkg/ottl/ottlfuncs` directory to include
detailed descriptions, usage guidelines, and examples for the `IsBool`
converter.
- The README file also reflects the addition of `BoolGetter` and
`BoolLikeGetter` to the list of supported types for single-value
parameters in OTTL functions.
@TylerHelmuth TylerHelmuth added help wanted Extra attention is needed good first issue Good for newcomers labels Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contribfest enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed pkg/ottl priority:p2 Medium
Projects
None yet
Development

No branches or pull requests

3 participants