Skip to content

Commit 6495d9f

Browse files
authored
Avoid exposing internal types via type aliasing (#2727)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
1 parent 0c6757e commit 6495d9f

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

consumer/pdata/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
// AttributeValueType specifies the type of AttributeValue.
27-
type AttributeValueType int
27+
type AttributeValueType int32
2828

2929
const (
3030
AttributeValueNULL AttributeValueType = iota

consumer/pdata/log.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (ld Logs) ResourceLogs() ResourceLogsSlice {
104104
}
105105

106106
// SeverityNumber is the public alias of otlplogs.SeverityNumber from internal package.
107-
type SeverityNumber otlplogs.SeverityNumber
107+
type SeverityNumber int32
108108

109109
const (
110110
SeverityNumberUNDEFINED = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_UNSPECIFIED)
@@ -133,3 +133,5 @@ const (
133133
SeverityNumberFATAL3 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL3)
134134
SeverityNumberFATAL4 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL4)
135135
)
136+
137+
func (sn SeverityNumber) String() string { return otlplogs.SeverityNumber(sn).String() }

consumer/pdata/metric.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
otlpmetrics "go.opentelemetry.io/collector/internal/data/protogen/metrics/v1"
2121
)
2222

23-
type AggregationTemporality otlpmetrics.AggregationTemporality
23+
type AggregationTemporality int32
2424

2525
const (
2626
AggregationTemporalityUnspecified = AggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED)
@@ -146,7 +146,7 @@ func (md Metrics) MetricAndDataPointCount() (metricCount int, dataPointCount int
146146
}
147147

148148
// MetricDataType specifies the type of data in a Metric.
149-
type MetricDataType int
149+
type MetricDataType int32
150150

151151
const (
152152
MetricDataTypeNone MetricDataType = iota

consumer/pdata/trace.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ func (td Traces) ResourceSpans() ResourceSpansSlice {
9898
// TraceState in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
9999
type TraceState string
100100

101-
type SpanKind otlptrace.Span_SpanKind
102-
103-
func (sk SpanKind) String() string { return otlptrace.Span_SpanKind(sk).String() }
104-
105101
const (
106102
TraceStateEmpty TraceState = ""
107103
)
108104

105+
type SpanKind int32
106+
107+
func (sk SpanKind) String() string { return otlptrace.Span_SpanKind(sk).String() }
108+
109109
const (
110110
SpanKindUNSPECIFIED = SpanKind(0)
111111
SpanKindINTERNAL = SpanKind(otlptrace.Span_SPAN_KIND_INTERNAL)
@@ -117,7 +117,7 @@ const (
117117

118118
// StatusCode mirrors the codes defined at
119119
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
120-
type StatusCode otlptrace.Status_StatusCode
120+
type StatusCode int32
121121

122122
const (
123123
StatusCodeUnset = StatusCode(otlptrace.Status_STATUS_CODE_UNSET)

0 commit comments

Comments
 (0)