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 support for concatenating multiple embedded uris, or uris with ot…
…her string parts (#7055)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Jan 31, 2023
commit 202c03010605012f00b01c45ff90b1a0afd46c01
11 changes: 11 additions & 0 deletions .chloggen/supportconcat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support to resolve embedded uris inside a string, concatenate results.

# One or more tracking issues or pull requests related to the change
issues: [6932]
5 changes: 5 additions & 0 deletions confmap/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ func TestNewRetrievedWithOptions(t *testing.T) {
assert.Equal(t, New(), retMap)
assert.Equal(t, want, ret.Close(context.Background()))
}

func TestNewRetrievedUnsupportedType(t *testing.T) {
_, err := NewRetrieved(errors.New("my error"))
require.Error(t, err)
}
88 changes: 66 additions & 22 deletions confmap/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,31 @@ import (
"context"
"errors"
"fmt"
"reflect"
"regexp"
"strconv"
"strings"

"go.uber.org/multierr"

"go.opentelemetry.io/collector/featuregate"
)

// schemePattern defines the regexp pattern for scheme names.
// Scheme name consist of a sequence of characters beginning with a letter and followed by any
// combination of letters, digits, plus ("+"), period ("."), or hyphen ("-").
const schemePattern = `[A-Za-z][A-Za-z0-9+.-]+`

var (
// follows drive-letter specification:
// https://datatracker.ietf.org/doc/html/draft-kerwin-file-scheme-07.html#section-2.2
driverLetterRegexp = regexp.MustCompile("^[A-z]:")

// Scheme name consist of a sequence of characters beginning with a letter and followed by any
// combination of letters, digits, plus ("+"), period ("."), or hyphen ("-").
// Need to match new line as well in the OpaqueValue, so setting the "s" flag. See https://pkg.go.dev/regexp/syntax.
locationRegexp = regexp.MustCompile(`(?s:^(?P<Scheme>[A-Za-z][A-Za-z0-9+.-]+):(?P<OpaqueValue>.*)$)`)
uriRegexp = regexp.MustCompile(`(?s:^(?P<Scheme>` + schemePattern + `):(?P<OpaqueValue>.*)$)`)

// embeddedURI matches "embedded" provider uris into a string value.
embeddedURI = regexp.MustCompile(`\${` + schemePattern + `:.*?}`)

errTooManyRecursiveExpansions = errors.New("too many recursive expansions")
)
Expand All @@ -43,7 +51,7 @@ var (
var expandEnabledGauge = featuregate.GlobalRegistry().MustRegister(
"confmap.expandEnabled",
featuregate.StageBeta,
featuregate.WithRegisterDescription("controls whether expending embedded external config providers URIs"))
featuregate.WithRegisterDescription("controls whether expanding embedded external config providers URIs"))

// Resolver resolves a configuration as a Conf.
type Resolver struct {
Expand Down Expand Up @@ -168,6 +176,7 @@ func (mr *Resolver) Resolve(ctx context.Context) (*Conf, error) {
}
retMap = NewFromStringMap(cfgMap)
}

// Apply the converters in the given order.
for _, confConv := range mr.converters {
if err := confConv.Convert(ctx, retMap); err != nil {
Expand Down Expand Up @@ -234,26 +243,44 @@ func (mr *Resolver) expandValueRecursively(ctx context.Context, value any) (any,
func (mr *Resolver) expandValue(ctx context.Context, value any) (any, bool, error) {
switch v := value.(type) {
case string:
// If it doesn't have the format "${scheme:opaque}" no need to expand.
if !strings.HasPrefix(v, "${") || !strings.HasSuffix(v, "}") || !strings.Contains(v, ":") {
return value, false, nil
}
lURI, err := newLocation(v[2 : len(v)-1])
if err != nil {
// Cannot return error, since a case like "${HOST}:${PORT}" is invalid location,
// but is supported in the legacy implementation.
// If no embedded "uris" no need to expand. embeddedURI regexp matches uriRegexp as well.
if !embeddedURI.MatchString(v) {
return value, false, nil
}
if strings.Contains(lURI.opaqueValue, "$") {
return nil, false, fmt.Errorf("the uri %q contains unsupported characters ('$')", lURI.asString())
}
ret, err := mr.retrieveValue(ctx, lURI)
if err != nil {
return nil, false, err

// If the value is a single URI, then the return value can be anything.
// This is the case `foo: ${file:some_extra_config.yml}`.
if embeddedURI.FindString(v) == v {
return mr.expandStringURI(ctx, v)
}
mr.closers = append(mr.closers, ret.Close)
val, err := ret.AsRaw()
return val, true, err

// If the URI is embedded into the string, return value must be a string, and we have to concatenate all strings.
var nerr error
var nchanged bool
nv := embeddedURI.ReplaceAllStringFunc(v, func(s string) string {
ret, changed, err := mr.expandStringURI(ctx, s)
nchanged = nchanged || changed
nerr = multierr.Append(nerr, err)
if err != nil {
return ""
}
// This list must be kept in sync with checkRawConfType.
val := reflect.ValueOf(ret)
switch val.Kind() {
case reflect.String:
return val.String()
case reflect.Int, reflect.Int32, reflect.Int64:
return strconv.FormatInt(val.Int(), 10)
case reflect.Float32, reflect.Float64:
return strconv.FormatFloat(val.Float(), 'f', -1, 64)
case reflect.Bool:
return strconv.FormatBool(val.Bool())
default:
nerr = multierr.Append(nerr, fmt.Errorf("expanding %v, expected string value type, got %T", s, ret))
return v
}
})
return nv, nchanged, nerr
case []any:
nslice := make([]any, 0, len(v))
nchanged := false
Expand Down Expand Up @@ -282,6 +309,23 @@ func (mr *Resolver) expandValue(ctx context.Context, value any) (any, bool, erro
return value, false, nil
}

func (mr *Resolver) expandStringURI(ctx context.Context, uri string) (any, bool, error) {
lURI, err := newLocation(uri[2 : len(uri)-1])
if err != nil {
return nil, false, err
}
if strings.Contains(lURI.opaqueValue, "$") {
return nil, false, fmt.Errorf("the uri %q contains unsupported characters ('$')", lURI.asString())
}
ret, err := mr.retrieveValue(ctx, lURI)
if err != nil {
return nil, false, err
}
mr.closers = append(mr.closers, ret.Close)
val, err := ret.AsRaw()
return val, true, err
}

type location struct {
scheme string
opaqueValue string
Expand All @@ -292,7 +336,7 @@ func (c location) asString() string {
}

func newLocation(uri string) (location, error) {
submatches := locationRegexp.FindStringSubmatch(uri)
submatches := uriRegexp.FindStringSubmatch(uri)
if len(submatches) != 3 {
return location{}, fmt.Errorf("invalid uri: %q", uri)
}
Expand Down
Loading