-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
…tor into consumererror_tidy
- Loading branch information
Showing
16 changed files
with
143 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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 configsource | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// ConfigSource is the interface to be implemented by objects used by the collector | ||
// to retrieve external configuration information. | ||
type ConfigSource interface { | ||
// NewSession must create a Session object that will be used to inject data into | ||
// a configuration. | ||
// | ||
// The Session object should use its creation according to their ConfigSource needs: | ||
// lock resources, suspend background tasks, etc. An implementation, for instance, | ||
// can use the creation of the Session object to prevent torn configurations, | ||
// by acquiring a lock (or some other mechanism) that prevents concurrent changes to the | ||
// configuration during the middle of a session. | ||
// | ||
// The code managing the returned Session object must guarantee that the object is not used | ||
// concurrently. | ||
NewSession(ctx context.Context) (Session, error) | ||
} | ||
|
||
// Session is the interface used to inject configuration data from a ConfigSource. A Session | ||
// object is created from a ConfigSource. The code using Session objects must guarantee that | ||
// methods of a single instance are not called concurrently. | ||
type Session interface { | ||
// Apply goes to the configuration source, and according to the specified selector and | ||
// parameters retrieves a configuration value that is injected into the configuration. | ||
// | ||
// The selector is a string that is required on all invocations, the params are optional. | ||
Apply(ctx context.Context, selector string, params interface{}) (interface{}, error) | ||
|
||
// Close signals that the object won't be used anymore to inject data into a configuration. | ||
// Each Session object should use this call according to their needs: release resources, | ||
// close communication channels, etc. | ||
Close(ctx context.Context) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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 builder | ||
|
||
import ( | ||
"go.uber.org/zap" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
) | ||
|
||
// hostWrapper adds behavior on top of the component.Host being passed when starting the built components. | ||
type hostWrapper struct { | ||
component.Host | ||
*zap.Logger | ||
} | ||
|
||
func newHostWrapper(host component.Host, logger *zap.Logger) component.Host { | ||
return &hostWrapper{ | ||
host, | ||
logger, | ||
} | ||
} | ||
|
||
func (hw *hostWrapper) ReportFatalError(err error) { | ||
// The logger from the built component already identifies the component. | ||
hw.Logger.Error("Component fatal error", zap.Error(err)) | ||
hw.Host.ReportFatalError(err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 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 builder | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"go.uber.org/zap" | ||
|
||
"go.opentelemetry.io/collector/component/componenttest" | ||
) | ||
|
||
func Test_newHostWrapper(t *testing.T) { | ||
hw := newHostWrapper(componenttest.NewNopHost(), zap.NewNop()) | ||
hw.ReportFatalError(errors.New("test error")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters