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

[Feature][exporter/azuredataexplorerexporter] Exporter helper support #27272

Merged
merged 26 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
79b9fc2
export helper configuration support added
asaharn Sep 29, 2023
f1f851f
Added changes for logs export helper
asaharn Sep 29, 2023
a3dae38
Updated readme file
asaharn Sep 29, 2023
300a85b
Merge branch 'main' into feature/ingestionretry
asaharn Sep 29, 2023
839c8b5
added change log file
asaharn Oct 2, 2023
2a3f134
Merge branch 'feature/ingestionretry' of https://github.com/asaharn/o…
asaharn Oct 2, 2023
4d172de
go get result
asaharn Oct 2, 2023
a86d337
Merge branch 'main' into feature/ingestionretry
asaharn Oct 2, 2023
fd40eb1
Test cases change
asaharn Oct 3, 2023
d959c19
Merge branch 'feature/ingestionretry' of https://github.com/asaharn/o…
asaharn Oct 3, 2023
c539886
Merge branch 'main' into feature/ingestionretry
asaharn Oct 3, 2023
785c27f
Merge branch 'main' into feature/ingestionretry
asaharn Oct 4, 2023
6bbcc85
gotidy change
asaharn Oct 4, 2023
6ca1914
* Fix lint error
ag-ramachandran Oct 4, 2023
6f1fdfc
Merge branch 'main' into feature/ingestionretry
asaharn Oct 4, 2023
e5230d1
readme change
asaharn Oct 4, 2023
b1e4eda
readme change
asaharn Oct 4, 2023
26de91e
Merge branch 'main' into feature/ingestionretry
asaharn Oct 4, 2023
16ff03a
Merge branch 'main' into feature/ingestionretry
fatsheep9146 Oct 5, 2023
64e5578
* Update timeout settings
ag-ramachandran Oct 5, 2023
717596e
Merge branch 'main' into feature/ingestionretry
ag-ramachandran Oct 5, 2023
ceb7421
reverted gomodtidy
asaharn Oct 6, 2023
9c16013
added empty line for keeping identical
asaharn Oct 6, 2023
0349563
Merge branch 'main' into feature/ingestionretry
asaharn Oct 6, 2023
ab46156
Merge branch 'main' into feature/ingestionretry
asaharn Oct 6, 2023
c41e5c9
Merge branch 'main' into feature/ingestionretry
ag-ramachandran Oct 12, 2023
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/ingestionretry.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: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: azuredataexplorerexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Added exporter helper config support for Azure Data Explorer exporter

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

# (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]
33 changes: 33 additions & 0 deletions exporter/azuredataexplorerexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This exporter sends metrics, logs and trace data to
[Azure Data Explorer](https://docs.microsoft.com/en-us/azure/data-explorer),
[Azure Synapse Data Explorer](https://docs.microsoft.com/en-us/azure/synapse-analytics/data-explorer/data-explorer-overview) and
[Real time analytics in Fabric](https://learn.microsoft.com/en-us/fabric/real-time-analytics/overview)

## Configuration

The following settings are required:
Expand Down Expand Up @@ -78,6 +79,17 @@ exporters:
traces_table_json_mapping: "oteltraces_mapping"
# Type of ingestion managed or queued
ingestion_type : "managed"
#other available exporter helper options, see more here: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/README.md
# timeout: 10s
# sending_queue:
# enabled: true
# num_consumers: 2
# queue_size: 10
# retry_on_failure:
# enabled: true
# initial_interval: 10s
# max_interval: 60s
# max_elapsed_time: 10m
```

## Attribute mapping
Expand Down Expand Up @@ -193,3 +205,24 @@ with ( docstring = "Histo sum count processing function", folder = "UpdatePolicy
.alter table HistoData policy update
@'[{ "IsEnabled": true, "Source": "RawMetricsData","Query": "ExtractHistoCountColumns()", "IsTransactional": false, "PropagateIngestionProperties": false}]'
```

### Opentelemetry Exporter Helper Configurations

The ADX exporter now includes support for Opentelemetry exporter helper configurations. This feature allows you to leverage the exporter helper capabilities(retries, timeout etc.) provided natively by Otel. Read more [here](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/README.md).

Please note that this configuration is not enabled by default. To utilize the Opentelemetry exporter helper, you will need to add it manually to the configuration.

#### Example Configuration

```yaml
# Example Opentelemetry Exporter Configuration
timeout: 10s
sending_queue:
enabled: true
num_consumers: 2
queue_size: 10
retry_on_failure:
enabled: true
initial_interval: 10s
max_interval: 60s
max_elapsed_time: 10m
3 changes: 2 additions & 1 deletion exporter/azuredataexplorerexporter/adx_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ func TestCreateKcsb(t *testing.T) {
applicationID: "",
},
}
for _, tt := range tests {
for i := range tests {
tt := tests[i]
t.Run(tt.name, func(t *testing.T) {
wantAppID := tt.applicationID
gotKcsb := createKcsb(&tt.config, "1.0.0")
Expand Down
30 changes: 17 additions & 13 deletions exporter/azuredataexplorerexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,27 @@ import (

"github.com/google/uuid"
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)

// Config defines configuration for Azure Data Explorer Exporter
type Config struct {
ClusterURI string `mapstructure:"cluster_uri"`
ApplicationID string `mapstructure:"application_id"`
ApplicationKey configopaque.String `mapstructure:"application_key"`
TenantID string `mapstructure:"tenant_id"`
ManagedIdentityID string `mapstructure:"managed_identity_id"`
Database string `mapstructure:"db_name"`
MetricTable string `mapstructure:"metrics_table_name"`
LogTable string `mapstructure:"logs_table_name"`
TraceTable string `mapstructure:"traces_table_name"`
MetricTableMapping string `mapstructure:"metrics_table_json_mapping"`
LogTableMapping string `mapstructure:"logs_table_json_mapping"`
TraceTableMapping string `mapstructure:"traces_table_json_mapping"`
IngestionType string `mapstructure:"ingestion_type"`
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
ClusterURI string `mapstructure:"cluster_uri"`
ApplicationID string `mapstructure:"application_id"`
ApplicationKey configopaque.String `mapstructure:"application_key"`
TenantID string `mapstructure:"tenant_id"`
ManagedIdentityID string `mapstructure:"managed_identity_id"`
Database string `mapstructure:"db_name"`
MetricTable string `mapstructure:"metrics_table_name"`
LogTable string `mapstructure:"logs_table_name"`
TraceTable string `mapstructure:"traces_table_name"`
MetricTableMapping string `mapstructure:"metrics_table_json_mapping"`
LogTableMapping string `mapstructure:"logs_table_json_mapping"`
TraceTableMapping string `mapstructure:"traces_table_json_mapping"`
IngestionType string `mapstructure:"ingestion_type"`
}

// Validate checks if the exporter configuration is valid
Expand Down
30 changes: 30 additions & 0 deletions exporter/azuredataexplorerexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ package azuredataexplorerexporter // import "github.com/open-telemetry/opentelem
import (
"path/filepath"
"testing"
"time"

"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/exporter/exporterhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azuredataexplorerexporter/internal/metadata"
)
Expand Down Expand Up @@ -80,6 +82,34 @@ func TestLoadConfig(t *testing.T) {
id: component.NewIDWithName(metadata.Type, "7"),
errorMessage: `clusterURI config is mandatory`,
},
{
id: component.NewIDWithName(metadata.Type, "8"),
expected: &Config{
ClusterURI: "https://CLUSTER.kusto.windows.net",
ApplicationID: "f80da32c-108c-415c-a19e-643f461a677a",
ApplicationKey: "xx-xx-xx-xx",
TenantID: "21ff9e36-fbaa-43c8-98ba-00431ea10bc3",
Database: "oteldb",
MetricTable: "OTELMetrics",
LogTable: "OTELLogs",
TraceTable: "OTELTraces",
IngestionType: managedIngestType,
TimeoutSettings: exporterhelper.TimeoutSettings{
Timeout: 10 * time.Second,
},
RetrySettings: exporterhelper.RetrySettings{
Enabled: true,
InitialInterval: 10 * time.Second,
MaxInterval: 60 * time.Second,
MaxElapsedTime: 10 * time.Minute,
},
QueueSettings: exporterhelper.QueueSettings{
Enabled: true,
NumConsumers: 2,
QueueSize: 10,
},
},
},
}

for _, tt := range tests {
Expand Down
12 changes: 9 additions & 3 deletions exporter/azuredataexplorerexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func createMetricsExporter(
set,
adxCfg,
adp.metricsDataPusher,
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithTimeout(adxCfg.TimeoutSettings),
exporterhelper.WithRetry(adxCfg.RetrySettings),
exporterhelper.WithQueue(adxCfg.QueueSettings),
exporterhelper.WithShutdown(adp.Close))

if err != nil {
Expand Down Expand Up @@ -104,7 +106,9 @@ func createTracesExporter(
set,
adxCfg,
adp.tracesDataPusher,
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithTimeout(adxCfg.TimeoutSettings),
exporterhelper.WithRetry(adxCfg.RetrySettings),
exporterhelper.WithQueue(adxCfg.QueueSettings),
exporterhelper.WithShutdown(adp.Close))

if err != nil {
Expand Down Expand Up @@ -134,7 +138,9 @@ func createLogsExporter(
set,
adxCfg,
adp.logsDataPusher,
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithTimeout(adxCfg.TimeoutSettings),
exporterhelper.WithRetry(adxCfg.RetrySettings),
exporterhelper.WithQueue(adxCfg.QueueSettings),
exporterhelper.WithShutdown(adp.Close))

if err != nil {
Expand Down
32 changes: 31 additions & 1 deletion exporter/azuredataexplorerexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,34 @@ azuredataexplorer/7:
# raw traces table
traces_table_name: "OTELTraces"
# type of ingestion managed or queued
ingestion_type: "managed"
ingestion_type: "managed"
azuredataexplorer/8:
# Kusto cluster uri
cluster_uri: "https://CLUSTER.kusto.windows.net"
# Client Id
application_id: "f80da32c-108c-415c-a19e-643f461a677a"
# The client secret for the client
application_key: "xx-xx-xx-xx"
# The tenant
tenant_id: "21ff9e36-fbaa-43c8-98ba-00431ea10bc3"
# database for the logs
db_name: "oteldb"
# raw metric table name
metrics_table_name: "OTELMetrics"
# raw log table name
logs_table_name: "OTELLogs"
# raw traces table
traces_table_name: "OTELTraces"
# type of ingestion managed or queued
ingestion_type: "managed"
#export helper options
timeout: 10s
sending_queue:
enabled: true
num_consumers: 2
queue_size: 10
retry_on_failure:
enabled: true
initial_interval: 10s
max_interval: 60s
max_elapsed_time: 10m