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
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
a88ca9f
Enable service logging options when running as windows service
xborder Jan 25, 2023
9e4b354
Remove unnecessary interface in service/nodes.go (#7013)
djaglowski Jan 25, 2023
f616fab
Deprecate Apply in favor of Set (#7018)
bogdandrutu Jan 25, 2023
6f1cbd8
Add the httpsprovider component (#6683)
rapphil Jan 25, 2023
b03b046
Deprecate RegistryOption in favor of RegisterOption (#7012)
bogdandrutu Jan 25, 2023
af15118
Remove deprecated featuregate.GetRegistry (#7011)
bogdandrutu Jan 25, 2023
ef609c2
Increase components test in the builder generated code (#7027)
bogdandrutu Jan 26, 2023
12c782d
Add component node build methods (#7026)
djaglowski Jan 26, 2023
af2d662
Fix incorrect key used for receiver logger datatype attribute (#7034)
Aneurysm9 Jan 26, 2023
c90afb4
Add connectors readme (#7035)
djaglowski Jan 26, 2023
8d4b9d5
Add entry point to build graph-based pipelines (#7023)
djaglowski Jan 26, 2023
955d477
[chore] remove ghr (#7038)
Jan 26, 2023
286f731
[chore] update release script to fail on error (#7036)
Jan 26, 2023
30c2e7d
[chore] [pdata] Update godoc comments of pcommon functions (#7039)
dmitryax Jan 27, 2023
6723312
[chore] update documentation for releasing contrib (#7037)
Jan 27, 2023
b771d13
Change API to be a bit more go friendly. (#7040)
bogdandrutu Jan 27, 2023
cf9c829
Deprecate featuregate.Registry.List in favor of Visit. (#7041)
bogdandrutu Jan 27, 2023
504a00b
[chore] update release schedule (#7046)
Jan 27, 2023
e520829
Add private method to GrpcServer interface, disallow direct implement…
bogdandrutu Jan 27, 2023
cdc9e15
Allow configuration of fields, RandomizationFactor and Multiplier, fo…
Gabrielopesantos Jan 27, 2023
5f1733a
[chore] remove duplicate code in consumertest (#7049)
bogdandrutu Jan 27, 2023
ea2e6e3
[chore] dependabot updates Mon Jan 30 02:01:43 UTC 2023 (#7074)
opentelemetrybot Jan 30, 2023
6896a37
Document ability to use config providers inside config (#7032)
jpkrohling Jan 30, 2023
de4867f
[pdata] Do not wrap orig fields when it's not required (#7081)
dmitryax Jan 30, 2023
26bd7b2
[chore] use standard hex.EncodedLen instead of manually multiply (#7082)
bogdandrutu Jan 30, 2023
a2f0153
[chore] replace the usage of interface{} with any (#7053)
bogdandrutu Jan 30, 2023
fe3b4f8
[chore] [pdata] Split Value/Map/Slice into separate files (#7083)
dmitryax Jan 31, 2023
202c030
Add support for concatenating multiple embedded uris, or uris with ot…
bogdandrutu Jan 31, 2023
fcd68be
[chore] [pdata] Split generated code into more files (#7084)
dmitryax Jan 31, 2023
bdf63b7
Revert "Revert "Fix: Force usage of case-sensitive keys in configurat…
gbbr Jan 31, 2023
83dfe09
[chore] [pdata] Split internal/wrapper_common.go (#7087)
dmitryax Jan 31, 2023
272ebe6
Add shellcheck GitHub Actions workflow (#6870)
PiotrLewandowski323 Jan 31, 2023
c0a08e3
add ldflags builder cmd option (#6946)
kristinapathak Feb 1, 2023
3f73651
[chore] [pdata] Move constants to separate files (#7092)
dmitryax Feb 2, 2023
83599a7
Rename pipelineSettings fields with Builder (#7093)
djaglowski Feb 2, 2023
969b9ac
Simplify forward connector by removing sharedcomponent (#7096)
djaglowski Feb 2, 2023
c641c05
[pdata] Deprecate [Metrics|Logs|Traces].MoveTo methods (#7091)
dmitryax Feb 2, 2023
84c3d00
Remove deprecated pcommon.Map.Sort (#7028)
bogdandrutu Feb 2, 2023
297e391
Instrument proctelemetry.ProcessMetrics (#6886)
moh-osman3 Feb 2, 2023
33e5265
[chore] [pdata] Simplify EnsureCapacity tests (#7099)
dmitryax Feb 2, 2023
3c791d8
[chore] Update .gitignore for proto (#7100)
dmitryax Feb 3, 2023
490fd6a
Add full component graph build (#7045)
djaglowski Feb 3, 2023
c3d5b3b
Add graph-based GetExporters (#7108)
djaglowski Feb 3, 2023
93bc338
Disambiguate component ID in 'connectortest' package (#7110)
djaglowski Feb 3, 2023
a8cfb51
[chore] [pdata] Fix the generated tests for slices (#7112)
dmitryax Feb 3, 2023
da09040
[chore] [pdata] Move generator template fields to dedicated methods (…
dmitryax Feb 3, 2023
56fc8f2
[chore] [pdata] Combine slice templates in the generator (#7103)
dmitryax Feb 4, 2023
16c851d
Added guidelines for getter and setter Method. (#7113)
Abhishek-569 Feb 4, 2023
0f6a174
[chore] [pdata] Add test coverage for slices Sort method (#7115)
dmitryax Feb 4, 2023
7ae79f0
Update connectors flag and documentation (#7114)
djaglowski Feb 4, 2023
eaca119
[capabilityconsumer]: If the consumer has already the desired capabil…
bogdandrutu Feb 5, 2023
b4f81e3
Add graph-based implementation of HandleZPages (#7109)
djaglowski Feb 5, 2023
4815d7b
Bump ludeeus/action-shellcheck from 1.1.0 to 2.0.0 (#7123)
dependabot[bot] Feb 6, 2023
e42aad4
Bump github.com/golangci/golangci-lint in /internal/tools (#7120)
dependabot[bot] Feb 6, 2023
3d54789
dependabot updates Mon Feb 6 03:02:30 UTC 2023 (#7125)
opentelemetrybot Feb 6, 2023
e544eaf
[chore] use generics to avoid map copy (#7118)
bogdandrutu Feb 6, 2023
b8ca836
Split graph based pipelines implementation from connectors functional…
bogdandrutu Feb 6, 2023
e815d44
Connectors comment typo (#7127)
djaglowski Feb 6, 2023
29add1d
Update forward connector readme (#7128)
djaglowski Feb 6, 2023
6f69f62
Connectors readme typo (#7126)
djaglowski Feb 6, 2023
ede9e0a
[memorylimiter] Fix cgroups parsing (#6825)
povilasv Feb 6, 2023
d587e1d
[chore] fix chlog-update format (#7141)
Feb 6, 2023
f7af599
Revert "[memorylimiter] Fix cgroups parsing (#6825)" (#7142)
bogdandrutu Feb 6, 2023
1ca481b
[chore] update chlog update call (#7144)
Feb 6, 2023
e769012
Fix API to be compatible with flagset, missed the comment initially (…
bogdandrutu Feb 7, 2023
faf5a57
Bump otel-go to latest (#7149)
bogdandrutu Feb 7, 2023
a0d1e62
Bump otel-go/contrib to latest (#7154)
bogdandrutu Feb 7, 2023
7cf999e
[chore] Prepare release 0.71.0/1.0.0-rc5 (#7155)
opentelemetrybot Feb 8, 2023
6e6597e
[chore] [receiver/otlp] Remove unused constants and update a doc line…
dmitryax Feb 8, 2023
ead716a
remove go 1.18 support, bump minimum to go 1.19 and add testing for 1…
Feb 8, 2023
e2a6cd7
[chore] Move an abandoned .chloggen entry to CHANGELOG.md (#7166)
dmitryax Feb 8, 2023
2476ab9
Revert "Revert "[memorylimiter] Fix cgroups parsing (#6825)" (#7142)"…
povilasv Feb 9, 2023
08985c4
[pdata] Remove deprecated `[Metrics|Traces|Logs]MoveTo` methods (#7165)
dmitryax Feb 9, 2023
72a44b1
Remove deprecated funcs in featuregate. (#7173)
bogdandrutu Feb 11, 2023
8bf3885
dependabot updates Mon Feb 13 17:07:47 UTC 2023 (#7194)
opentelemetrybot Feb 13, 2023
1a2d0cc
Fix typo in exporterhelper (#7197)
panzhongxian Feb 15, 2023
b04c8d9
add semantic conventions for specification v1.17.0 (#7171)
frzifus Feb 15, 2023
69dd391
add semantic conventions for specification v1.18.0 (#7169)
frzifus Feb 15, 2023
90f3233
Enable service logging options when running as windows service
xborder Jan 25, 2023
dd4ac30
rebasing from main
xborder Feb 15, 2023
beac561
fixing code after rebase
xborder Feb 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add the httpsprovider component (#6683)
* 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>
  • Loading branch information
3 people authored Jan 25, 2023
commit 6f1cbd851e6212d2a973679aea73cae73a8c04df
16 changes: 16 additions & 0 deletions .chloggen/add-https-httpprovider.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: new_component

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: httpsprovider

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add the httpsprovider. This component allows the collector to fetch configurations from web servers using the HTTPS protocol.

# One or more tracking issues or pull requests related to the change
issues: [6683]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
61 changes: 5 additions & 56 deletions confmap/provider/httpprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,15 @@
package httpprovider // import "go.opentelemetry.io/collector/confmap/provider/httpprovider"

import (
"context"
"fmt"
"io"
"net/http"
"strings"

"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/provider/internal"
)

const (
schemeName = "http"
"go.opentelemetry.io/collector/confmap/provider/internal/configurablehttpprovider"
)

type provider struct {
client http.Client
}

// New returns a new confmap.Provider that reads the configuration from a file.
//
// This Provider supports "http" scheme, and can be called with a "uri" that follows:
// New returns a new confmap.Provider that reads the configuration from a http server.
//
// One example for http-uri be like: http://localhost:3333/getConfig
// This Provider supports "http" scheme.
//
// Examples:
// `http://localhost:3333/getConfig` - (unix, windows)
// One example for HTTP URI is: http://localhost:3333/getConfig
func New() confmap.Provider {
return &provider{client: http.Client{}}
}

func (fmp *provider) Retrieve(_ context.Context, uri string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) {
if !strings.HasPrefix(uri, schemeName+":") {
return nil, fmt.Errorf("%q uri is not supported by %q provider", uri, schemeName)
}

// send a HTTP GET request
resp, err := fmp.client.Get(uri)
if err != nil {
return nil, fmt.Errorf("unable to download the file via HTTP GET for uri %q, with err: %w ", uri, err)
}
defer resp.Body.Close()

// check the HTTP status code
if resp.StatusCode != 200 {
return nil, fmt.Errorf("404: resource didn't exist, fail to read the response body from uri %q", uri)
}

// read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("fail to read the response body from uri %q, with err: %w ", uri, err)
}

return internal.NewRetrievedFromYAML(body)
}

func (*provider) Scheme() string {
return schemeName
}

func (*provider) Shutdown(context.Context) error {
return nil
return configurablehttpprovider.New(configurablehttpprovider.HTTPScheme)
}
89 changes: 1 addition & 88 deletions confmap/provider/httpprovider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,101 +16,14 @@ package httpprovider

import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/confmap/confmaptest"
)

func TestFunctionalityDownloadFileHTTP(t *testing.T) {
fp := New()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
f, err := os.ReadFile("./testdata/otel-config.yaml")
if err != nil {
w.WriteHeader(404)
_, innerErr := w.Write([]byte("Cannot find the config file"))
if innerErr != nil {
fmt.Println("Write failed: ", innerErr)
}
return
}
w.WriteHeader(200)
_, err = w.Write(f)
if err != nil {
fmt.Println("Write failed: ", err)
}
}))
defer ts.Close()
_, err := fp.Retrieve(context.Background(), ts.URL, nil)
assert.NoError(t, err)
assert.NoError(t, fp.Shutdown(context.Background()))
}

func TestUnsupportedScheme(t *testing.T) {
fp := New()
_, err := fp.Retrieve(context.Background(), "https://...", nil)
assert.Error(t, err)
assert.NoError(t, fp.Shutdown(context.Background()))
}

func TestEmptyURI(t *testing.T) {
fp := New()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(400)
}))
defer ts.Close()
_, err := fp.Retrieve(context.Background(), ts.URL, nil)
require.Error(t, err)
require.NoError(t, fp.Shutdown(context.Background()))
}

func TestRetrieveFromShutdownServer(t *testing.T) {
fp := New()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
ts.Close()
_, err := fp.Retrieve(context.Background(), ts.URL, nil)
assert.Error(t, err)
require.NoError(t, fp.Shutdown(context.Background()))
}

func TestNonExistent(t *testing.T) {
fp := New()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(404)
}))
defer ts.Close()
_, err := fp.Retrieve(context.Background(), ts.URL, nil)
assert.Error(t, err)
require.NoError(t, fp.Shutdown(context.Background()))
}

func TestInvalidYAML(t *testing.T) {
fp := New()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
_, err := w.Write([]byte("wrong : ["))
if err != nil {
fmt.Println("Write failed: ", err)
}
}))
defer ts.Close()
_, err := fp.Retrieve(context.Background(), ts.URL, nil)
assert.Error(t, err)
require.NoError(t, fp.Shutdown(context.Background()))
}

func TestScheme(t *testing.T) {
func TestSupportedScheme(t *testing.T) {
fp := New()
assert.Equal(t, "http", fp.Scheme())
require.NoError(t, fp.Shutdown(context.Background()))
}

func TestValidateProviderScheme(t *testing.T) {
assert.NoError(t, confmaptest.ValidateProviderScheme(New()))
}
18 changes: 18 additions & 0 deletions confmap/provider/httpsprovider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
### What is the httpsprovider?

An implementation of `confmap.Provider` for HTTPS (httpsprovider) allows OTEL Collector to use the HTTPS protocol to
load configuration files stored in web servers.

Expected URI format:
- https://...

### Prerequistes

You need to setup a HTTP server with support to HTTPS. The server must have a certificate that can be validated in the
host running the collector using system root certificates.

### Configuration

At this moment, this component only support communicating with servers whose certificate can be verified using the root
CA certificates installed in the system. The process of adding more root CA certificates to the system is operating
system dependent. For Linux, please refer to the `update-ca-trust` command.
30 changes: 30 additions & 0 deletions confmap/provider/httpsprovider/provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package httpsprovider // import "go.opentelemetry.io/collector/confmap/provider/httpsprovider"

import (
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/provider/internal/configurablehttpprovider"
)

// New returns a new confmap.Provider that reads the configuration from a https server.
//
// This Provider supports "https" scheme. One example of an HTTPS URI is: https://localhost:3333/getConfig
//
// To add extra CA certificates you need to install certificates in the system pool. This procedure is operating system
// dependent. E.g.: on Linux please refer to the `update-ca-trust` command.
func New() confmap.Provider {
return configurablehttpprovider.New(configurablehttpprovider.HTTPSScheme)
}
26 changes: 26 additions & 0 deletions confmap/provider/httpsprovider/provider_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package httpsprovider

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestSupportedScheme(t *testing.T) {
fp := New()
assert.Equal(t, "https", fp.Scheme())
}
Loading