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

feat: report attributes as fields #874

Merged
merged 17 commits into from
Feb 2, 2023
Merged

feat: report attributes as fields #874

merged 17 commits into from
Feb 2, 2023

Conversation

pdelewski
Copy link
Contributor

There is opened bug https://jira.kumoroku.com/jira/browse/SUMO-207676, which is about reporting severity as a field. This PR does similar thing as LokiExporter, adding severity into set of attributes. It's preliminary solution, showing only possible way, not necessarily final solution and question is how do we want to tackle it.

@pdelewski pdelewski requested a review from a team as a code owner December 19, 2022 10:56
@github-actions github-actions bot added the go label Dec 19, 2022
@pdelewski pdelewski force-pushed the severity-number-as-field branch from 72ca7c7 to 1c9bf0c Compare December 19, 2022 11:05
@swiatekm
Copy link

This shouldn't happen in the exporter, as exporters shouldn't modify data. I think this should be a feature in the schema processor, if anything, and should probably be configurable.

@aboguszewski-sumo
Copy link
Contributor

I agree that this should be in a processor. It also seems to be totally independent from what I'm doing right now in sumologicschema processor, so feel free to add it there as soon as you need it.

@pdelewski
Copy link
Contributor Author

This shouldn't happen in the exporter, as exporters shouldn't modify data. I think this should be a feature in the schema processor, if anything, and should probably be configurable.

Thx. Agree, that it should be configurable

@aboguszewski-sumo
Copy link
Contributor

A few nits. Please modify README.md and add a sample test to processor_test.go

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Dec 22, 2022
@pdelewski pdelewski force-pushed the severity-number-as-field branch 4 times, most recently from edc8148 to f5996e8 Compare December 23, 2022 13:07
@pdelewski pdelewski closed this Dec 27, 2022
@pdelewski pdelewski force-pushed the severity-number-as-field branch from f5996e8 to d670949 Compare December 27, 2022 10:11
@github-actions github-actions bot removed go documentation Improvements or additions to documentation labels Dec 27, 2022
@pdelewski pdelewski reopened this Dec 27, 2022
@github-actions github-actions bot added documentation Improvements or additions to documentation go labels Dec 27, 2022
@pdelewski pdelewski force-pushed the severity-number-as-field branch from c33469d to e1ad3dd Compare December 27, 2022 10:19
@pdelewski pdelewski force-pushed the severity-number-as-field branch from e1ad3dd to 73ea417 Compare December 27, 2022 10:37
@pdelewski pdelewski changed the title WIP feat: add severity number as field feat: add severity number as field Dec 27, 2022

# Defines whether `severity` attribute should be added to record attributes.
# default = true
add_severity_level_attribute: {true, false}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose the following configuration, or something similar:

add_severity_attribute:
  enabled: true
  attribute_name: loglevel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed configuration and extended to use other fields as well, eg. severity text span id and trace id. That was asked by our customer support, however I'm still waiting for confirmation if client needs that. Anyway, we can always leave it or remove.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be updated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @astencel-sumo that the configuration added by this PR should be grouped in one major key, instead of producing 4 new config options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sumo-drosiek I don't think @astencel-sumo suggested grouping, but maybe I'm wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pdelewski any update on this? The customer is inquiring for updates and I don't see any recent movement. Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bnartiff , I will update PR tomorrow. It still requires aprovals. I was also waiting for confirmation regarding fields that customer expects (as originally there were mentioned only severity, recently I updated that to spanid and traceid

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, I am going to check w/ the customer to confirm the desired fields. Thank you for adding spanid and traceid as well.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per customer, "I think severity, spanID, and traceID are a good start. I don’t have any other suggestions/needs at this point. " @pdelewski

@pdelewski pdelewski force-pushed the severity-number-as-field branch from 6dbd3a5 to 5f8a0e1 Compare January 3, 2023 12:42

In order to report one of them as field, following configuration is needed:

```json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```json
```yaml

@pdelewski
Copy link
Contributor Author

@astencel-sumo @sumo-drosiek @aboguszewski-sumo Could you look at this PR?

Copy link
Contributor

@aboguszewski-sumo aboguszewski-sumo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some problems with understanding how should this work in general. As I understand - there are some OTLP fields in logs that are not shown in Sumo, and to fix that, we transform them into regular attributes. Should every of these fields be translated, or only one, selected in the config? The implementation suggests that all of them are translated, but the config suggests that only one of them.


### Severity Attribute

Some fields that log entries consist are not displayed as fields in Sumo Logic out of the box.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Some fields that log entries consist are not displayed as fields in Sumo Logic out of the box.
Some fields that log entries consist of are not displayed as fields in Sumo Logic out of the box.

Comment on lines 70 to 75

# Defines whether `severity` attribute should be added to record attributes.
add_severity_number_attribute:
enabled: true
attribute_name: "loglevel"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep it consistent with other examples above in this file, eg.:

add_severity_number_attribute:
    # if enabled, then XYZ
    # default = true
     enabled: {true, false}
    # The name that is something
    # default = "loglevel"
     attribute_name: "loglevel"

Comment on lines 292 to 298
In order to report one of them as field, following configuration is needed:

```yaml
add_severity_number_attribute:
enabled: true
attribute_name: "loglevel"
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can all of them be enabled or only one at one time? Maybe it's better to squash this into one attribute and disable it by selecting none, empty string or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was to be able to enable one by one, however I have not seen requirements regarding this from customer side.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've read the discussion above. In my opinion, the best thing would be to define something like this (the name should probably be different, I'm not sure how to call all these attributes):

add_log_metadata_attributes:
  metadata: ["severity_no", "severity_text", "span_id", "trace_id"]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I can update implementation according to your suggestion, @astencel-sumo @sumo-drosiek What's your opinion on that? I would like to avoid yet another round of changes regarding configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that squashing all configurations into a single property is any better than the current solution. We can discuss in a meeting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that squashing all configurations into a single property is any better than the current solution. We can discuss in a meeting.

same as we skip attribute_name

Comment on lines 1248 to 1276
name: "addSeverity",
addSeverity: true,
createLogs: func() plog.Logs {
logs := plog.NewLogs()
log := logs.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty()
log.SetSeverityNumber(plog.SeverityNumberInfo)
log.SetSeverityText("severity")
var spanIDBytes [8]byte = [8]byte{1, 1, 1, 1, 1, 1, 1, 1}
log.SetSpanID(spanIDBytes)
var traceIDBytes [16]byte = [16]byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
log.SetTraceID(traceIDBytes)
return logs
},
test: func(outputLogs plog.Logs) {
attribute1, found := outputLogs.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Attributes().Get("loglevel")
assert.True(t, found)
assert.Equal(t, "INFO", attribute1.Str())
attribute2, found := outputLogs.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Attributes().Get("severitytext")
assert.True(t, found)
assert.Equal(t, "severity", attribute2.Str())
attribute3, found := outputLogs.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Attributes().Get("spanid")
assert.True(t, found)
assert.Equal(t, "0101010101010101", attribute3.Str())
attribute4, found := outputLogs.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Attributes().Get("traceid")
assert.True(t, found)
assert.Equal(t, "01010101010101010101010101010101", attribute4.Str())

},
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how this works.
In the config (lines 1356+), you set only SeverityNumberAttributeName to be transformed, but here everything is transformed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check that


`add_severity_number_attribute`
`add_severity_text_attribute`
`add_space_id_attribute`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`add_space_id_attribute`
`add_span_id_attribute`

@@ -1298,3 +1353,15 @@ func newAggregateAttributesConfig(aggregations []aggregationPair) *Config {
config.AggregateAttributes = aggregations
return config
}

func newLogFieldsConversionConfig(logFieldsConversion bool) *Config {
Copy link
Contributor

@andrzej-stencel andrzej-stencel Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter logFieldsConversion does not seem to be used? Which probably indicates that the test coverage is not good enough 😉

Copy link
Contributor Author

@pdelewski pdelewski Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sumo-drosiek @astencel-sumo @aboguszewski-sumo I updated PR according to our today discussion as well as fixed some bugs. Current configuration looks as suggested by @sumo-drosiek, however I have not changed main key field_attributes yet. (I'm looking for better alternative and inspiration )

field_attributes:
  trace_id:
    enabled: true
    name: traceid
  span_id:
    enabled: true
    name: spanid

If you have suggestion regarding replacing fieldd_attributes with better name, just let me know

@pdelewski pdelewski force-pushed the severity-number-as-field branch from 843581b to a04f125 Compare January 25, 2023 17:07
@pdelewski pdelewski force-pushed the severity-number-as-field branch from a04f125 to 6b88312 Compare January 25, 2023 17:33
enabled: true
name: "loglevel"

- ...
Copy link
Contributor

@aboguszewski-sumo aboguszewski-sumo Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line (79) seems redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment on lines +74 to +77
field_attributes:
severity_number:
enabled: true
name: "loglevel"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Info about defaults is missing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update

Copy link
Contributor

@aboguszewski-sumo aboguszewski-sumo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test that checks if this is correct?

    field_attributes:
      severity_number:
        enabled: true
        name: "definitely_not_default_name"

@pdelewski
Copy link
Contributor Author

pdelewski commented Feb 2, 2023

Could you add a test that checks if this is correct?

    field_attributes:
      severity_number:
        enabled: true
        name: "definitely_not_default_name"

@aboguszewski-sumo I updated current test using suggested name definitely_not_default_name. Will this satisfy your requirements?

Copy link
Contributor

@aboguszewski-sumo aboguszewski-sumo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I overlooked one thing when I asked for that, sorry for inconvienience.

@pdelewski pdelewski merged commit 7167cf4 into main Feb 2, 2023
@pdelewski pdelewski deleted the severity-number-as-field branch February 2, 2023 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation go
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants