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

[otelcol] Tell all loggers to encode timestamps in ISO8601. #10543

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

igorpeshansky
Copy link

Description

OTel collector log messages in Windows are currently displayed in scientific notation, e.g.:

1.7194132367192364e+09  error   scraperhelper/scrapercontroller.go:197  Error scraping metrics  …

This fix will cause the log messages to use ISO8601 timestamps instead.

Testing

Manual testing.

Documentation

The previous behavior was undocumented, so no documentation changes needed.

@igorpeshansky igorpeshansky requested review from a team and codeboten July 4, 2024 19:17
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jul 19, 2024
Copy link
Contributor

github-actions bot commented Aug 2, 2024

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Aug 2, 2024
@djaglowski djaglowski reopened this Aug 6, 2024
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.69%. Comparing base (c8a932e) to head (0ef9b0f).
Report is 226 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10543   +/-   ##
=======================================
  Coverage   91.69%   91.69%           
=======================================
  Files         411      411           
  Lines       19294    19296    +2     
=======================================
+ Hits        17692    17694    +2     
  Misses       1241     1241           
  Partials      361      361           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@djaglowski djaglowski removed the Stale label Aug 7, 2024
Copy link
Member

@djaglowski djaglowski left a comment

Choose a reason for hiding this comment

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

LGTM. Please add a changelog entry. IMO this is best documented as a breaking change since it may affect users who are consuming the collector's logs.

Comment on lines +13 to +19
ec := zap.NewProductionEncoderConfig()
ec.EncodeTime = zapcore.ISO8601TimeEncoder
zapCfg := &zap.Config{
Level: zap.NewAtomicLevelAt(cfg.Level),
Development: cfg.Development,
Encoding: cfg.Encoding,
EncoderConfig: zap.NewProductionEncoderConfig(),
EncoderConfig: ec,
Copy link
Member

Choose a reason for hiding this comment

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

I believe only the change in collector_windows.go is necessary. Are you sure this needs changed also?

Copy link
Author

Choose a reason for hiding this comment

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

Wouldn't we have the same issue with the collector's stderr on Linux without this change?

Copy link
Member

Choose a reason for hiding this comment

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

I'll check again next week, but I believe it is getting set below. I've only ever seen the collector write out ISO timestamps, so I don't believe Linux is affected.

Copy link
Author

Choose a reason for hiding this comment

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

@TylerHelmuth Any progress on checking this? Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

@igorpeshansky a couple lines below there is:

if zapCfg.Encoding == "console" {
    // Human-readable timestamps for console format of logs.
    zapCfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
}

My guess is that for linux this condition is getting met which is why the timestamps when the collector is run in linux are ISO8601. I think if we set the value here, we can remove that conditional.

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Aug 27, 2024
@github-actions github-actions bot removed the Stale label Aug 28, 2024
Copy link
Contributor

github-actions bot commented Oct 6, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Oct 6, 2024
@igorpeshansky
Copy link
Author

Sorry, still planning to work on this.

@igorpeshansky igorpeshansky requested a review from a team as a code owner October 16, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants