Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce naming conventions for Invalid[Trace|Span]ID #5969

Merged
merged 2 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
- `MetricDataPointFlagsStruct` -> `MetricDataPointFlags`
- `NewMetricDataPointFlagsStruct` -> `NewMetricDataPointFlags`
- Deprecate builder distribution flags, use configuration. (#5946)
- Enforce naming conventions for Invalid[Trace|Span]ID: (#5969)
- Deprecate funcs `pcommon.InvalidTraceID` and `pcommon.InvalidSpanID` in favor of vars `pcommon.EmptyTraceID` and `pcommon.EmptySpanID`

### 💡 Enhancements 💡

Expand Down
7 changes: 5 additions & 2 deletions pdata/pcommon/spanid.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ import (
"go.opentelemetry.io/collector/pdata/internal/data"
)

// EmptySpanID represents the empty (all zero bytes) SpanID.
var EmptySpanID = NewSpanID([8]byte{})

// SpanID is span identifier.
type SpanID internal.SpanID

func (ms SpanID) getOrig() data.SpanID {
return internal.GetOrigSpanID(internal.SpanID(ms))
}

// InvalidSpanID returns an empty (all zero bytes) SpanID.
// Deprecated: [v0.59.0] use EmptySpanID.
func InvalidSpanID() SpanID {
return NewSpanID([8]byte{})
return EmptySpanID
}

// NewSpanID returns a new SpanID from the given byte array.
Expand Down
2 changes: 1 addition & 1 deletion pdata/pcommon/spanid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func TestSpanID(t *testing.T) {
sid := InvalidSpanID()
sid := EmptySpanID
assert.EqualValues(t, [8]byte{}, sid.Bytes())
assert.True(t, sid.IsEmpty())
assert.Equal(t, "", sid.HexString())
Expand Down
8 changes: 5 additions & 3 deletions pdata/pcommon/traceid.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@
// limitations under the License.

package pcommon // import "go.opentelemetry.io/collector/pdata/pcommon"

bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved
import (
"go.opentelemetry.io/collector/pdata/internal"
"go.opentelemetry.io/collector/pdata/internal/data"
)

// EmptyTraceID represents the empty (all zero bytes) TraceID.
var EmptyTraceID = NewTraceID([16]byte{})

// TraceID is a trace identifier.
type TraceID internal.TraceID

func (ms TraceID) getOrig() data.TraceID {
return internal.GetOrigTraceID(internal.TraceID(ms))
}

// InvalidTraceID returns an empty (all zero bytes) TraceID.
// Deprecated: [v0.59.0] use EmptyTraceID.
func InvalidTraceID() TraceID {
return NewTraceID([16]byte{})
return EmptyTraceID
}

// NewTraceID returns a new TraceID from the given byte array.
Expand Down
2 changes: 1 addition & 1 deletion pdata/pcommon/traceid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func TestTraceID(t *testing.T) {
tid := InvalidTraceID()
tid := EmptyTraceID
assert.Equal(t, [16]byte{}, tid.Bytes())
assert.True(t, tid.IsEmpty())
assert.Equal(t, "", tid.HexString())
Expand Down