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

[extension/googleclientauth] Add new component boilerplate scaffolding #31518

Merged
merged 25 commits into from
Mar 26, 2024
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
27 changes: 27 additions & 0 deletions .chloggen/gcp-auth-ext.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# 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. filelogreceiver)
component: googleclientauthextension

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add boilerplate for Google Client Auth Extension

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [31412]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ extension/encoding/jsonlogencodingextension/ @open-telemetry/collect
extension/encoding/otlpencodingextension/ @open-telemetry/collector-contrib-approvers @dao-jun @VihasMakwana
extension/encoding/textencodingextension/ @open-telemetry/collector-contrib-approvers @MovieStoreGuy @atoulme
extension/encoding/zipkinencodingextension/ @open-telemetry/collector-contrib-approvers @MovieStoreGuy @dao-jun
extension/googleclientauthextension/ @open-telemetry/collector-contrib-approvers @aabmass @dashpole @jsuereth @punya @damemi @psx95
extension/headerssetterextension/ @open-telemetry/collector-contrib-approvers @jpkrohling
extension/healthcheckextension/ @open-telemetry/collector-contrib-approvers @jpkrohling
extension/httpforwarderextension/ @open-telemetry/collector-contrib-approvers @atoulme @rmfitzpatrick
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ body:
- extension/encoding/otlpencoding
- extension/encoding/textencoding
- extension/encoding/zipkinencoding
- extension/googleclientauth
- extension/headerssetter
- extension/healthcheck
- extension/httpforwarder
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ body:
- extension/encoding/otlpencoding
- extension/encoding/textencoding
- extension/encoding/zipkinencoding
- extension/googleclientauth
- extension/headerssetter
- extension/healthcheck
- extension/httpforwarder
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ body:
- extension/encoding/otlpencoding
- extension/encoding/textencoding
- extension/encoding/zipkinencoding
- extension/googleclientauth
- extension/headerssetter
- extension/healthcheck
- extension/httpforwarder
Expand Down
1 change: 1 addition & 0 deletions extension/googleclientauthextension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
45 changes: 45 additions & 0 deletions extension/googleclientauthextension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Google Client Auth Extension
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [development] |
| Distributions | [] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aextension%2Fgoogleclientauth%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aextension%2Fgoogleclientauth) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aextension%2Fgoogleclientauth%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aextension%2Fgoogleclientauth) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@dashpole](https://www.github.com/dashpole), [@damemi](https://www.github.com/damemi), [@aabmass](https://www.github.com/aabmass), [@jsuereth](https://www.github.com/jsuereth), [@punya](https://www.github.com/punya), [@psx95](https://www.github.com/psx95) |

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
<!-- end autogenerated section -->
damemi marked this conversation as resolved.
Show resolved Hide resolved

This extension provides Google OAuth2 Client Credentials and Metadata for gRPC and http based exporters.

## Configuration

```yaml
extensions:
googleclientauth:

receivers:
otlp:
protocols:
grpc:

exporters:
otlp/withauth:
endpoint: 0.0.0.0:5000
ca_file: /tmp/certs/ca.pem
auth:
authenticator: googleclientauth

service:
extensions: [googleclientauth]
pipelines:
metrics:
receivers: [otlp]
processors: []
exporters: [otlp/withauth]
```

The following optional config fields are available:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: It might make sense to have the options defined before the example. Not a big deal either way though. 👍

- `project` - The Google Cloud Project telemetry is sent to if the `gcp.project.id` resource attribute is not set. If unspecified, this is determined using application default credentials.
- `scopes` - The oauth 2.0 [scopes](https://datatracker.ietf.org/doc/html/rfc6749#section-3.3) requested by the extension.
- `quota_project` - The [project](https://cloud.google.com/apis/docs/system-parameters) for quota and billing purposes. The caller must have `serviceusage.services.use` permission on the project.
12 changes: 12 additions & 0 deletions extension/googleclientauthextension/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package googleclientauthextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/googleclientauthextension"

// Config defines configuration for the Google client auth extension.
type Config struct {
}

func (cfg *Config) Validate() error {
return nil
}
7 changes: 7 additions & 0 deletions extension/googleclientauthextension/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

// Package googleclientauthextension implements an extension that provides authentication with Google Cloud.
package googleclientauthextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/googleclientauthextension"
27 changes: 27 additions & 0 deletions extension/googleclientauthextension/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

package googleclientauthextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/googleclientauthextension"

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/extension/auth"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/googleclientauthextension/internal/metadata"
)

func NewFactory() extension.Factory {
return extension.NewFactory(
metadata.Type,
func() component.Config { return &Config{} },
func(context.Context, extension.CreateSettings, component.Config) (extension.Extension, error) {
return auth.NewClient(), nil
},
metadata.ExtensionStability,
)
}
42 changes: 42 additions & 0 deletions extension/googleclientauthextension/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions extension/googleclientauthextension/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/extension/googleclientauthextension

go 1.21

exclude github.com/knadh/koanf v1.5.0

require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/collector/confmap v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/collector/extension v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/collector/extension/auth v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/otel/metric v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
go.uber.org/goleak v1.3.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
github.com/knadh/koanf/v2 v2.1.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.96.1-0.20240306115632-b2693620eff6 // indirect
go.opentelemetry.io/collector/pdata v1.3.1-0.20240306115632-b2693620eff6 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.46.0 // indirect
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading