Skip to content

Commit

Permalink
Avoid exposing internal types via type aliasing (#2727)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Mar 23, 2021
1 parent 0c6757e commit 6495d9f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion consumer/pdata/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

// AttributeValueType specifies the type of AttributeValue.
type AttributeValueType int
type AttributeValueType int32

const (
AttributeValueNULL AttributeValueType = iota
Expand Down
4 changes: 3 additions & 1 deletion consumer/pdata/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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() }
4 changes: 2 additions & 2 deletions consumer/pdata/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions consumer/pdata/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6495d9f

Please sign in to comment.