Skip to content

Commit f3f126f

Browse files
Merge branch 'main' into add-splunk-rolling-restart-metric
2 parents 04d80c7 + 26dd5a6 commit f3f126f

File tree

29 files changed

+2190
-810
lines changed

29 files changed

+2190
-810
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: mongodbatlasreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Add support for setting custom base URL for the MongoDB Atlas API"
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39345]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

.chloggen/subtract-strategy-v2.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: metricstarttimeprocessor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Implementation of the subtractinitial strategy
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [38379]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

.chloggen/unexport_struct.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: splunkenterprisereceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Unexport InfoEntry and InfoContent
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39830]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

exporter/azuredataexplorerexporter/adx_exporter.go

Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ import (
99
"strconv"
1010
"strings"
1111

12-
"github.com/Azure/azure-kusto-go/kusto"
13-
kustoerrors "github.com/Azure/azure-kusto-go/kusto/data/errors"
14-
"github.com/Azure/azure-kusto-go/kusto/ingest"
15-
"github.com/Azure/azure-kusto-go/kusto/ingest/ingestoptions"
12+
"github.com/Azure/azure-kusto-go/azkustodata"
13+
"github.com/Azure/azure-kusto-go/azkustoingest"
14+
"github.com/Azure/azure-kusto-go/azkustoingest/ingestoptions"
1615
jsoniter "github.com/json-iterator/go"
1716
"go.opentelemetry.io/collector/pdata/pcommon"
1817
"go.opentelemetry.io/collector/pdata/plog"
@@ -23,10 +22,9 @@ import (
2322

2423
// adxDataProducer uses the ADX client to perform ingestion
2524
type adxDataProducer struct {
26-
client *kusto.Client // client for logs, traces and metrics
27-
ingestor ingest.Ingestor // ingestion for logs, traces and metrics
28-
ingestOptions []ingest.FileOption // options for the ingestion
29-
logger *zap.Logger // logger for tracing the flow
25+
ingestor azkustoingest.Ingestor // ingestion for logs, traces and metrics
26+
ingestOptions []azkustoingest.FileOption // options for the ingestion
27+
logger *zap.Logger // logger for tracing the flow
3028
}
3129

3230
const nextline = "\n"
@@ -127,13 +125,8 @@ func (e *adxDataProducer) tracesDataPusher(_ context.Context, traceData ptrace.T
127125
}
128126

129127
func (e *adxDataProducer) Close(context.Context) error {
130-
var err error
131-
132-
err = e.ingestor.Close()
133-
134-
if clientErr := e.client.Close(); clientErr != nil {
135-
err = kustoerrors.GetCombinedError(err, clientErr)
136-
}
128+
// Close the ingestor and client connections
129+
err := e.ingestor.Close()
137130
if err != nil {
138131
e.logger.Warn("Error closing connections", zap.Error(err))
139132
} else {
@@ -149,94 +142,94 @@ func newExporter(config *Config, logger *zap.Logger, telemetryDataType int, vers
149142
if err != nil {
150143
return nil, err
151144
}
152-
metricClient, err := buildAdxClient(config, version)
153-
if err != nil {
154-
return nil, err
155-
}
156145

157-
var ingestor ingest.Ingestor
146+
var ingestor azkustoingest.Ingestor
158147

159-
var ingestOptions []ingest.FileOption
160-
ingestOptions = append(ingestOptions, ingest.FileFormat(ingest.JSON))
161-
ingestOptions = append(ingestOptions, ingest.CompressionType(ingestoptions.GZIP))
148+
var ingestOptions []azkustoingest.FileOption
149+
ingestOptions = append(ingestOptions, azkustoingest.FileFormat(azkustoingest.JSON))
150+
ingestOptions = append(ingestOptions, azkustoingest.CompressionType(ingestoptions.GZIP))
162151
// Expect that this mapping is already existent
163152
if refOption := getMappingRef(config, telemetryDataType); refOption != nil {
164153
ingestOptions = append(ingestOptions, refOption)
165154
}
166155
// The exporter could be configured to run in either modes. Using managedstreaming or batched queueing
167156
if strings.ToLower(config.IngestionType) == managedIngestType {
168-
mi, err := createManagedStreamingIngestor(config, metricClient, tableName)
157+
mi, err := createManagedStreamingIngestor(config, version, tableName)
169158
if err != nil {
170159
return nil, err
171160
}
172161
ingestor = mi
173162
} else {
174-
qi, err := createQueuedIngestor(config, metricClient, tableName)
163+
qi, err := createQueuedIngestor(config, version, tableName)
175164
if err != nil {
176165
return nil, err
177166
}
178167
ingestor = qi
179168
}
180169
return &adxDataProducer{
181-
client: metricClient,
182170
ingestOptions: ingestOptions,
183171
ingestor: ingestor,
184172
logger: logger,
185173
}, nil
186174
}
187175

188176
// Fetches the corresponding ingestionRef if the mapping is provided
189-
func getMappingRef(config *Config, telemetryDataType int) ingest.FileOption {
177+
func getMappingRef(config *Config, telemetryDataType int) azkustoingest.FileOption {
190178
switch telemetryDataType {
191179
case metricsType:
192180
if !isEmpty(config.MetricTableMapping) {
193-
return ingest.IngestionMappingRef(config.MetricTableMapping, ingest.JSON)
181+
return azkustoingest.IngestionMappingRef(config.MetricTableMapping, azkustoingest.JSON)
194182
}
195183
case tracesType:
196184
if !isEmpty(config.TraceTableMapping) {
197-
return ingest.IngestionMappingRef(config.TraceTableMapping, ingest.JSON)
185+
return azkustoingest.IngestionMappingRef(config.TraceTableMapping, azkustoingest.JSON)
198186
}
199187
case logsType:
200188
if !isEmpty(config.LogTableMapping) {
201-
return ingest.IngestionMappingRef(config.LogTableMapping, ingest.JSON)
189+
return azkustoingest.IngestionMappingRef(config.LogTableMapping, azkustoingest.JSON)
202190
}
203191
}
204192
return nil
205193
}
206194

207-
func buildAdxClient(config *Config, version string) (*kusto.Client, error) {
208-
client, err := kusto.New(createKcsb(config, version))
209-
return client, err
210-
}
211-
212-
func createKcsb(config *Config, version string) *kusto.ConnectionStringBuilder {
213-
var kcsb *kusto.ConnectionStringBuilder
195+
func createKcsb(config *Config, version string) *azkustodata.ConnectionStringBuilder {
196+
var kcsb *azkustodata.ConnectionStringBuilder
214197
isManagedIdentity := len(strings.TrimSpace(config.ManagedIdentityID)) > 0
215198
isSystemManagedIdentity := strings.EqualFold(strings.TrimSpace(config.ManagedIdentityID), "SYSTEM")
216199
// If the user has managed identity done, use it. For System managed identity use the MI as system
217200
switch {
218201
case config.UseAzureAuth:
219-
kcsb = kusto.NewConnectionStringBuilder(config.ClusterURI).WithDefaultAzureCredential()
202+
kcsb = azkustodata.NewConnectionStringBuilder(config.ClusterURI).WithDefaultAzureCredential()
220203
case !isManagedIdentity:
221-
kcsb = kusto.NewConnectionStringBuilder(config.ClusterURI).WithAadAppKey(config.ApplicationID, string(config.ApplicationKey), config.TenantID)
204+
kcsb = azkustodata.NewConnectionStringBuilder(config.ClusterURI).WithAadAppKey(config.ApplicationID, string(config.ApplicationKey), config.TenantID)
222205
case isManagedIdentity && isSystemManagedIdentity:
223-
kcsb = kusto.NewConnectionStringBuilder(config.ClusterURI).WithSystemManagedIdentity()
206+
kcsb = azkustodata.NewConnectionStringBuilder(config.ClusterURI).WithSystemManagedIdentity()
224207
case isManagedIdentity && !isSystemManagedIdentity:
225-
kcsb = kusto.NewConnectionStringBuilder(config.ClusterURI).WithUserManagedIdentity(config.ManagedIdentityID)
208+
kcsb = azkustodata.NewConnectionStringBuilder(config.ClusterURI).WithUserAssignedIdentityClientId(config.ManagedIdentityID)
226209
}
227-
kcsb.SetConnectorDetails("OpenTelemetry", version, "", "", false, "", kusto.StringPair{Key: "isManagedIdentity", Value: strconv.FormatBool(isManagedIdentity)})
210+
kcsb.SetConnectorDetails("OpenTelemetry", version, "", "", false, "", azkustodata.StringPair{Key: "isManagedIdentity", Value: strconv.FormatBool(isManagedIdentity)})
228211
return kcsb
229212
}
230213

231214
// Depending on the table, create separate ingestors
232-
func createManagedStreamingIngestor(config *Config, adxclient *kusto.Client, tablename string) (*ingest.Managed, error) {
233-
ingestor, err := ingest.NewManaged(adxclient, config.Database, tablename)
215+
func createManagedStreamingIngestor(config *Config, version string, tablename string) (*azkustoingest.Managed, error) {
216+
kcsb := createKcsb(config, version)
217+
ingestopts := []azkustoingest.Option{
218+
azkustoingest.WithDefaultDatabase(config.Database),
219+
azkustoingest.WithDefaultTable(tablename),
220+
}
221+
ingestor, err := azkustoingest.NewManaged(kcsb, ingestopts...)
234222
return ingestor, err
235223
}
236224

237225
// A queued ingestor in case that is provided as the config option
238-
func createQueuedIngestor(config *Config, adxclient *kusto.Client, tablename string) (*ingest.Ingestion, error) {
239-
ingestor, err := ingest.New(adxclient, config.Database, tablename)
226+
func createQueuedIngestor(config *Config, version string, tablename string) (*azkustoingest.Ingestion, error) {
227+
kcsb := createKcsb(config, version)
228+
ingestopts := []azkustoingest.Option{
229+
azkustoingest.WithDefaultDatabase(config.Database),
230+
azkustoingest.WithDefaultTable(tablename),
231+
}
232+
ingestor, err := azkustoingest.New(kcsb, ingestopts...)
240233
return ingestor, err
241234
}
242235

0 commit comments

Comments
 (0)