-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[receiver/azure_functions] Introduce new component #46584
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
andrzej-stencel
merged 17 commits into
open-telemetry:main
from
tetianakravchenko:azurefunctionsreceiver
Mar 15, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b4f2954
[receiver/azurefunctionsreceiver] Introduce new component
tetianakravchenko 9b9c5c8
add changelog record; fix linter issues
tetianakravchenko e5abc46
add config validation; address review comments
tetianakravchenko e21355b
Apply suggestions from code review
tetianakravchenko 4b2a9a0
Merge branch 'main' into azurefunctionsreceiver
tetianakravchenko f7eb49e
make auth configuration optional; use azure_encoding instead of azure…
tetianakravchenko 97e532e
follow naming convention for the receiver: rename to azure_functions
tetianakravchenko 26a565e
update changelog record and config to match new naming convention
tetianakravchenko 87ad208
Merge branch 'main' into azurefunctionsreceiver
tetianakravchenko b115d9b
Merge branch 'main' into azurefunctionsreceiver
andrzej-stencel 7cd9304
Merge branch 'main' into azurefunctionsreceiver
tetianakravchenko 121817e
Merge branch 'main' into azurefunctionsreceiver
andrzej-stencel 0d0f971
Merge branch 'main' into azurefunctionsreceiver
tetianakravchenko e8a0ed3
rerun make generate to fix tests
tetianakravchenko f39f550
Merge branch 'main' into azurefunctionsreceiver
andrzej-stencel 2afc171
Merge branch 'main' into pr/tetianakravchenko/46584
andrzej-stencel 16d7bba
make gotidy
andrzej-stencel 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
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: new_component | ||
|
|
||
| # The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog) | ||
| component: receiver/azure_functions | ||
|
|
||
| # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
| note: "Introduce new component to receive logs from Azure Functions" | ||
|
|
||
| # Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
| issues: [43507] | ||
|
|
||
| # (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: This change includes only overall structure, readme and configuration for the new component. | ||
|
|
||
| # 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: [] |
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
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
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
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 @@ | ||
| include ../../Makefile.Common |
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,84 @@ | ||
| # Azure Functions Receiver | ||
| <!-- status autogenerated section --> | ||
| # Azure Functions Receiver | ||
| | Status | | | ||
| | ------------- |-----------| | ||
| | Stability | [development]: logs | | ||
| | Distributions | [] | | ||
| | Issues | [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fazurefunctions) [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fazurefunctions) | | ||
| | Code coverage | [](https://app.codecov.io/gh/open-telemetry/opentelemetry-collector-contrib/tree/main/?components%5B0%5D=receiver_azurefunctions&displayType=list) | | ||
| | [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@jmacd](https://www.github.com/jmacd), [@MichaelKatsoulis](https://www.github.com/MichaelKatsoulis), [@constanca-m](https://www.github.com/constanca-m) | | ||
|
|
||
| [development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development | ||
| <!-- end autogenerated section --> | ||
|
|
||
| ## Overview | ||
|
|
||
| The Azure Functions receiver is an OpenTelemetry Collector receiver that integrates with Azure Functions as a custom handler. It receives logs from Azure Event Hubs via the Azure Functions runtime and converts them to OpenTelemetry format for further processing and export. | ||
|
|
||
| ## How It Works | ||
|
|
||
| The receiver is designed to operate as part of an Azure Functions custom handler: | ||
|
|
||
| 1. Azure Functions runtime consumes events from Azure Event Hubs (e.g. separate hubs for logs and metrics). | ||
| 2. The runtime sends HTTP POST requests to the receiver's endpoint `/logs`. | ||
| 3. The receiver decodes Azure Functions invoke requests containing Event Hub messages. | ||
| 4. Messages are converted to OpenTelemetry format. | ||
| 5. Data is forwarded to the configured pipeline consumers. | ||
|
|
||
| ## Configuration | ||
|
|
||
| The following receiver configuration parameters are supported. | ||
|
|
||
| | Name | Type | Description | | ||
| |------|------|-------------| | ||
| | `http` | confighttp.ServerConfig | **Required.** HTTP server settings (e.g. `endpoint: :9090`). Typically use `FUNCTIONS_CUSTOMHANDLER_PORT`. | | ||
| | `auth` | component.ID | Optional. Component ID of the extension that provides Azure authentication (e.g. token credential). | | ||
| | `logs.encoding` | component.ID | **Required.** Encoding extension ID for unmarshaling log records. | | ||
| | `include_invoke_metadata` | bool | Optional. When true, add Azure Functions invoke metadata to resource attributes. Default: false. | | ||
|
|
||
| Required fields must be set for the receiver to start. | ||
|
|
||
| ### Example configuration | ||
|
|
||
| ```yaml | ||
| receivers: | ||
| azure_functions: | ||
| # HTTP server configuration | ||
| http: | ||
| endpoint: :${env:FUNCTIONS_CUSTOMHANDLER_PORT:-9090} | ||
|
|
||
| # Logs configuration | ||
| logs: | ||
| # Encoding extension ID for log unmarshaling | ||
| # Must reference an encoding extension defined in the extensions section | ||
| encoding: azure_encoding | ||
|
|
||
| # Include Azure Functions invoke metadata in resource attributes | ||
| # When enabled, adds partition context and system metadata | ||
| include_invoke_metadata: true | ||
|
|
||
| extensions: | ||
| azureauth: | ||
| # Azure auth extension configuration | ||
| azure_encoding: | ||
| # Encoding extension configuration | ||
|
|
||
| service: | ||
| extensions: [azureauth, azure_encoding] | ||
| pipelines: | ||
| logs: | ||
| receivers: [azure_functions] | ||
| exporters: [otlp] | ||
| ``` | ||
|
|
||
| ## Supported Signal Decoders | ||
|
|
||
| - **Logs** (Primary support) - Logs are decoded using an encoding extension (typically `azure_encoding`) that converts Azure Resource Logs format to OpenTelemetry logs. | ||
| - **Metrics** (Future consideration) | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Deployed as an Azure Functions custom handler. | ||
| - Azure Functions host configuration (`host.json`) with custom handler settings. | ||
| - Event Hub trigger bindings configured in `function.json`. | ||
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,46 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package azurefunctionsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azurefunctionsreceiver" | ||
|
|
||
| import ( | ||
| "errors" | ||
|
|
||
| "go.opentelemetry.io/collector/component" | ||
| "go.opentelemetry.io/collector/config/confighttp" | ||
| ) | ||
|
|
||
| type Config struct { | ||
| // HTTP defines the HTTP server settings for the Azure Functions invoke endpoints. | ||
| HTTP *confighttp.ServerConfig `mapstructure:"http"` | ||
|
|
||
| // Logs defines configuration for log records received from Azure Functions. | ||
| Logs EncodingConfig `mapstructure:"logs"` | ||
|
|
||
| // Auth is the component.ID of the extension that provides Azure authentication | ||
| Auth component.ID `mapstructure:"auth"` | ||
|
|
||
| // IncludeInvokeMetadata, when true, adds Azure Functions invoke metadata to resource attributes. | ||
| IncludeInvokeMetadata bool `mapstructure:"include_invoke_metadata"` | ||
| } | ||
|
|
||
| // EncodingConfig holds the encoding extension configuration for a signal type. | ||
| type EncodingConfig struct { | ||
| // Encoding identifies the encoding of log records that triggered azure functions. | ||
| Encoding component.ID `mapstructure:"encoding"` | ||
| _ struct{} // Prevent unkeyed literal initialization | ||
| } | ||
|
|
||
| // Validate checks if the receiver configuration is valid. | ||
| func (cfg *Config) Validate() error { | ||
| var errs []error | ||
| if cfg.HTTP == nil || cfg.HTTP.NetAddr.Endpoint == "" { | ||
| errs = append(errs, errors.New("missing http server settings")) | ||
| } | ||
|
|
||
| if cfg.Logs.Encoding == (component.ID{}) { | ||
| errs = append(errs, errors.New("logs.encoding must be set")) | ||
| } | ||
|
|
||
| return errors.Join(errs...) | ||
| } |
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,76 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package azurefunctionsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azurefunctionsreceiver" | ||
|
|
||
| import ( | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| "go.opentelemetry.io/collector/component" | ||
| "go.opentelemetry.io/collector/config/confighttp" | ||
| "go.opentelemetry.io/collector/config/confignet" | ||
| "go.opentelemetry.io/collector/confmap/confmaptest" | ||
| "go.opentelemetry.io/collector/confmap/xconfmap" | ||
|
|
||
| "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azurefunctionsreceiver/internal/metadata" | ||
| ) | ||
|
|
||
| func TestLoadConfig(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) | ||
| require.NoError(t, err) | ||
|
|
||
| tests := []struct { | ||
| id component.ID | ||
| expected component.Config | ||
| expectedErrMessage string | ||
| }{ | ||
| { | ||
| id: component.NewID(metadata.Type), | ||
| expected: &Config{ | ||
| HTTP: &confighttp.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: "test:123", Transport: confignet.TransportTypeTCP}}, | ||
| Auth: component.MustNewID("azureauth"), | ||
| Logs: EncodingConfig{Encoding: component.MustNewID("azure_encoding")}, | ||
| }, | ||
| }, | ||
| { | ||
| id: component.NewIDWithName(metadata.Type, "no_auth"), | ||
| expected: &Config{ | ||
| HTTP: &confighttp.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: "test:123", Transport: confignet.TransportTypeTCP}}, | ||
| Logs: EncodingConfig{Encoding: component.MustNewID("azure_encoding")}, | ||
| }, | ||
| }, | ||
| { | ||
| id: component.NewIDWithName(metadata.Type, "no_http"), | ||
| expectedErrMessage: "missing http server settings", | ||
| }, | ||
| { | ||
| id: component.NewIDWithName(metadata.Type, "missing_logs_encoding"), | ||
| expectedErrMessage: "logs.encoding must be set", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.id.String(), func(t *testing.T) { | ||
| factory := NewFactory() | ||
| cfg := factory.CreateDefaultConfig() | ||
|
|
||
| sub, err := cm.Sub(tt.id.String()) | ||
| assert.NoError(t, err) | ||
| assert.NoError(t, sub.Unmarshal(cfg)) | ||
|
|
||
| err = xconfmap.Validate(cfg) | ||
| if tt.expectedErrMessage != "" { | ||
| assert.Error(t, err) | ||
| assert.EqualError(t, err, tt.expectedErrMessage) | ||
| return | ||
| } | ||
|
|
||
| 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
| 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 make mdatagen | ||
|
|
||
| // Package azurefunctionsreceiver receives logs and metrics from Azure Functions (custom handler). | ||
| package azurefunctionsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azurefunctionsreceiver" |
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,42 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package azurefunctionsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azurefunctionsreceiver" | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "go.opentelemetry.io/collector/component" | ||
| "go.opentelemetry.io/collector/config/confighttp" | ||
| "go.opentelemetry.io/collector/config/confignet" | ||
| "go.opentelemetry.io/collector/consumer" | ||
| "go.opentelemetry.io/collector/receiver" | ||
|
|
||
| "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azurefunctionsreceiver/internal/metadata" | ||
| ) | ||
|
|
||
| // NewFactory creates a factory for the Azure Functions receiver. | ||
| func NewFactory() receiver.Factory { | ||
| return receiver.NewFactory( | ||
| metadata.Type, | ||
| createDefaultConfig, | ||
| receiver.WithLogs(createLogsReceiver, metadata.LogsStability), | ||
| ) | ||
| } | ||
|
|
||
| func createDefaultConfig() component.Config { | ||
| return &Config{ | ||
| HTTP: &confighttp.ServerConfig{ | ||
| NetAddr: confignet.AddrConfig{Transport: confignet.TransportTypeTCP}, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func createLogsReceiver( | ||
| _ context.Context, | ||
| settings receiver.Settings, | ||
| cfg component.Config, | ||
| consumer consumer.Logs, | ||
| ) (receiver.Logs, error) { | ||
| return newFunctionsReceiver(cfg.(*Config), settings, consumer), nil | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.