1
1
// Copyright The OpenTelemetry Authors
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
- package datadogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadogreceiver"
4
+ package translator // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadogreceiver/internal/translator "
5
5
6
6
import (
7
7
"go.opentelemetry.io/collector/pdata/pcommon"
@@ -10,16 +10,16 @@ import (
10
10
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity"
11
11
)
12
12
13
- type Batcher struct {
13
+ type batcher struct {
14
14
pmetric.Metrics
15
15
16
16
resourceMetrics map [identity.Resource ]pmetric.ResourceMetrics
17
17
scopeMetrics map [identity.Scope ]pmetric.ScopeMetrics
18
18
metrics map [identity.Metric ]pmetric.Metric
19
19
}
20
20
21
- func newBatcher () Batcher {
22
- return Batcher {
21
+ func newBatcher () batcher {
22
+ return batcher {
23
23
Metrics : pmetric .NewMetrics (),
24
24
resourceMetrics : make (map [identity.Resource ]pmetric.ResourceMetrics ),
25
25
scopeMetrics : make (map [identity.Scope ]pmetric.ScopeMetrics ),
@@ -30,7 +30,7 @@ func newBatcher() Batcher {
30
30
// Dimensions stores the properties of the series that are needed in order
31
31
// to unique identify the series. This is needed in order to batch metrics by
32
32
// resource, scope, and datapoint attributes
33
- type Dimensions struct {
33
+ type dimensions struct {
34
34
name string
35
35
metricType pmetric.MetricType
36
36
resourceAttrs pcommon.Map
@@ -47,9 +47,9 @@ var metricTypeMap = map[string]pmetric.MetricType{
47
47
"sketch" : pmetric .MetricTypeExponentialHistogram ,
48
48
}
49
49
50
- func parseSeriesProperties (name string , metricType string , tags []string , host string , version string , stringPool * StringPool ) Dimensions {
50
+ func parseSeriesProperties (name string , metricType string , tags []string , host string , version string , stringPool * StringPool ) dimensions {
51
51
resourceAttrs , scopeAttrs , dpAttrs := tagsToAttributes (tags , host , stringPool )
52
- return Dimensions {
52
+ return dimensions {
53
53
name : name ,
54
54
metricType : metricTypeMap [metricType ],
55
55
buildInfo : version ,
@@ -59,7 +59,7 @@ func parseSeriesProperties(name string, metricType string, tags []string, host s
59
59
}
60
60
}
61
61
62
- func (b Batcher ) Lookup (dim Dimensions ) (pmetric.Metric , identity.Metric ) {
62
+ func (b batcher ) Lookup (dim dimensions ) (pmetric.Metric , identity.Metric ) {
63
63
resource := dim .Resource ()
64
64
resourceID := identity .OfResource (resource )
65
65
resourceMetrics , ok := b .resourceMetrics [resourceID ]
@@ -90,21 +90,21 @@ func (b Batcher) Lookup(dim Dimensions) (pmetric.Metric, identity.Metric) {
90
90
return metric , metricID
91
91
}
92
92
93
- func (d Dimensions ) Resource () pcommon.Resource {
93
+ func (d dimensions ) Resource () pcommon.Resource {
94
94
resource := pcommon .NewResource ()
95
95
d .resourceAttrs .CopyTo (resource .Attributes ()) // TODO(jesus.vazquez) review this copy
96
96
return resource
97
97
}
98
98
99
- func (d Dimensions ) Scope () pcommon.InstrumentationScope {
99
+ func (d dimensions ) Scope () pcommon.InstrumentationScope {
100
100
scope := pcommon .NewInstrumentationScope ()
101
101
scope .SetName ("otelcol/datadogreceiver" )
102
102
scope .SetVersion (d .buildInfo )
103
103
d .scopeAttrs .CopyTo (scope .Attributes ())
104
104
return scope
105
105
}
106
106
107
- func (d Dimensions ) Metric () pmetric.Metric {
107
+ func (d dimensions ) Metric () pmetric.Metric {
108
108
metric := pmetric .NewMetric ()
109
109
metric .SetName (d .name )
110
110
switch d .metricType {
0 commit comments