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

update deps to 0.42.0 and provide double dollar config source parsing compatibility #1099

Merged
merged 2 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

## Unreleased

This Splunk OpenTelemetry Collector release includes changes from the [opentelemetry-collector v0.42.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.42.0) and the [opentelemetry-collector-contrib v0.42.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.42.0) releases.

### 🛑 Breaking changes 🛑

- This version adopts OpenTelemetry Core version 0.42.0, and in doing so the configuration parsing process has changed slightly. The Splunk OpenTelemetry Collector used to [evaluate user configuration twice](https://github.com/signalfx/splunk-otel-collector/issues/628) and this required escaping desired `$` literals with an additional `$` character to prevent unwanted environment variable expansion. This version no longer doubly evaluates configuration so any `$$` instances in your configuration as a workaround should be updated to `$`. [Config source directives](./internal/configsource) that include an additional `$` are provided with a temporary, backward-compatible `$${config_source:value}` and `$$config_source:value` parsing rule controlled by `SPLUNK_DOUBLE_DOLLAR_CONFIG_SOURCE_COMPATIBLE` environment variable (default `"true"`) to migrate them to single `$` usage to continue supporting the updating configs from [#930](https://github.com/signalfx/splunk-otel-collector/pull/930) and [#935](https://github.com/signalfx/splunk-otel-collector/pull/935). This functionality will be removed in a future release (#1099)

### 🚀 New components 🚀

- [`docker_observer`](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/dockerobserver) to detect and create container endpoints, to be used with the [`receiver_creator`](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/receivercreator).
- [`docker_observer`](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/dockerobserver) to detect and create container endpoints, to be used with the [`receiver_creator`](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/receivercreator) (#1044)

## v0.41.0

Expand Down
34 changes: 22 additions & 12 deletions cmd/otelcol/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package main

import (
"bytes"
"flag"
"fmt"
"io"
Expand All @@ -29,6 +28,7 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configmapprovider"
"go.opentelemetry.io/collector/config/configunmarshaler"
"go.opentelemetry.io/collector/service"
"go.uber.org/zap"

Expand Down Expand Up @@ -82,31 +82,38 @@ func main() {
Version: version.Version,
}

parserProvider := configprovider.NewConfigSourceParserProvider(
newBaseParserProvider(),
configMapProviderFromConfigSources := configprovider.NewConfigSourceConfigMapProvider(
baseConfigMapProviders(),
zap.NewNop(), // The service logger is not available yet, setting it to NoP.
info,
configsources.Get()...,
)

var configMapConverters []service.ConfigMapConverterFunc

const noConvertConfigFlag = "--no-convert-config"
if hasFlag(noConvertConfigFlag) {
// the collector complains about this flag if we don't remove it
removeFlag(&os.Args, noConvertConfigFlag)
} else {
parserProvider = configconverter.ParserProvider(
parserProvider,
configMapConverters = append(configMapConverters,
configconverter.RemoveBallastKey,
configconverter.MoveOTLPInsecureKey,
configconverter.MoveHecTLS,
configconverter.RenameK8sTagger,
)
}

serviceConfigProvider := service.NewConfigProvider(
[]configmapprovider.Provider{configMapProviderFromConfigSources},
configMapConverters,
configunmarshaler.NewDefault(),
)

serviceParams := service.CollectorSettings{
BuildInfo: info,
Factories: factories,
ConfigMapProvider: parserProvider,
BuildInfo: info,
Factories: factories,
ConfigProvider: serviceConfigProvider,
}

if err := run(serviceParams); err != nil {
Expand Down Expand Up @@ -370,8 +377,8 @@ func setDefaultEnvVars() {
}
}

// Returns a ParserProvider that reads configuration YAML from an environment variable when applicable.
func newBaseParserProvider() configmapprovider.Provider {
// Returns a []configmapprovider.Provider for reading from yaml env var or config path and set properties
func baseConfigMapProviders() []configmapprovider.Provider {
var configPath string
var ok bool
if ok, configPath = getKeyValue(os.Args[1:], "--config"); !ok {
Expand All @@ -380,10 +387,13 @@ func newBaseParserProvider() configmapprovider.Provider {
configYaml := os.Getenv(configYamlEnvVarName)

if configPath == "" && configYaml != "" {
return configmapprovider.NewExpand(configmapprovider.NewInMemory(bytes.NewBufferString(configYaml)))
return []configmapprovider.Provider{configmapprovider.NewEnv(configYamlEnvVarName)}
}

return configmapprovider.NewDefault(configPath, getSetProperties())
return []configmapprovider.Provider{
configmapprovider.NewFile(configPath),
configmapprovider.NewProperties(getSetProperties()),
}
}

func runInteractive(settings service.CollectorSettings) error {
Expand Down
Loading