mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-28 21:09:17 +02:00
Ensure exported interfaces have named method parameters (#1172)
* Ensure exported interface types have named arguments * Update Styling Guide * update CHANGELOG
This commit is contained in:
parent
2621bd4847
commit
a12224a454
@ -39,6 +39,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- The [configuration style guide](https://github.com/open-telemetry/opentelemetry-go/blob/master/CONTRIBUTING.md#config) has been updated to
|
||||
recommend the use of `newConfig()` instead of `configure()`. (#1163)
|
||||
- The `otlp.Config` type has been unexported and changed to `otlp.config`, along with its initializer. (#1163)
|
||||
- Ensure exported interface types include parameter names and update the
|
||||
Style Guide to reflect this styling rule. (#1172)
|
||||
- Don't consider unset environment variable for resource detection to be an error. (#1170)
|
||||
- Rename `go.opentelemetry.io/otel/api/metric.ConfigureInstrument` to `NewInstrumentConfig` and
|
||||
`go.opentelemetry.io/otel/api/metric.ConfigureMeter` to `NewMeterConfig`.
|
||||
|
@ -345,6 +345,14 @@ func NewDog(name string, o ...DogOption) Dog {…}
|
||||
func NewBird(name string, o ...BirdOption) Bird {…}
|
||||
```
|
||||
|
||||
### Interface Type
|
||||
|
||||
To allow other developers to better comprehend the code, it is important
|
||||
to ensure it is sufficiently documented. One simple measure that contributes
|
||||
to this aim is self-documenting by naming method parameters. Therefore,
|
||||
where appropriate, methods of every exported interface type should have
|
||||
their parameters appropriately named.
|
||||
|
||||
## Approvers and Maintainers
|
||||
|
||||
Approvers:
|
||||
|
@ -32,7 +32,7 @@ var ErrInvalidAsyncRunner = errors.New("unknown async runner type")
|
||||
// the SDK to provide support for running observer callbacks.
|
||||
type AsyncCollector interface {
|
||||
// CollectAsync passes a batch of observations to the MeterImpl.
|
||||
CollectAsync([]label.KeyValue, ...metric.Observation)
|
||||
CollectAsync(labels []label.KeyValue, observation ...metric.Observation)
|
||||
}
|
||||
|
||||
// AsyncInstrumentState manages an ordered set of asynchronous
|
||||
@ -49,7 +49,7 @@ type AsyncInstrumentState struct {
|
||||
// collection interval. Singletons are entered with a real
|
||||
// instrument each, batch observers are entered with a nil
|
||||
// instrument, ensuring that when a singleton callback is used
|
||||
// repeatedly, it is excuted repeatedly in the interval, while
|
||||
// repeatedly, it is executed repeatedly in the interval, while
|
||||
// when a batch callback is used repeatedly, it only executes
|
||||
// once per interval.
|
||||
runnerMap map[asyncRunnerPair]struct{}
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
// implementation.
|
||||
type MeterImpl interface {
|
||||
// RecordBatch atomically records a batch of measurements.
|
||||
RecordBatch(context.Context, []label.KeyValue, ...Measurement)
|
||||
RecordBatch(ctx context.Context, labels []label.KeyValue, measurement ...Measurement)
|
||||
|
||||
// NewSyncInstrument returns a newly constructed
|
||||
// synchronous instrument implementation or an error, should
|
||||
@ -85,10 +85,10 @@ type AsyncImpl interface {
|
||||
|
||||
// WrapMeterImpl constructs a `Meter` implementation from a
|
||||
// `MeterImpl` implementation.
|
||||
func WrapMeterImpl(impl MeterImpl, instrumentatioName string, opts ...MeterOption) Meter {
|
||||
func WrapMeterImpl(impl MeterImpl, instrumentationName string, opts ...MeterOption) Meter {
|
||||
return Meter{
|
||||
impl: impl,
|
||||
name: instrumentatioName,
|
||||
name: instrumentationName,
|
||||
version: NewMeterConfig(opts...).InstrumentationVersion,
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ type HTTPExtractor interface {
|
||||
// trace.ContextWithRemoteSpanContext. In case of correlation
|
||||
// context, the propagator should use correlation.WithMap to
|
||||
// store it in the context.
|
||||
Extract(context.Context, HTTPSupplier) context.Context
|
||||
Extract(ctx context.Context, supplier HTTPSupplier) context.Context
|
||||
}
|
||||
|
||||
// HTTPInjector injects information into a HTTPSupplier.
|
||||
@ -52,7 +52,7 @@ type HTTPInjector interface {
|
||||
// encodes it into propagator specific format and then injects
|
||||
// the encoded information using supplier into an associated
|
||||
// carrier.
|
||||
Inject(context.Context, HTTPSupplier)
|
||||
Inject(ctx context.Context, supplier HTTPSupplier)
|
||||
}
|
||||
|
||||
// Config contains the current set of extractors and injectors.
|
||||
|
@ -89,8 +89,8 @@ func WithSpanRecorder(sr SpanRecorder) Option {
|
||||
}
|
||||
|
||||
type SpanRecorder interface {
|
||||
OnStart(*Span)
|
||||
OnEnd(*Span)
|
||||
OnStart(span *Span)
|
||||
OnEnd(span *Span)
|
||||
}
|
||||
|
||||
type StandardSpanRecorder struct {
|
||||
|
@ -72,5 +72,5 @@ type OverrideTracerSpanExtension interface {
|
||||
// API calls. In such case, there is no need to use the
|
||||
// WrapperTracer and thus no need to override the result of
|
||||
// the Tracer() function.
|
||||
OverrideTracer(oteltrace.Tracer)
|
||||
OverrideTracer(tracer oteltrace.Tracer)
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ type (
|
||||
// Encode returns the serialized encoding of the label
|
||||
// set using its Iterator. This result may be cached
|
||||
// by a label.Set.
|
||||
Encode(Iterator) string
|
||||
Encode(iterator Iterator) string
|
||||
|
||||
// ID returns a value that is unique for each class of
|
||||
// label encoder. Label encoders allocate these using
|
||||
|
@ -71,7 +71,7 @@ type Processor interface {
|
||||
// computation. An SDK is not expected to call exporters from
|
||||
// with Process, use a controller for that (see
|
||||
// ./controllers/{pull,push}.
|
||||
Process(Accumulation) error
|
||||
Process(accum Accumulation) error
|
||||
}
|
||||
|
||||
// AggregatorSelector supports selecting the kind of Aggregator to
|
||||
@ -94,7 +94,7 @@ type AggregatorSelector interface {
|
||||
// Note: This is context-free because the aggregator should
|
||||
// not relate to the incoming context. This call should not
|
||||
// block.
|
||||
AggregatorFor(*metric.Descriptor, ...*Aggregator)
|
||||
AggregatorFor(descriptor *metric.Descriptor, aggregator ...*Aggregator)
|
||||
}
|
||||
|
||||
// Checkpointer is the interface used by a Controller to coordinate
|
||||
@ -152,7 +152,7 @@ type Aggregator interface {
|
||||
//
|
||||
// The Context argument comes from user-level code and could be
|
||||
// inspected for a `correlation.Map` or `trace.SpanContext`.
|
||||
Update(context.Context, metric.Number, *metric.Descriptor) error
|
||||
Update(ctx context.Context, number metric.Number, descriptor *metric.Descriptor) error
|
||||
|
||||
// SynchronizedMove is called during collection to finish one
|
||||
// period of aggregation by atomically saving the
|
||||
@ -181,7 +181,7 @@ type Aggregator interface {
|
||||
//
|
||||
// The owner of an Aggregator being merged is responsible for
|
||||
// synchronization of both Aggregator states.
|
||||
Merge(Aggregator, *metric.Descriptor) error
|
||||
Merge(aggregator Aggregator, descriptor *metric.Descriptor) error
|
||||
}
|
||||
|
||||
// Subtractor is an optional interface implemented by some
|
||||
@ -206,7 +206,7 @@ type Exporter interface {
|
||||
//
|
||||
// The CheckpointSet interface refers to the Processor that just
|
||||
// completed collection.
|
||||
Export(context.Context, CheckpointSet) error
|
||||
Export(ctx context.Context, checkpointSet CheckpointSet) error
|
||||
|
||||
// ExportKindSelector is an interface used by the Processor
|
||||
// in deciding whether to compute Delta or Cumulative
|
||||
@ -221,7 +221,7 @@ type ExportKindSelector interface {
|
||||
// ExportKindFor should return the correct ExportKind that
|
||||
// should be used when exporting data for the given metric
|
||||
// instrument and Aggregator kind.
|
||||
ExportKindFor(*metric.Descriptor, aggregation.Kind) ExportKind
|
||||
ExportKindFor(descriptor *metric.Descriptor, aggregatorKind aggregation.Kind) ExportKind
|
||||
}
|
||||
|
||||
// CheckpointSet allows a controller to access a complete checkpoint of
|
||||
@ -242,7 +242,7 @@ type CheckpointSet interface {
|
||||
// expected from the Meter implementation. Any other kind
|
||||
// of error will immediately halt ForEach and return
|
||||
// the error to the caller.
|
||||
ForEach(ExportKindSelector, func(Record) error) error
|
||||
ForEach(kindSelector ExportKindSelector, recordFunc func(Record) error) error
|
||||
|
||||
// Locker supports locking the checkpoint set. Collection
|
||||
// into the checkpoint set cannot take place (in case of a
|
||||
|
@ -40,12 +40,12 @@ type SpanExporter interface {
|
||||
// calls this function will not implement any retry logic. All errors
|
||||
// returned by this function are considered unrecoverable and will be
|
||||
// reported to a configured error Handler.
|
||||
ExportSpans(context.Context, []*SpanData) error
|
||||
ExportSpans(ctx context.Context, spanData []*SpanData) error
|
||||
// Shutdown notifies the exporter of a pending halt to operations. The
|
||||
// exporter is expected to preform any cleanup or synchronization it
|
||||
// requires while honoring all timeouts and cancellations contained in
|
||||
// the passed context.
|
||||
Shutdown(context.Context) error
|
||||
Shutdown(ctx context.Context) error
|
||||
}
|
||||
|
||||
// SpanData contains all the information collected by a completed span.
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
|
||||
type Clock interface {
|
||||
Now() lib.Time
|
||||
Ticker(lib.Duration) Ticker
|
||||
Ticker(duration lib.Duration) Ticker
|
||||
}
|
||||
|
||||
type Ticker interface {
|
||||
|
@ -31,7 +31,7 @@ type (
|
||||
// LabelFilterSelector is the interface used to configure a
|
||||
// specific Filter to an instrument.
|
||||
LabelFilterSelector interface {
|
||||
LabelFilterFor(*metric.Descriptor) label.Filter
|
||||
LabelFilterFor(descriptor *metric.Descriptor) label.Filter
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
|
||||
// Sampler decides whether a trace should be sampled and exported.
|
||||
type Sampler interface {
|
||||
ShouldSample(SamplingParameters) SamplingResult
|
||||
ShouldSample(parameters SamplingParameters) SamplingResult
|
||||
Description() string
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user