Skip to content

Conversation

KevinMcHugh
Copy link

Hello! Thank you for providing this gem. I noticed a possible issue in my team's usage of it. Without this patch, an Array will be flattened, resulting in keys and values becoming mismatched.

Eg, given a request that responds to some_array_method with [1,2]:

logger = Fluent::Logger::FluentLogger.new
logger.tagged(array: :some_array_method, date: Date.today)

You might expect to see log entries having tags like:

{ array: [1,2], date: '2021-07-20' }

but it will actually have tags like:

{ array: 1, date: 2}

This can be worked around by passing a proc which calls to_s on any array values,
but it seems unlikely users would expect their keys to map to different values if some method returns an Array.

Without this patch, an Array will be flattened, resulting in keys and values
becoming mismatched.

Eg, given a request that responds to `some_array_method` with `[1,2]`:
```
logger = Fluent::Logger::FluentLogger.new
logger.tagged(array: :some_array_method, date: Date.today)
```
You might expect to see log entries having tags like:

```
{ array: [1,2], date: '2021-07-20' }
```

but it will actually have tags like:

```
{ array: 1, date: 2}
```

This can be worked around by passing a proc which calls `to_s` on any array values,
but it seems unlikely users would expect their keys to map to different values if some method returns an array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant