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

Edit type/func documentation in the consumer package #3269

Merged
merged 31 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a76b227
Edited grammar of pdata doc.go
eddyleelin May 20, 2021
36e3d5c
Added missing word
eddyleelin May 20, 2021
30666ab
Fixed typos in pdata/common.go
eddyleelin May 20, 2021
8530cd5
Added missing String method docs
eddyleelin May 20, 2021
662c34d
Fixed spacing in doc example
eddyleelin May 20, 2021
7d31d65
Fixed spacing issues in multiple examples
eddyleelin May 20, 2021
8202727
Fixed spacing issue on Range example
eddyleelin May 20, 2021
d553a0b
Fixed spacing in At example
eddyleelin May 20, 2021
ee17722
Fixed more spacing errors in examples
eddyleelin May 21, 2021
db923d2
Fixed error in ResourceMetrics header describing InstrumentationLibra…
eddyleelin May 21, 2021
ab14f50
Fixed another header referencing wrong method
eddyleelin May 21, 2021
d6343c1
Added documentation for pdata.Resource
eddyleelin May 21, 2021
1d360f1
Updated outdated links to Span OTLP definition
eddyleelin May 21, 2021
72f02be
Cleaned up wording in SpanStatus doc
eddyleelin May 21, 2021
c5c310b
Fixed more spacing errors in examples
eddyleelin May 21, 2021
de3d473
Fixed typos in type docs
eddyleelin May 21, 2021
a1a9d4c
Cleaned up formatting in consumererror
eddyleelin May 21, 2021
f25c699
Cleaned up consumerhelper doc typos
eddyleelin May 21, 2021
3c7ac3b
Updated docs in consumertest
eddyleelin May 21, 2021
02477bf
Update CHANGELOG.md
eddyleelin May 24, 2021
8432959
Fixed formatting errors in cmd/pdatagen
eddyleelin May 24, 2021
d2c51e4
Removed unused imports
eddyleelin May 26, 2021
c0c35e1
Merge branch 'main' into edit-godocs-consumer
eddyleelin May 27, 2021
f4feaa9
Update CHANGELOG.md
eddyleelin Jun 2, 2021
8409b7d
Fixed generated code lint failures
eddyleelin Jun 2, 2021
ddbd231
Merge branch 'main' into edit-godocs-consumer
eddyleelin Jun 2, 2021
72daca2
Merge branch 'edit-godocs-consumer' of https://github.com/open-o11y/o…
eddyleelin Jun 2, 2021
50c3ab5
Revert changes in pdatagen and pdata/generated
eddyleelin Jun 2, 2021
88244d4
Merge remote-tracking branch 'upstream/main' into edit-godocs-consumer
eddyleelin Jun 12, 2021
2b13771
Update NewErr docstring
eddyleelin Jun 12, 2021
d9f542c
Updated docstring for TraceState
eddyleelin Jun 12, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
## 💡 Enhancements 💡

- Add `doc.go` files to the consumer package and its subpackages (#3270)
- Improve documentation of consumer package and subpackages (#3269, #3361)
- Automate triggering of doc-update on release (#3234)
- Enable Dependabot for Github Actions (#3312)
- Remove the proto dependency in `goldendataset` for traces (#3322)
Expand Down
4 changes: 2 additions & 2 deletions consumer/consumererror/permanent.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type permanent struct {
err error
}

// Permanent wraps an error to indicate that it is a permanent error, i.e.: an
// Permanent wraps an error to indicate that it is a permanent error, i.e. an
// error that will be always returned if its source receives the same inputs.
func Permanent(err error) error {
return permanent{err: err}
Expand All @@ -37,7 +37,7 @@ func (p permanent) Unwrap() error {
return p.err
}

// IsPermanent checks if an error was wrapped with the Permanent function, that
// IsPermanent checks if an error was wrapped with the Permanent function, which
// is used to indicate that a given error will always be returned in the case
// that its sources receives the same input.
func IsPermanent(err error) bool {
Expand Down
6 changes: 3 additions & 3 deletions consumer/consumererror/signalerrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewTraces(err error, failed pdata.Traces) error {
}
}

// AsTraces finds the first error in err's chain that can be assigned to target. If such an error is found
// AsTraces finds the first error in err's chain that can be assigned to target. If such an error is found,
// it is assigned to target and true is returned, otherwise false is returned.
func AsTraces(err error, target *Traces) bool {
if err == nil {
Expand Down Expand Up @@ -69,7 +69,7 @@ func NewLogs(err error, failed pdata.Logs) error {
}
}

// AsLogs finds the first error in err's chain that can be assigned to target. If such an error is found
// AsLogs finds the first error in err's chain that can be assigned to target. If such an error is found,
// it is assigned to target and true is returned, otherwise false is returned.
func AsLogs(err error, target *Logs) bool {
if err == nil {
Expand Down Expand Up @@ -103,7 +103,7 @@ func NewMetrics(err error, failed pdata.Metrics) error {
}
}

// AsMetrics finds the first error in err's chain that can be assigned to target. If such an error is found
// AsMetrics finds the first error in err's chain that can be assigned to target. If such an error is found,
// it is assigned to target and true is returned, otherwise false is returned.
func AsMetrics(err error, target *Metrics) bool {
if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions consumer/consumerhelper/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ type baseConsumer struct {
capabilities consumer.Capabilities
}

// Option apply changes to internalOptions.
// Option applies changes to internalOptions.
type Option func(*baseConsumer)

// WithCapabilities overrides the default GetCapabilities function for an processor.
// WithCapabilities overrides the default GetCapabilities function for a processor.
// The default GetCapabilities function returns mutable capabilities.
func WithCapabilities(capabilities consumer.Capabilities) Option {
return func(o *baseConsumer) {
Expand Down
1 change: 1 addition & 0 deletions consumer/consumertest/base_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

type nonMutatingConsumer struct{}

// Capabilities returns the base consumer capabilities.
func (bc nonMutatingConsumer) Capabilities() consumer.Capabilities {
return consumer.Capabilities{MutatesData: false}
}
6 changes: 3 additions & 3 deletions consumer/consumertest/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
)

// Consumer is a convenience interface that implements all consumer interfaces.
// It has a private function on it to forbid external users to implement it,
// to allow us to add extra functions without breaking compatibility because
// nobody else implements this interface.
// It has a private function on it to forbid external users from implementing it
// and, as a result, to allow us to add extra functions without breaking
// compatibility.
type Consumer interface {
// Capabilities to implement the base consumer functionality.
Capabilities() consumer.Capabilities
Expand Down
2 changes: 1 addition & 1 deletion consumer/consumertest/err.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (er *errConsumer) ConsumeLogs(context.Context, pdata.Logs) error {
return er.err
}

// NewErr returns a Consumer that just drops all received data and returns no error.
// NewErr returns a Consumer that just drops all received data and returns the specified error to Consume* callers.
func NewErr(err error) Consumer {
return &errConsumer{err: err}
}
6 changes: 3 additions & 3 deletions consumer/consumertest/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (ste *TracesSink) AllTraces() []pdata.Traces {
return copyTraces
}

// SpansCount return the number of spans sent to this sink.
// SpansCount returns the number of spans sent to this sink.
func (ste *TracesSink) SpansCount() int {
ste.mu.Lock()
defer ste.mu.Unlock()
Expand Down Expand Up @@ -102,7 +102,7 @@ func (sme *MetricsSink) AllMetrics() []pdata.Metrics {
return copyMetrics
}

// MetricsCount return the number of metrics stored by this sink since last Reset.
// MetricsCount returns the number of metrics stored by this sink since last Reset.
func (sme *MetricsSink) MetricsCount() int {
sme.mu.Lock()
defer sme.mu.Unlock()
Expand Down Expand Up @@ -150,7 +150,7 @@ func (sle *LogsSink) AllLogs() []pdata.Logs {
return copyLogs
}

// LogRecordsCount return the number of log records stored by this sink since last Reset.
// LogRecordsCount returns the number of log records stored by this sink since last Reset.
func (sle *LogsSink) LogRecordsCount() int {
sle.mu.Lock()
defer sle.mu.Unlock()
Expand Down
29 changes: 15 additions & 14 deletions consumer/pdata/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const (
AttributeValueTypeArray
)

// String returns the string representation of the AttributeValueType.
func (avt AttributeValueType) String() string {
switch avt {
case AttributeValueTypeNull:
Expand Down Expand Up @@ -65,12 +66,12 @@ func (avt AttributeValueType) String() string {
//
// function f1(val AttributeValue) { val.SetIntVal(234) }
// function f2() {
// v := NewAttributeValueString("a string")
// f1(v)
// _ := v.Type() // this will return AttributeValueTypeInt
// v := NewAttributeValueString("a string")
// f1(v)
// _ := v.Type() // this will return AttributeValueTypeInt
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved
// }
//
// Important: zero-initialized instance is not valid for use. All AttributeValue functions bellow must
// Important: zero-initialized instance is not valid for use. All AttributeValue functions below must
// be called only on instances that are created via NewAttributeValue+ functions.
type AttributeValue struct {
orig *otlpcommon.AnyValue
Expand Down Expand Up @@ -362,7 +363,7 @@ func newAttributeMap(orig *[]otlpcommon.KeyValue) AttributeMap {
// with values from the given map[string]string.
//
// Returns the same instance to allow nicer code like:
// assert.EqualValues(t, NewAttributeMap().InitFromMap(map[string]AttributeValue{...}), actual)
// assert.EqualValues(t, NewAttributeMap().InitFromMap(map[string]AttributeValue{...}), actual)
func (am AttributeMap) InitFromMap(attrMap map[string]AttributeValue) AttributeMap {
if len(attrMap) == 0 {
*am.orig = []otlpcommon.KeyValue(nil)
Expand Down Expand Up @@ -586,7 +587,7 @@ func (am AttributeMap) UpsertBool(k string, v bool) {

// Sort sorts the entries in the AttributeMap so two instances can be compared.
// Returns the same instance to allow nicer code like:
// assert.EqualValues(t, expected.Sort(), actual.Sort())
// assert.EqualValues(t, expected.Sort(), actual.Sort())
func (am AttributeMap) Sort() AttributeMap {
// Intention is to move the nil values at the end.
sort.SliceStable(*am.orig, func(i, j int) bool {
Expand All @@ -607,9 +608,9 @@ func (am AttributeMap) Len() int {
//
// Example:
//
// it := sm.Range(func(k string, v AttributeValue) {
// ...
// })
// it := sm.Range(func(k string, v AttributeValue) {
// ...
// })
func (am AttributeMap) Range(f func(k string, v AttributeValue) bool) {
for i := range *am.orig {
kv := &(*am.orig)[i]
Expand Down Expand Up @@ -664,7 +665,7 @@ func newStringMap(orig *[]otlpcommon.StringKeyValue) StringMap {
// with values from the given map[string]string.
//
// Returns the same instance to allow nicer code like:
// assert.EqualValues(t, NewStringMap().InitFromMap(map[string]string{...}), actual)
// assert.EqualValues(t, NewStringMap().InitFromMap(map[string]string{...}), actual)
func (sm StringMap) InitFromMap(attrMap map[string]string) StringMap {
if len(attrMap) == 0 {
*sm.orig = []otlpcommon.StringKeyValue(nil)
Expand Down Expand Up @@ -759,9 +760,9 @@ func (sm StringMap) Len() int {
//
// Example:
//
// it := sm.Range(func(k string, v StringValue) {
// ...
// })
// it := sm.Range(func(k string, v StringValue) {
// ...
// })
func (sm StringMap) Range(f func(k string, v string) bool) {
for i := range *sm.orig {
skv := &(*sm.orig)[i]
Expand Down Expand Up @@ -800,7 +801,7 @@ func (sm StringMap) get(k string) (*otlpcommon.StringKeyValue, bool) {

// Sort sorts the entries in the StringMap so two instances can be compared.
// Returns the same instance to allow nicer code like:
// assert.EqualValues(t, expected.Sort(), actual.Sort())
// assert.EqualValues(t, expected.Sort(), actual.Sort())
func (sm StringMap) Sort() StringMap {
sort.SliceStable(*sm.orig, func(i, j int) bool {
// Intention is to move the nil values at the end.
Expand Down
12 changes: 6 additions & 6 deletions consumer/pdata/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
// limitations under the License.

// Package pdata (pipeline data) implements data structures that represent telemetry data in-memory.
// All data received is converted into this format and travels through the pipeline
// in this format and that is converted from this format by exporters when sending.
// All data received is converted into this format, travels through the pipeline
// in this format, and is converted from this format by exporters when sending.
//
// Current implementation primarily uses OTLP ProtoBuf structs as the underlying data
// structures for many of of the declared structs. We keep a pointer to OTLP protobuf
// in the "orig" member field. This allows efficient translation to/from OTLP wire
// protocol. Note that the underlying data structure is kept private so that in the
// future we are free to make changes to it to make more optimal.
// protocol. Note that the underlying data structure is kept private so that we are
// free to make changes to it in the future.
//
// Most of the internal data structures must be created via New* functions. Zero-initialized
// structures in most cases are not valid (read comments for each struct to know if it
// structures, in most cases, are not valid (read comments for each struct to know if that
// is the case). This is a slight deviation from idiomatic Go to avoid unnecessary
// pointer checks in dozens of functions which assume the invariant that "orig" member
// is non-nil. Several structures also provide New*Slice functions that allows to create
// is non-nil. Several structures also provide New*Slice functions that allow creating
// more than one instance of the struct more efficiently instead of calling New*
// repeatedly. Use it where appropriate.
package pdata
1 change: 1 addition & 0 deletions consumer/pdata/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,5 @@ const (
SeverityNumberFATAL4 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL4)
)

// String returns the string representation of the SeverityNumber.
func (sn SeverityNumber) String() string { return otlplogs.SeverityNumber(sn).String() }
7 changes: 4 additions & 3 deletions consumer/pdata/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func (at AggregationTemporality) String() string {
return otlpmetrics.AggregationTemporality(at).String()
}

// Metrics is an opaque interface that allows transition to the new internal Metrics data, but also facilitate the
// transition to the new components especially for traces.
// Metrics is an opaque interface that allows transition to the new internal Metrics data, but also facilitates the
// transition to the new components, especially for traces.
//
// Outside of the core repository the metrics pipeline cannot be converted to the new model since data.MetricData is
// Outside of the core repository, the metrics pipeline cannot be converted to the new model since data.MetricData is
// part of the internal package.
type Metrics struct {
orig *otlpcollectormetrics.ExportMetricsServiceRequest
Expand Down Expand Up @@ -166,6 +166,7 @@ const (
MetricDataTypeSummary
)

// String returns the string representation of the MetricDataType.
func (mdt MetricDataType) String() string {
switch mdt {
case MetricDataTypeNone:
Expand Down
3 changes: 2 additions & 1 deletion consumer/pdata/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (td Traces) ResourceSpans() ResourceSpansSlice {
return newResourceSpansSlice(&td.orig.ResourceSpans)
}

// TraceState in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
// TraceState is a string representing the tracestate in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
type TraceState string

const (
Expand Down Expand Up @@ -145,6 +145,7 @@ const (
StatusCodeError = StatusCode(otlptrace.Status_STATUS_CODE_ERROR)
)

// String returns the string representation of the StatusCode.
func (sc StatusCode) String() string { return otlptrace.Status_StatusCode(sc).String() }

// SetCode replaces the code associated with this SpanStatus.
Expand Down
2 changes: 1 addition & 1 deletion consumer/simple/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (mb *SafeMetrics) AddHistogramRawDataPoint(name string, hist pdata.IntHisto
return mb
}

// AddDHistogramRawDataPoint wraps AddDHistogramRawDataPoint.
// AddDHistogramRawDataPoint wraps Metrics.AddDHistogramRawDataPoint.
func (mb *SafeMetrics) AddDHistogramRawDataPoint(name string, hist pdata.HistogramDataPoint) *SafeMetrics {
mb.Lock()
mb.Metrics.AddDHistogramRawDataPoint(name, hist)
Expand Down