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

[telemetry] Add disabled flag on each telemetry type, and sync logger on shutdown. #7094

Closed
wants to merge 4 commits into from

Conversation

atoulme
Copy link
Contributor

@atoulme atoulme commented Feb 2, 2023

Description:
Add disabled flag on each telemetry type, and sync logger on shutdown.

Remove TODO and apply sync on telemetry shutdown

@atoulme atoulme requested review from a team and djaglowski February 2, 2023 02:33
@atoulme atoulme force-pushed the sync_logger branch 2 times, most recently from 8018e51 to 718411a Compare February 2, 2023 05:49
service/service_test.go Outdated Show resolved Hide resolved
@djaglowski
Copy link
Member

Looks like the test failures may be related to the change.

@atoulme
Copy link
Contributor Author

atoulme commented Feb 2, 2023

I'll take a look, thanks.

bogdandrutu
bogdandrutu previously approved these changes Feb 3, 2023
@atoulme
Copy link
Contributor Author

atoulme commented Feb 3, 2023

Yes, I'm looking more into it. There is a bit of an issue with how we manage situations where we test with this logger because stderr is not available from within tests.
I tried to disable going to stderr with an empty array, but in that case the default applies.
I have some code towards disabling logging explicitly (level: none). It expands the scope of the PR a bit and I have at least one test that depends on logger emitting at least once that fails. I'll keep looking.

@atoulme atoulme force-pushed the sync_logger branch 2 times, most recently from 26a5238 to e309813 Compare February 3, 2023 04:29
@atoulme
Copy link
Contributor Author

atoulme commented Feb 3, 2023

It turns out our tests here would fail because stderr is set by default, if no value is provided. I have developed therefore a different approach for testing: creating a log level of none where we just return a zap.NewNop() instead of building the logger.

With that change, and applying that change to the yaml config files used in tests, we get all tests to pass.

@codecov
Copy link

codecov bot commented Feb 3, 2023

Codecov Report

Patch coverage: 96.55% and project coverage change: -0.14 ⚠️

Comparison is base (105e5ae) 90.99% compared to head (f2c3be6) 90.86%.

❗ Current head f2c3be6 differs from pull request most recent head 1207721. Consider uploading reports for the commit 1207721 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7094      +/-   ##
==========================================
- Coverage   90.99%   90.86%   -0.14%     
==========================================
  Files         293      291       -2     
  Lines       14268    14072     -196     
==========================================
- Hits        12983    12786     -197     
  Misses       1017     1017              
- Partials      268      269       +1     
Impacted Files Coverage Δ
service/telemetry/config.go 100.00% <ø> (ø)
service/service.go 66.40% <85.71%> (-1.54%) ⬇️
otelcol/unmarshaler.go 100.00% <100.00%> (ø)
service/telemetry/telemetry.go 86.15% <100.00%> (+2.82%) ⬆️

... and 12 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bogdandrutu bogdandrutu dismissed their stale review February 3, 2023 05:08

dismiss my review since significant changes were made, will look tomorrow for the new approach

@bogdandrutu
Copy link
Member

It turns out our tests here would fail because stderr is set by default, if no value is provided. I have developed therefore a different approach for testing: creating a log level of none where we just return a zap.NewNop() instead of building the logger.

Do I understand correctly that we added the new public API just to fix tests?

@atoulme
Copy link
Contributor Author

atoulme commented Feb 3, 2023

Do I understand correctly that we added the new public API just to fix tests?

I guess there isn't any way to disable logging entirely, so maybe there's value to this beyond tests here.

@atoulme atoulme force-pushed the sync_logger branch 3 times, most recently from 919cdd5 to 189ca0a Compare February 21, 2023 00:55
@atoulme atoulme changed the title [telemetry] sync logger on shutdown [telemetry] Add enabled flag on each telemetry type, and sync logger on shutdown. Feb 21, 2023
@atoulme atoulme force-pushed the sync_logger branch 4 times, most recently from e94584a to 5dbf6cd Compare February 21, 2023 06:49
@bogdandrutu
Copy link
Member

@codeboten do we go with "Enable" or "Disable" int he config otep?

@codeboten
Copy link
Contributor

@codeboten do we go with "Enable" or "Disable" int he config otep?

@bogdandrutu the otep currently proposes disabled

@atoulme
Copy link
Contributor Author

atoulme commented Mar 15, 2023

I didn't know there was an otep. Got a link?

Mind approving the PR?

@dmitryax
Copy link
Member

We don't use disable anywhere in the collector repos. I don't think we should start using disabled without planning the migration if we want to migrate. I commented on the Otep https://github.com/open-telemetry/oteps/pull/225/files#r1139485969

@jpkrohling
Copy link
Member

Just to record somewhere: I prefer "enabled" instead of "disabled", as "disabled" requires a double-negative to have something activated (disabled=false means enabled).

@github-actions
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 Apr 13, 2023
@atoulme atoulme removed the Stale label Apr 13, 2023
@atoulme
Copy link
Contributor Author

atoulme commented Apr 13, 2023

Trying to understand what is blocking there. Are we stuck on disabled/enabled?

@github-actions
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 Apr 28, 2023
@dmitryax
Copy link
Member

dmitryax commented Apr 28, 2023

Trying to understand what is blocking there. Are we stuck on disabled/enabled?

I think so. If we want to be consistent within Collector, we need to use enabled. But if the Configuration SIG chooses a different strategy, we would need to change it in all the places. Having one more of them is probably not that critical. I'd say we can go with enabled here. @codeboten @jpkrohling @bogdandrutu WDYT?

@dmitryax dmitryax removed the Stale label Apr 28, 2023
@atoulme
Copy link
Contributor Author

atoulme commented Apr 28, 2023

I think enabled makes more sense. To keep backwards compatibility, we should assume enabled : true by default. The issue with that is we then need to use a pointer boolean, which earlier in this PR gave pause to Bogdan. We use a pointer boolean to find whether someone set the boolean expressly to false or if the value is not set (nil pointer).

@dmitryax
Copy link
Member

I think enabled makes more sense. To keep backwards compatibility, we should assume enabled : true by default. The issue with that is we then need to use a pointer boolean, which earlier in this PR gave pause to Bogdan. We use a pointer boolean to find whether someone set the boolean expressly to false or if the value is not set (nil pointer).

We can keep backward compatibility for end users without pointer. Default values are set https://github.com/open-telemetry/opentelemetry-collector/blob/main/otelcol/unmarshaler.go#L43, not ideal, but that's what we have

Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

I agree that we should pursue enabled instead of disabled unless absolutely necessary.

@github-actions
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 May 27, 2023
@github-actions
Copy link
Contributor

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

@github-actions github-actions bot closed this Jun 11, 2023
@tigrannajaryan
Copy link
Member

We have logs.level and metrics.level. metrics.level already supports none. We can add none to logs.level too and then enabled/disabled won't be necessary anymore.

@atoulme atoulme reopened this Jul 8, 2023
@atoulme
Copy link
Contributor Author

atoulme commented Jul 8, 2023

We have logs.level and metrics.level. metrics.level already supports none. We can add none to logs.level too and then enabled/disabled won't be necessary anymore.

That was discussed and was my first array into this work, but unfortunately there was pushback as maintainers said they want log level to be zap log levels.
See this commit: a7ac1b1

@github-actions github-actions bot removed the Stale label Jul 9, 2023
@github-actions
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 24, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

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

@github-actions github-actions bot closed this Aug 8, 2023
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.

7 participants