From 6495d9fac2de0247b378f4129b6c0cfba30c7f3d Mon Sep 17 00:00:00 2001
From: Bogdan Drutu <bogdandrutu@gmail.com>
Date: Tue, 23 Mar 2021 10:27:10 -0700
Subject: [PATCH] Avoid exposing internal types via type aliasing (#2727)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
---
 consumer/pdata/common.go |  2 +-
 consumer/pdata/log.go    |  4 +++-
 consumer/pdata/metric.go |  4 ++--
 consumer/pdata/trace.go  | 10 +++++-----
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/consumer/pdata/common.go b/consumer/pdata/common.go
index 953eeceac9d..4bbaaac1a68 100644
--- a/consumer/pdata/common.go
+++ b/consumer/pdata/common.go
@@ -24,7 +24,7 @@ import (
 )
 
 // AttributeValueType specifies the type of AttributeValue.
-type AttributeValueType int
+type AttributeValueType int32
 
 const (
 	AttributeValueNULL AttributeValueType = iota
diff --git a/consumer/pdata/log.go b/consumer/pdata/log.go
index d97f612d127..613da4b3dd8 100644
--- a/consumer/pdata/log.go
+++ b/consumer/pdata/log.go
@@ -104,7 +104,7 @@ func (ld Logs) ResourceLogs() ResourceLogsSlice {
 }
 
 // SeverityNumber is the public alias of otlplogs.SeverityNumber from internal package.
-type SeverityNumber otlplogs.SeverityNumber
+type SeverityNumber int32
 
 const (
 	SeverityNumberUNDEFINED = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_UNSPECIFIED)
@@ -133,3 +133,5 @@ const (
 	SeverityNumberFATAL3    = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL3)
 	SeverityNumberFATAL4    = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL4)
 )
+
+func (sn SeverityNumber) String() string { return otlplogs.SeverityNumber(sn).String() }
diff --git a/consumer/pdata/metric.go b/consumer/pdata/metric.go
index 1bcdb7e3181..8775e321707 100644
--- a/consumer/pdata/metric.go
+++ b/consumer/pdata/metric.go
@@ -20,7 +20,7 @@ import (
 	otlpmetrics "go.opentelemetry.io/collector/internal/data/protogen/metrics/v1"
 )
 
-type AggregationTemporality otlpmetrics.AggregationTemporality
+type AggregationTemporality int32
 
 const (
 	AggregationTemporalityUnspecified = AggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED)
@@ -146,7 +146,7 @@ func (md Metrics) MetricAndDataPointCount() (metricCount int, dataPointCount int
 }
 
 // MetricDataType specifies the type of data in a Metric.
-type MetricDataType int
+type MetricDataType int32
 
 const (
 	MetricDataTypeNone MetricDataType = iota
diff --git a/consumer/pdata/trace.go b/consumer/pdata/trace.go
index 0d66ea32d84..d2be1c0b1c7 100644
--- a/consumer/pdata/trace.go
+++ b/consumer/pdata/trace.go
@@ -98,14 +98,14 @@ func (td Traces) ResourceSpans() ResourceSpansSlice {
 // TraceState in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
 type TraceState string
 
-type SpanKind otlptrace.Span_SpanKind
-
-func (sk SpanKind) String() string { return otlptrace.Span_SpanKind(sk).String() }
-
 const (
 	TraceStateEmpty TraceState = ""
 )
 
+type SpanKind int32
+
+func (sk SpanKind) String() string { return otlptrace.Span_SpanKind(sk).String() }
+
 const (
 	SpanKindUNSPECIFIED = SpanKind(0)
 	SpanKindINTERNAL    = SpanKind(otlptrace.Span_SPAN_KIND_INTERNAL)
@@ -117,7 +117,7 @@ const (
 
 // StatusCode mirrors the codes defined at
 // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
-type StatusCode otlptrace.Status_StatusCode
+type StatusCode int32
 
 const (
 	StatusCodeUnset = StatusCode(otlptrace.Status_STATUS_CODE_UNSET)