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

Enable service logging options when running as windows service #7025

Closed

Conversation

xborder
Copy link

@xborder xborder commented Jan 25, 2023

Description:

This PR partially addresses the issues described in #5300.

When running as a windows service, the collector's logger zapcore.Core is replaced by a customized zapcore.Core that writes the logs to the EventViewer ignoring what is configured in the yaml.
Instead of replacing it, the PR creates a Tee that preserves the original Core and its configuration, and adds the customized Core for EventViewer.
This way logs are duplicated and flushed by both Cores.
Since there isn't a specific telemetry configuration for windows the logging level is shared between both Cores.

As an example the following configuration:

service:
  telemetry:
    logs:
      level: warn
      output_paths: ["C:\\otel-collector.log"]

Would enable logs with a level equal or bigger to warn to be sent to EventViewer and the file otel-collector.log

This partially addresses this issue.

Link to tracking Issue:

Testing:

  • Tested locally on a windows machine

When running as a windows service, the collector's logger zapcore.Core is replaced
by a customized zapcore.Core that writes the logs to the EventViewer ignoring what is
configured in the yaml.
Instead of replacing it, the PR creates a Tee that preserves the original Core and its
configuration, and adds the customized Core for EventViewer. This way logs are
duplicated and flushed by both Cores.
@xborder xborder requested review from a team and Aneurysm9 January 25, 2023 17:16
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 25, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

djaglowski and others added 16 commits January 25, 2023 12:35
Trying to keep the API closer to some standard libraries like FlagsSet. If a getter is needed we should name it Lookup.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
* Feat: add httpsprovider component

Add the httpsprovider component that allows the collector to fetch
configuration from a web server using the https protocol.

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Add httpsprovider to the list of config providers

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Update README

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Apply suggestions from code review

Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>

* Improve unit tests

Improve unit tests to check for error while parsing test URL.

Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>

* Fix comments

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>

* Fix comments

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>

* Use SchemeType instead of TransportType

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Refactor to improve readability

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Use consts from http to set http status code

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Refactor code organization

Signed-off-by: Raphael Silva <rapphil@gmail.com>

* Use struct with zero initialized properties

Signed-off-by: Raphael Silva <rapphil@gmail.com>

Signed-off-by: Raphael Silva <rapphil@gmail.com>
Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
)

This is consisten with other places where we call the options as the func that applies to.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
…y#7027)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This repo does not use ghr.

Signed-off-by: Alex Boten <aboten@lightstep.com>

Signed-off-by: Alex Boten <aboten@lightstep.com>
Signed-off-by: Alex Boten <aboten@lightstep.com>

Signed-off-by: Alex Boten <aboten@lightstep.com>
Once open-telemetry/opentelemetry-collector-contrib#18057 is merged, this PR will update the documentation around releasing contrib.

Signed-off-by: Alex Boten <aboten@lightstep.com>

Signed-off-by: Alex Boten <aboten@lightstep.com>
Similar to FlagSet.Lookup where return pointers, clarifies that nil when error instead of invalid instance. This is not breaking change since this API was added in this version.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
…y#7041)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Will the existing testsuite for windows (https://github.com/open-telemetry/opentelemetry-collector/blob/main/.github/workflows/build-and-test-windows.yaml) be enough coverage to ensure this test solves part of the issue described?

Gaps in windows testing for this repo has historically caused problems.

Alex Boten and others added 9 commits January 27, 2023 09:50
@bogdandrutu if you're ok with it, I'd like to do the next release to ensure the changes to the release process I've made work.

Signed-off-by: Alex Boten <aboten@lightstep.com>
…r `retry_on_failure` (open-telemetry#7017)

* Allow configuration of fields, RandomizationFactor and Multiplier, for
`retry_on_failure`

* changelog entry
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
…ry#7074)

Bump go.opentelemetry.io/otel from 1.11.2 to 1.12.0
Bump go.opentelemetry.io/otel from 1.11.2 to 1.12.0 in /processor/batchprocessor
Bump go.opentelemetry.io/otel/exporters/prometheus from 0.34.0 to 0.35.0
Bump go.opentelemetry.io/otel/exporters/prometheus from 0.34.0 to 0.35.0 in /processor/batchprocessor
Bump go.opentelemetry.io/otel/metric from 0.34.0 to 0.35.0
Bump go.opentelemetry.io/otel/metric from 0.34.0 to 0.35.0 in /component
Bump go.opentelemetry.io/otel/metric from 0.34.0 to 0.35.0 in /processor/batchprocessor
Bump go.opentelemetry.io/otel/sdk from 1.11.2 to 1.12.0 in /extension/zpagesextension
Bump go.opentelemetry.io/otel/sdk from 1.11.2 to 1.12.0 in /processor/batchprocessor
Bump go.opentelemetry.io/otel/sdk/metric from 0.34.0 to 0.35.0 in /processor/batchprocessor
Bump go.opentelemetry.io/otel/trace from 1.11.2 to 1.12.0
Bump go.opentelemetry.io/otel/trace from 1.11.2 to 1.12.0 in /component
Bump go.opentelemetry.io/otel/trace from 1.11.2 to 1.12.0 in /extension/zpagesextension
Bump google.golang.org/grpc from 1.52.0 to 1.52.3
Bump google.golang.org/grpc from 1.52.0 to 1.52.3 in /exporter/otlpexporter
Bump google.golang.org/grpc from 1.52.0 to 1.52.3 in /exporter/otlphttpexporter
Bump google.golang.org/grpc from 1.52.0 to 1.52.3 in /pdata
Bump google.golang.org/grpc from 1.52.0 to 1.52.3 in /receiver/otlpreceiver

---------

Signed-off-by: Alex Boten <aboten@lightstep.com>
Co-authored-by: Alex Boten <aboten@lightstep.com>
…y#7032)

* Document ability to use config providers inside config

Fixes open-telemetry#6748

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>

* s/file/provider/

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>

* Move to its own heading

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>

---------

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
…y#7081)

This change simplifies the generated pdata code to not wrap orig fields in the internal package for structs that are not being used by other packages.

The code generator is adjusted to generate wrapped or unwrapped code for only for structs that need it based on the package name. The only exception is `Slice` struct that was pulled from the generator because:
- We don't have and don't expect to have any new slices that are used by other packages.
- The `Slice` struct have two additional methods `AsRaw` and `FromRaw` that are not generated and defined in a separate file which is a bit confusing.
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Alex Boten and others added 11 commits February 6, 2023 12:56
The previous change only modified the PR comment, instead of the call to `chlog-update` itself.

Signed-off-by: Alex Boten <aboten@lightstep.com>
…pen-telemetry#7148)

Not breaking change, not released yet.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
- Changelog update 0.71.0/1.0.0-rc5
- prepare release 1.0.0-rc5
- Prepare stable for version v1.0.0-rc5
- add multimod changes 1.0.0-rc5
- prepare release 0.71.0
- Prepare beta for version v0.71.0
- add multimod changes 0.71.0
….20 (open-telemetry#7151)

* remove go 1.18 support, bump minimum to go 1.19 and add testing for 1.20

Signed-off-by: Alex Boten <aboten@lightstep.com>

* update chlog

Signed-off-by: Alex Boten <aboten@lightstep.com>

* add quotes

Signed-off-by: Alex Boten <aboten@lightstep.com>

---------

Signed-off-by: Alex Boten <aboten@lightstep.com>
…etry#7166)

It wasn't picked up because of the `.yml` (not `.yaml`) extension.
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
@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 Feb 11, 2023
opentelemetrybot and others added 3 commits February 13, 2023 09:52
Bump go.opentelemetry.io/build-tools/checkdoc from 0.5.0 to 0.6.0 in /internal/tools
Bump go.opentelemetry.io/build-tools/chloggen from 0.5.0 to 0.6.0 in /internal/tools
Bump go.opentelemetry.io/build-tools/crosslink from 0.5.0 to 0.6.0 in /internal/tools
Bump go.opentelemetry.io/build-tools/multimod from 0.5.0 to 0.6.0 in /internal/tools
Bump go.opentelemetry.io/build-tools/semconvgen from 0.5.0 to 0.6.0 in /internal/tools
Bump golang.org/x/net from 0.5.0 to 0.6.0
Bump golang.org/x/sys from 0.4.0 to 0.5.0
Bump golang.org/x/sys from 0.4.0 to 0.5.0 in /cmd/otelcorecol
Bump golang.org/x/sys from 0.4.0 to 0.5.0 in /exporter/loggingexporter
Bump google.golang.org/grpc from 1.52.3 to 1.53.0
Bump google.golang.org/grpc from 1.52.3 to 1.53.0 in /exporter/otlpexporter
Bump google.golang.org/grpc from 1.52.3 to 1.53.0 in /exporter/otlphttpexporter
Bump google.golang.org/grpc from 1.52.3 to 1.53.0 in /pdata
Bump google.golang.org/grpc from 1.52.3 to 1.53.0 in /receiver/otlpreceiver
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
@xborder
Copy link
Author

xborder commented Feb 15, 2023

@codeboten From my understanding, there is not specific test suite for windows. The workflow you references just runs the tests on a windows container.

I only found 1 windows-specific test that tests the service change of status. In this PR case, it would require mocking the event viewer somehow and change the code to make stuff public in order to mock it.
Being something so specific to the OS and only when it runs as a window service, I find it somewhat hard to justify.

I'm not well-versed in the golang ways so let me know if I could improve it somehow.

frzifus and others added 4 commits February 15, 2023 06:52
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
When running as a windows service, the collector's logger zapcore.Core is replaced
by a customized zapcore.Core that writes the logs to the EventViewer ignoring what is
configured in the yaml.
Instead of replacing it, the PR creates a Tee that preserves the original Core and its
configuration, and adds the customized Core for EventViewer. This way logs are
duplicated and flushed by both Cores.
@github-actions github-actions bot removed the Stale label Feb 16, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2023

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 Mar 2, 2023
@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Patch coverage: 96.70% and project coverage change: +0.63 🎉

Comparison is base (1af31a0) 90.36% compared to head (beac561) 90.99%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7025      +/-   ##
==========================================
+ Coverage   90.36%   90.99%   +0.63%     
==========================================
  Files         243      293      +50     
  Lines       14598    14271     -327     
==========================================
- Hits        13191    12986     -205     
+ Misses       1138     1017     -121     
+ Partials      269      268       -1     
Impacted Files Coverage Δ
client/client.go 100.00% <ø> (ø)
cmd/builder/internal/builder/config.go 68.67% <ø> (ø)
cmd/otelcorecol/main.go 0.00% <0.00%> (ø)
component/config.go 87.50% <ø> (ø)
exporter/exporterhelper/logs.go 80.64% <ø> (ø)
exporter/exporterhelper/metrics.go 80.64% <ø> (ø)
exporter/exporterhelper/traces.go 80.95% <ø> (ø)
exporter/exportertest/nop_exporter.go 100.00% <ø> (ø)
otelcol/config.go 96.38% <0.00%> (ø)
pdata/internal/generated_wrapper_float64slice.go 100.00% <ø> (ø)
... and 132 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@github-actions github-actions bot removed the Stale label Mar 10, 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 Mar 25, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2023

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

@github-actions github-actions bot closed this Apr 9, 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.