Skip to content

Commit 7887d30

Browse files
authored
Make non public some exporter azuredata structs (#40747)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Move to internal visibility some Azuredata exporter structs and removes an unused Status struct <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes #40647 <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.-->
1 parent 46c9461 commit 7887d30

File tree

8 files changed

+88
-66
lines changed

8 files changed

+88
-66
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: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: azuredataexplorerexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Unexport Status, Link, AdxTrace, AdxLog, Event, AdxMetric
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: [40647]
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/e2e_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestCreateTracesE2E(t *testing.T) {
7878
assert.Fail(t, err.Error())
7979
}
8080
// Validate the results
81-
recs := []AdxTrace{}
81+
recs := []adxTrace{}
8282
tableResult := <-dataset.Tables()
8383
if tableResult.Err() != nil {
8484
panic(tableResult.Err())
@@ -92,7 +92,7 @@ func TestCreateTracesE2E(t *testing.T) {
9292
}
9393
row := rowResult.Row()
9494

95-
rec := AdxTrace{}
95+
rec := adxTrace{}
9696
if err = row.ToStruct(&rec); err != nil {
9797
err = rowResult.Err()
9898
}
@@ -146,7 +146,7 @@ func TestCreateLogsE2E(t *testing.T) {
146146
assert.Fail(t, err.Error())
147147
}
148148
// Validate the results
149-
recs := []AdxLog{}
149+
recs := []adxLog{}
150150
tableResult := <-dataset.Tables()
151151
if tableResult.Err() != nil {
152152
panic(tableResult.Err())
@@ -160,7 +160,7 @@ func TestCreateLogsE2E(t *testing.T) {
160160
}
161161
row := rowResult.Row()
162162

163-
rec := AdxLog{}
163+
rec := adxLog{}
164164
if err = row.ToStruct(&rec); err != nil {
165165
err = rowResult.Err()
166166
}
@@ -214,7 +214,7 @@ func TestCreateMetricsE2E(t *testing.T) {
214214
assert.Fail(t, err.Error())
215215
}
216216
// Validate the results
217-
recs := []AdxMetric{}
217+
recs := []adxMetric{}
218218
tableResult := <-dataset.Tables()
219219
if err != nil {
220220
assert.Fail(t, err.Error())
@@ -231,7 +231,7 @@ func TestCreateMetricsE2E(t *testing.T) {
231231
}
232232
row := rowResult.Row()
233233

234-
rec := AdxMetric{}
234+
rec := adxMetric{}
235235
if err = row.ToStruct(&rec); err != nil {
236236
err = rowResult.Err()
237237
}

exporter/azuredataexplorerexporter/logsdata_to_adx.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/traceutil"
1414
)
1515

16-
type AdxLog struct {
16+
type adxLog struct {
1717
Timestamp string // The timestamp of the occurrence. Formatted into string as RFC3339Nano
1818
ObservedTimestamp string // The timestamp of logs observed in opentelemetry collector. Formatted into string as RFC3339Nano
1919
TraceID string // TraceId associated to the log
@@ -26,11 +26,11 @@ type AdxLog struct {
2626
}
2727

2828
// Convert the plog to the type ADXLog, this matches the scheme in the Log table in the database
29-
func mapToAdxLog(resource pcommon.Resource, scope pcommon.InstrumentationScope, logData plog.LogRecord, _ *zap.Logger) *AdxLog {
29+
func mapToAdxLog(resource pcommon.Resource, scope pcommon.InstrumentationScope, logData plog.LogRecord, _ *zap.Logger) *adxLog {
3030
logAttrib := logData.Attributes().AsRaw()
3131
clonedLogAttrib := cloneMap(logAttrib)
3232
copyMap(clonedLogAttrib, getScopeMap(scope))
33-
adxLog := &AdxLog{
33+
adxLog := &adxLog{
3434
Timestamp: logData.Timestamp().AsTime().Format(time.RFC3339Nano),
3535
ObservedTimestamp: logData.ObservedTimestamp().AsTime().Format(time.RFC3339Nano),
3636
TraceID: traceutil.TraceIDToHexOrEmptyString(logData.TraceID()),

exporter/azuredataexplorerexporter/logsdata_to_adx_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func Test_mapToAdxLog(t *testing.T) {
3131
logRecordFn func() plog.LogRecord // function that generates the logs
3232
logResourceFn func() pcommon.Resource
3333
logScopeFn func() pcommon.InstrumentationScope
34-
expectedAdxLogs []*AdxLog
34+
expectedAdxLogs []*adxLog
3535
}{
3636
{
3737
name: "valid",
@@ -49,7 +49,7 @@ func Test_mapToAdxLog(t *testing.T) {
4949
},
5050
logResourceFn: newDummyResource,
5151
logScopeFn: newScopeWithData,
52-
expectedAdxLogs: []*AdxLog{
52+
expectedAdxLogs: []*adxLog{
5353
{
5454
Timestamp: tstr,
5555
ObservedTimestamp: tstr,
@@ -78,7 +78,7 @@ func Test_mapToAdxLog(t *testing.T) {
7878
},
7979
logResourceFn: newDummyResource,
8080
logScopeFn: newScopeWithData,
81-
expectedAdxLogs: []*AdxLog{
81+
expectedAdxLogs: []*adxLog{
8282
{
8383
Timestamp: tstr,
8484
ObservedTimestamp: tstr,
@@ -106,7 +106,7 @@ func Test_mapToAdxLog(t *testing.T) {
106106
},
107107
logResourceFn: newDummyResource,
108108
logScopeFn: newScopeWithData,
109-
expectedAdxLogs: []*AdxLog{
109+
expectedAdxLogs: []*adxLog{
110110
{
111111
Timestamp: tstr,
112112
ObservedTimestamp: tstr,
@@ -140,7 +140,7 @@ func Test_mapToAdxLog(t *testing.T) {
140140
},
141141
logResourceFn: newDummyResource,
142142
logScopeFn: newScopeWithData,
143-
expectedAdxLogs: []*AdxLog{
143+
expectedAdxLogs: []*adxLog{
144144
{
145145
Timestamp: tstr,
146146
ObservedTimestamp: tstr,
@@ -163,7 +163,7 @@ func Test_mapToAdxLog(t *testing.T) {
163163
},
164164
logResourceFn: pcommon.NewResource,
165165
logScopeFn: pcommon.NewInstrumentationScope,
166-
expectedAdxLogs: []*AdxLog{
166+
expectedAdxLogs: []*adxLog{
167167
{
168168
Timestamp: defaultTime,
169169
ObservedTimestamp: defaultTime,

exporter/azuredataexplorerexporter/metricsdata_to_adx.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const (
3232
)
3333

3434
// This is derived from the specification https://opentelemetry.io/docs/reference/specification/metrics/datamodel/
35-
type AdxMetric struct {
35+
type adxMetric struct {
3636
Timestamp string // The timestamp of the occurrence. A metric is measured at a point of time. Formatted into string as RFC3339Nano
3737
// Including name, the Metric object is defined by the following properties:
3838
MetricName string // Name of the metric field
@@ -50,7 +50,7 @@ type AdxMetric struct {
5050
Convert the pMetric to the type ADXMetric , this matches the scheme in the OTELMetric table in the database
5151
*/
5252

53-
func mapToAdxMetric(res pcommon.Resource, md pmetric.Metric, scopeattrs map[string]any, logger *zap.Logger) []*AdxMetric {
53+
func mapToAdxMetric(res pcommon.Resource, md pmetric.Metric, scopeattrs map[string]any, logger *zap.Logger) []*adxMetric {
5454
logger.Debug("Entering processing of toAdxMetric function")
5555
// default to collectors host name. Ignore the error here. This should not cause the failure of the process
5656
host, err := os.Hostname()
@@ -61,15 +61,15 @@ func mapToAdxMetric(res pcommon.Resource, md pmetric.Metric, scopeattrs map[stri
6161
if h := resourceAttrs[hostkey]; h != nil {
6262
host = h.(string)
6363
}
64-
createMetric := func(times time.Time, attr pcommon.Map, value func() float64, name string, desc string, mt pmetric.MetricType) *AdxMetric {
64+
createMetric := func(times time.Time, attr pcommon.Map, value func() float64, name string, desc string, mt pmetric.MetricType) *adxMetric {
6565
clonedScopedAttributes := copyMap(cloneMap(scopeattrs), attr.AsRaw())
6666
if isEmpty(name) {
6767
name = md.Name()
6868
}
6969
if isEmpty(desc) {
7070
desc = md.Description()
7171
}
72-
return &AdxMetric{
72+
return &adxMetric{
7373
Timestamp: times.Format(time.RFC3339Nano),
7474
MetricName: name,
7575
MetricType: mt.String(),
@@ -85,7 +85,7 @@ func mapToAdxMetric(res pcommon.Resource, md pmetric.Metric, scopeattrs map[stri
8585
switch md.Type() {
8686
case pmetric.MetricTypeGauge:
8787
dataPoints := md.Gauge().DataPoints()
88-
adxMetrics := make([]*AdxMetric, dataPoints.Len())
88+
adxMetrics := make([]*adxMetric, dataPoints.Len())
8989
for gi := 0; gi < dataPoints.Len(); gi++ {
9090
dataPoint := dataPoints.At(gi)
9191
adxMetrics[gi] = createMetric(dataPoint.Timestamp().AsTime(), dataPoint.Attributes(), func() float64 {
@@ -102,7 +102,7 @@ func mapToAdxMetric(res pcommon.Resource, md pmetric.Metric, scopeattrs map[stri
102102
return adxMetrics
103103
case pmetric.MetricTypeHistogram:
104104
dataPoints := md.Histogram().DataPoints()
105-
var adxMetrics []*AdxMetric
105+
var adxMetrics []*adxMetric
106106
for gi := 0; gi < dataPoints.Len(); gi++ {
107107
dataPoint := dataPoints.At(gi)
108108
bounds := dataPoint.ExplicitBounds()
@@ -168,7 +168,7 @@ func mapToAdxMetric(res pcommon.Resource, md pmetric.Metric, scopeattrs map[stri
168168
return adxMetrics
169169
case pmetric.MetricTypeSum:
170170
dataPoints := md.Sum().DataPoints()
171-
adxMetrics := make([]*AdxMetric, dataPoints.Len())
171+
adxMetrics := make([]*adxMetric, dataPoints.Len())
172172
for gi := 0; gi < dataPoints.Len(); gi++ {
173173
dataPoint := dataPoints.At(gi)
174174
adxMetrics[gi] = createMetric(dataPoint.Timestamp().AsTime(), dataPoint.Attributes(), func() float64 {
@@ -185,7 +185,7 @@ func mapToAdxMetric(res pcommon.Resource, md pmetric.Metric, scopeattrs map[stri
185185
return adxMetrics
186186
case pmetric.MetricTypeSummary:
187187
dataPoints := md.Summary().DataPoints()
188-
var adxMetrics []*AdxMetric
188+
var adxMetrics []*adxMetric
189189
for gi := 0; gi < dataPoints.Len(); gi++ {
190190
dataPoint := dataPoints.At(gi)
191191
// first, add one event for sum, and one for count
@@ -238,8 +238,8 @@ func mapToAdxMetric(res pcommon.Resource, md pmetric.Metric, scopeattrs map[stri
238238
}
239239

240240
// Given all the metrics , transform that to the representative structure
241-
func rawMetricsToAdxMetrics(_ context.Context, metrics pmetric.Metrics, logger *zap.Logger) []*AdxMetric {
242-
var transformedAdxMetrics []*AdxMetric
241+
func rawMetricsToAdxMetrics(_ context.Context, metrics pmetric.Metrics, logger *zap.Logger) []*adxMetric {
242+
var transformedAdxMetrics []*adxMetric
243243
resourceMetric := metrics.ResourceMetrics()
244244
for i := 0; i < resourceMetric.Len(); i++ {
245245
res := resourceMetric.At(i).Resource()

exporter/azuredataexplorerexporter/metricsdata_to_adx_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ func Test_rawMetricsToAdxMetrics(t *testing.T) {
5151
name string // name of the test
5252
metricsDataFn func(metricType pmetric.MetricType, ts pcommon.Timestamp) pmetric.Metrics // function that generates the metric
5353
metricDataType pmetric.MetricType
54-
expectedAdxMetrics []*AdxMetric // expected results
54+
expectedAdxMetrics []*adxMetric // expected results
5555
}{
5656
{
5757
//
5858
name: "metrics_counter_over_time",
5959
metricsDataFn: newMetrics,
6060
metricDataType: pmetric.MetricTypeSum,
61-
expectedAdxMetrics: []*AdxMetric{
61+
expectedAdxMetrics: []*adxMetric{
6262
{
6363
Timestamp: tstr,
6464
MetricName: "page_faults",
@@ -75,7 +75,7 @@ func Test_rawMetricsToAdxMetrics(t *testing.T) {
7575
name: "metrics_simple_histogram_with_value",
7676
metricsDataFn: newMetrics,
7777
metricDataType: pmetric.MetricTypeHistogram,
78-
expectedAdxMetrics: []*AdxMetric{
78+
expectedAdxMetrics: []*adxMetric{
7979
{
8080
Timestamp: tstr,
8181
MetricName: "http.server.duration_sum",
@@ -187,7 +187,7 @@ func Test_mapToAdxMetric(t *testing.T) {
187187
name string // name of the test
188188
resourceFn func() pcommon.Resource // function that generates the resources
189189
metricDataFn func() pmetric.Metric // function that generates the metric
190-
expectedAdxMetrics []*AdxMetric // expected results
190+
expectedAdxMetrics []*adxMetric // expected results
191191
configFn func() *Config // the config to apply
192192
}{
193193
{
@@ -207,7 +207,7 @@ func Test_mapToAdxMetric(t *testing.T) {
207207
return createDefaultConfig().(*Config)
208208
},
209209

210-
expectedAdxMetrics: []*AdxMetric{
210+
expectedAdxMetrics: []*adxMetric{
211211
{
212212
Timestamp: tstr,
213213
MetricName: "page_faults",
@@ -237,7 +237,7 @@ func Test_mapToAdxMetric(t *testing.T) {
237237
return createDefaultConfig().(*Config)
238238
},
239239

240-
expectedAdxMetrics: []*AdxMetric{
240+
expectedAdxMetrics: []*adxMetric{
241241
{
242242
Timestamp: tstr,
243243
MetricName: "page_faults",
@@ -286,7 +286,7 @@ func Test_mapToAdxMetric(t *testing.T) {
286286
return createDefaultConfig().(*Config)
287287
},
288288

289-
expectedAdxMetrics: []*AdxMetric{
289+
expectedAdxMetrics: []*adxMetric{
290290
{
291291
Timestamp: tstr,
292292
MetricName: "http.server.duration_sum",
@@ -391,7 +391,7 @@ func Test_mapToAdxMetric(t *testing.T) {
391391
configFn: func() *Config {
392392
return createDefaultConfig().(*Config)
393393
},
394-
expectedAdxMetrics: []*AdxMetric{
394+
expectedAdxMetrics: []*adxMetric{
395395
{
396396
Timestamp: tstr,
397397
MetricName: "cpu.frequency",
@@ -422,7 +422,7 @@ func Test_mapToAdxMetric(t *testing.T) {
422422
configFn: func() *Config {
423423
return createDefaultConfig().(*Config)
424424
},
425-
expectedAdxMetrics: []*AdxMetric{
425+
expectedAdxMetrics: []*adxMetric{
426426
{
427427
Timestamp: tstr,
428428
MetricName: "cpu.frequency",
@@ -458,7 +458,7 @@ func Test_mapToAdxMetric(t *testing.T) {
458458
qt2.SetValue(45)
459459
return summary
460460
},
461-
expectedAdxMetrics: []*AdxMetric{
461+
expectedAdxMetrics: []*adxMetric{
462462
{
463463
Timestamp: tstr,
464464
MetricName: "http.server.duration_sum",

0 commit comments

Comments
 (0)