-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[receiver/azuremonitor] Add support for azureauthextension #39658
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
Merged
atoulme
merged 39 commits into
open-telemetry:main
from
constanca-m:azuremonitor-authextension
May 14, 2025
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
e3fb879
Add support for azureauthextension
constanca-m 68973bc
Merge branch 'main' into azuremonitor-authextension
constanca-m 68f7a7d
make gotidy
constanca-m b4754e7
fix module version error
constanca-m e7d4e05
fix module version error
constanca-m a61af8d
Update go.sum
constanca-m b10a121
Merge branch 'main' into azuremonitor-authextension
constanca-m 51608a2
Merge remote-tracking branch 'origin/azuremonitor-authextension' into…
constanca-m afdcc0c
change `token_provider` to `credentials`
constanca-m c7d50da
change `token_provider` to `credentials`
constanca-m 356c20c
Add deprecate warning
constanca-m 2635e87
fix failing unit test
constanca-m b8a1b30
Merge branch 'main' into azuremonitor-authextension
constanca-m c2bd28a
make gotidy
constanca-m ffdebc2
Merge branch 'main' into azuremonitor-authextension
constanca-m fec9048
Use auth.authenticator component.ID
constanca-m e22fe39
./.github/workflows/scripts/check-collector-module-version.sh
constanca-m a7700c7
Update receiver/azuremonitorreceiver/README.md
constanca-m 0c0f917
Address comments
constanca-m 9dcf0aa
Merge branch 'main' into azuremonitor-authextension
constanca-m 2fcab1e
make gotidy
constanca-m 09f43f4
Run ./.github/workflows/scripts/check-collector-module-version.sh
constanca-m f168f86
Update receiver/azuremonitorreceiver/README.md
constanca-m ab2c7e4
Merge branch 'main' into azuremonitor-authextension
constanca-m b875e10
make gotidy
constanca-m 5504ce4
make gotidy
constanca-m 74e8e36
Merge branch 'main' into azuremonitor-authextension
constanca-m 3443493
make gotidy
constanca-m 701b7a8
run ./.github/workflows/scripts/check-collector-module-version.sh
constanca-m a17c799
make gotidy
constanca-m 3b71df3
Merge branch 'main' into azuremonitor-authextension
edmocosta 2a1c55f
Merge branch 'main' into azuremonitor-authextension
constanca-m 613a4f2
make gotidy
constanca-m 2026205
make gotidy
constanca-m 671c3ec
Merge branch 'main' into azuremonitor-authextension
constanca-m 7681a30
make gotidy
constanca-m 4a77bc0
Merge remote-tracking branch 'origin/azuremonitor-authextension' into…
constanca-m 0f9df1d
make gotidy
constanca-m 4727cd1
update deps
constanca-m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# 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. filelogreceiver) | ||
component: azuremonitorreceiver | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add support for azureauthextension as a token provider for azuremonitorreceiver. | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [39048] | ||
|
||
# (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] |
This file contains hidden or 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 hidden or 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 hidden or 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,132 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package azuremonitorreceiver | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/confmap/confmaptest" | ||
"go.opentelemetry.io/collector/confmap/xconfmap" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azuremonitorreceiver/internal/metadata" | ||
) | ||
|
||
func TestLoadConfig(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for that! So cool to see some tests of this quality for the config :) |
||
t.Parallel() | ||
|
||
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) | ||
require.NoError(t, err) | ||
|
||
tests := []struct { | ||
id component.ID | ||
expected component.Config | ||
expectedErr string | ||
}{ | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "valid_subscription_ids"), | ||
expected: func() component.Config { | ||
cfg := createDefaultConfig().(*Config) | ||
cfg.SubscriptionIDs = []string{"test"} | ||
cfg.Credentials = defaultCredentials | ||
return cfg | ||
}(), | ||
}, | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "valid_discover_subscription"), | ||
expected: func() component.Config { | ||
cfg := createDefaultConfig().(*Config) | ||
cfg.DiscoverSubscriptions = true | ||
cfg.Credentials = defaultCredentials | ||
return cfg | ||
}(), | ||
}, | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "missing_subscription"), | ||
expectedErr: errMissingSubscriptionIDs.Error(), | ||
}, | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "invalid_cloud"), | ||
expectedErr: errInvalidCloud.Error(), | ||
}, | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "missing_service_principal"), | ||
expectedErr: fmt.Sprintf( | ||
"%s; %s; %s", | ||
errMissingTenantID.Error(), | ||
errMissingClientID.Error(), | ||
errMissingClientSecret.Error(), | ||
), | ||
}, | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "missing_service_principal"), | ||
expectedErr: fmt.Sprintf( | ||
"%s; %s; %s", | ||
errMissingTenantID.Error(), | ||
errMissingClientID.Error(), | ||
errMissingClientSecret.Error(), | ||
), | ||
}, | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "missing_workload_identity"), | ||
expectedErr: fmt.Sprintf( | ||
"%s; %s; %s", | ||
errMissingTenantID.Error(), | ||
errMissingClientID.Error(), | ||
errMissingFedTokenFile.Error(), | ||
), | ||
}, | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "invalid_credentials"), | ||
expectedErr: `credentials "invalid" is not supported`, | ||
}, | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "valid_authenticator"), | ||
expected: func() component.Config { | ||
cfg := createDefaultConfig().(*Config) | ||
cfg.DiscoverSubscriptions = true | ||
cfg.Authentication = &AuthConfig{ | ||
AuthenticatorID: component.MustNewIDWithName("azureauth", "monitor"), | ||
} | ||
cfg.Credentials = "does-not-matter" | ||
return cfg | ||
}(), | ||
}, | ||
{ | ||
id: component.NewIDWithName(metadata.Type, "valid_authenticator_2"), | ||
expected: func() component.Config { | ||
cfg := createDefaultConfig().(*Config) | ||
cfg.DiscoverSubscriptions = true | ||
cfg.Authentication = &AuthConfig{ | ||
AuthenticatorID: component.MustNewID("azureauth"), | ||
} | ||
cfg.Credentials = "does-not-matter" | ||
return cfg | ||
}(), | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.id.Name(), func(t *testing.T) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() | ||
|
||
sub, err := cm.Sub(tt.id.String()) | ||
require.NoError(t, err) | ||
require.NoError(t, sub.Unmarshal(cfg)) | ||
|
||
err = xconfmap.Validate(cfg) | ||
if tt.expectedErr != "" { | ||
assert.ErrorContains(t, err, tt.expectedErr) | ||
} else { | ||
assert.NoError(t, err) | ||
assert.Equal(t, tt.expected, cfg) | ||
} | ||
}) | ||
} | ||
} |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you keep just TenantID at this place? Just a nit but this will be clearer when we'll remove the deprecated part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course