forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ID to context to trace requests.
Fix go.mod name.
- Loading branch information
Showing
10 changed files
with
247 additions
and
109 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 |
---|---|---|
@@ -1,27 +1,33 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package awsmiddleware // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/awsmiddleware" | ||
package awsmiddleware // import "github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware" | ||
|
||
import ( | ||
"fmt" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
) | ||
|
||
// Config defines the configuration for an AWS Middleware extension. | ||
type Config struct { | ||
// MiddlewareID is the ID of the Middleware extension. | ||
MiddlewareID component.ID `mapstructure:"middleware"` | ||
} | ||
type ID = component.ID | ||
|
||
// GetMiddleware retrieves the extension implementing Middleware based on the MiddlewareID. | ||
func (c Config) GetMiddleware(extensions map[component.ID]component.Component) (Middleware, error) { | ||
if ext, found := extensions[c.MiddlewareID]; found { | ||
if mw, ok := ext.(Middleware); ok { | ||
return mw, nil | ||
// getMiddleware retrieves the extension implementing Middleware based on the middlewareID. | ||
func getMiddleware(extensions map[component.ID]component.Component, middlewareID ID) (Middleware, error) { | ||
if extension, found := extensions[middlewareID]; found { | ||
if middleware, ok := extension.(Middleware); ok { | ||
return middleware, nil | ||
} | ||
return nil, errNotMiddleware | ||
} | ||
return nil, fmt.Errorf("failed to resolve AWS client handler %q: %w", c.MiddlewareID, errNotFound) | ||
return nil, fmt.Errorf("failed to resolve AWS middleware %q: %w", middlewareID, errNotFound) | ||
} | ||
|
||
// GetConfigurer retrieves the extension implementing Middleware based on the middlewareID and | ||
// wraps it in a Configurer. | ||
func GetConfigurer(extensions map[component.ID]component.Component, middlewareID ID) (*Configurer, error) { | ||
middleware, err := getMiddleware(extensions, middlewareID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return NewConfigurer(middleware), nil | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.