mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-24 20:14:40 +02:00
Add godot linter to golangci (#2845)
Comment should be complete sentences outside of lists with sentence fragments. This adds the godot linter to check these complete sentences end with punctuation. If they do not, running fix will append a period.
This commit is contained in:
parent
b8e4241a32
commit
fdfc821bac
@ -15,6 +15,7 @@ linters:
|
||||
- goimports
|
||||
- gosimple
|
||||
- govet
|
||||
- godot
|
||||
- ineffassign
|
||||
- misspell
|
||||
- revive
|
||||
@ -45,3 +46,9 @@ linters-settings:
|
||||
- cancelled
|
||||
goimports:
|
||||
local-prefixes: go.opentelemetry.io
|
||||
godot:
|
||||
exclude:
|
||||
# Exclude sentence fragments for lists.
|
||||
- '^[ ]*[-•]'
|
||||
# Exclude sentences prefixing a list.
|
||||
- ':$'
|
||||
|
@ -40,7 +40,7 @@ import (
|
||||
var errConversion = errors.New("Unable to convert from OpenCensus to OpenTelemetry")
|
||||
|
||||
// NewMetricExporter returns an OpenCensus exporter that exports to an
|
||||
// OpenTelemetry exporter
|
||||
// OpenTelemetry exporter.
|
||||
func NewMetricExporter(base export.Exporter) metricexport.Exporter {
|
||||
return &exporter{base: base}
|
||||
}
|
||||
@ -51,7 +51,7 @@ type exporter struct {
|
||||
base export.Exporter
|
||||
}
|
||||
|
||||
// ExportMetrics implements the OpenCensus metric Exporter interface
|
||||
// ExportMetrics implements the OpenCensus metric Exporter interface.
|
||||
func (e *exporter) ExportMetrics(ctx context.Context, metrics []*metricdata.Metric) error {
|
||||
res := resource.Empty()
|
||||
if len(metrics) != 0 {
|
||||
@ -147,7 +147,7 @@ func convertResource(res *ocresource.Resource) *resource.Resource {
|
||||
return resource.NewSchemaless(attrs...)
|
||||
}
|
||||
|
||||
// convertDescriptor converts an OpenCensus Descriptor to an OpenTelemetry Descriptor
|
||||
// convertDescriptor converts an OpenCensus Descriptor to an OpenTelemetry Descriptor.
|
||||
func convertDescriptor(ocDescriptor metricdata.Descriptor) (sdkapi.Descriptor, error) {
|
||||
var (
|
||||
nkind number.Kind
|
||||
|
@ -40,7 +40,7 @@ import (
|
||||
var (
|
||||
// instrumenttype differentiates between our gauge and view metrics.
|
||||
keyType = tag.MustNewKey("instrumenttype")
|
||||
// Counts the number of lines read in from standard input
|
||||
// Counts the number of lines read in from standard input.
|
||||
countMeasure = stats.Int64("test_count", "A count of something", stats.UnitDimensionless)
|
||||
countView = &view.View{
|
||||
Name: "test_count",
|
||||
|
@ -44,7 +44,7 @@ func New(next func(r *http.Request)) *Handler {
|
||||
}
|
||||
}
|
||||
|
||||
// HandleHTTPReq mimics what an instrumented http server does
|
||||
// HandleHTTPReq mimics what an instrumented http server does.
|
||||
func (h *Handler) HandleHTTPReq(r *http.Request) {
|
||||
ctx := h.propagators.Extract(r.Context(), propagation.HeaderCarrier(r.Header))
|
||||
var span trace.Span
|
||||
@ -58,7 +58,7 @@ func (h *Handler) HandleHTTPReq(r *http.Request) {
|
||||
h.makeOutgoingRequest(ctx)
|
||||
}
|
||||
|
||||
// makeOutgoingRequest mimics what an instrumented http client does
|
||||
// makeOutgoingRequest mimics what an instrumented http client does.
|
||||
func (h *Handler) makeOutgoingRequest(ctx context.Context) {
|
||||
// make a new http request
|
||||
r, err := http.NewRequest("", "", nil)
|
||||
|
@ -73,7 +73,7 @@ func initPassthroughGlobals() {
|
||||
}
|
||||
|
||||
// nonGlobalTracer creates a trace provider instance for testing, but doesn't
|
||||
// set it as the global tracer provider
|
||||
// set it as the global tracer provider.
|
||||
func nonGlobalTracer() *sdktrace.TracerProvider {
|
||||
var err error
|
||||
exp, err := stdouttrace.New(stdouttrace.WithPrettyPrint())
|
||||
|
@ -29,7 +29,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// udpPacketMaxLength is the max size of UDP packet we want to send, synced with jaeger-agent
|
||||
// udpPacketMaxLength is the max size of UDP packet we want to send, synced with jaeger-agent.
|
||||
udpPacketMaxLength = 65000
|
||||
// emitBatchOverhead is the additional overhead bytes used for enveloping the datagram,
|
||||
// synced with jaeger-agent https://github.com/jaegertracing/jaeger-client-go/blob/master/transport_udp.go#L37
|
||||
|
@ -18,13 +18,13 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Environment variable names
|
||||
// Environment variable names.
|
||||
const (
|
||||
// Hostname for the Jaeger agent, part of address where exporter sends spans
|
||||
// i.e. "localhost"
|
||||
// i.e. "localhost".
|
||||
envAgentHost = "OTEL_EXPORTER_JAEGER_AGENT_HOST"
|
||||
// Port for the Jaeger agent, part of address where exporter sends spans
|
||||
// i.e. 6831
|
||||
// i.e. 6831.
|
||||
envAgentPort = "OTEL_EXPORTER_JAEGER_AGENT_PORT"
|
||||
// The HTTP endpoint for sending spans directly to a collector,
|
||||
// i.e. http://jaeger-collector:14268/api/traces.
|
||||
@ -35,7 +35,7 @@ const (
|
||||
envPassword = "OTEL_EXPORTER_JAEGER_PASSWORD"
|
||||
)
|
||||
|
||||
// envOr returns an env variable's value if it is exists or the default if not
|
||||
// envOr returns an env variable's value if it is exists or the default if not.
|
||||
func envOr(key, defaultValue string) string {
|
||||
if v, ok := os.LookupEnv(key); ok && v != "" {
|
||||
return v
|
||||
|
@ -134,7 +134,7 @@ func (c *reconnectingUDPConn) attemptDialNewAddr(newAddr *net.UDPAddr) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Write calls net.udpConn.Write, if it fails an attempt is made to connect to a new addr, if that succeeds the write is retried before returning
|
||||
// Write calls net.udpConn.Write, if it fails an attempt is made to connect to a new addr, if that succeeds the write is retried before returning.
|
||||
func (c *reconnectingUDPConn) Write(b []byte) (int, error) {
|
||||
var bytesWritten int
|
||||
var err error
|
||||
@ -167,7 +167,7 @@ func (c *reconnectingUDPConn) Write(b []byte) (int, error) {
|
||||
return bytesWritten, err
|
||||
}
|
||||
|
||||
// Close stops the reconnectLoop, then closes the connection via net.udpConn 's implementation
|
||||
// Close stops the reconnectLoop, then closes the connection via net.udpConn 's implementation.
|
||||
func (c *reconnectingUDPConn) Close() error {
|
||||
close(c.closeChan)
|
||||
|
||||
@ -183,7 +183,7 @@ func (c *reconnectingUDPConn) Close() error {
|
||||
}
|
||||
|
||||
// SetWriteBuffer defers to the net.udpConn SetWriteBuffer implementation wrapped with a RLock. if no conn is currently held
|
||||
// and SetWriteBuffer is called store bufferBytes to be set for new conns
|
||||
// and SetWriteBuffer is called store bufferBytes to be set for new conns.
|
||||
func (c *reconnectingUDPConn) SetWriteBuffer(bytes int) error {
|
||||
var err error
|
||||
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"go.opentelemetry.io/otel/exporters/jaeger/internal/third_party/thrift/lib/go/thrift"
|
||||
)
|
||||
|
||||
// batchUploader send a batch of spans to Jaeger
|
||||
// batchUploader send a batch of spans to Jaeger.
|
||||
type batchUploader interface {
|
||||
upload(context.Context, *gen.Batch) error
|
||||
shutdown(context.Context) error
|
||||
|
@ -25,17 +25,17 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ConfigFn is the generic function used to set a config
|
||||
// ConfigFn is the generic function used to set a config.
|
||||
type ConfigFn func(*EnvOptionsReader)
|
||||
|
||||
// EnvOptionsReader reads the required environment variables
|
||||
// EnvOptionsReader reads the required environment variables.
|
||||
type EnvOptionsReader struct {
|
||||
GetEnv func(string) string
|
||||
ReadFile func(string) ([]byte, error)
|
||||
Namespace string
|
||||
}
|
||||
|
||||
// Apply runs every ConfigFn
|
||||
// Apply runs every ConfigFn.
|
||||
func (e *EnvOptionsReader) Apply(opts ...ConfigFn) {
|
||||
for _, o := range opts {
|
||||
o(e)
|
||||
@ -50,7 +50,7 @@ func (e *EnvOptionsReader) GetEnvValue(key string) (string, bool) {
|
||||
return v, v != ""
|
||||
}
|
||||
|
||||
// WithString retrieves the specified config and passes it to ConfigFn as a string
|
||||
// WithString retrieves the specified config and passes it to ConfigFn as a string.
|
||||
func WithString(n string, fn func(string)) func(e *EnvOptionsReader) {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
@ -59,7 +59,7 @@ func WithString(n string, fn func(string)) func(e *EnvOptionsReader) {
|
||||
}
|
||||
}
|
||||
|
||||
// WithDuration retrieves the specified config and passes it to ConfigFn as a duration
|
||||
// WithDuration retrieves the specified config and passes it to ConfigFn as a duration.
|
||||
func WithDuration(n string, fn func(time.Duration)) func(e *EnvOptionsReader) {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
@ -70,7 +70,7 @@ func WithDuration(n string, fn func(time.Duration)) func(e *EnvOptionsReader) {
|
||||
}
|
||||
}
|
||||
|
||||
// WithHeaders retrieves the specified config and passes it to ConfigFn as a map of HTTP headers
|
||||
// WithHeaders retrieves the specified config and passes it to ConfigFn as a map of HTTP headers.
|
||||
func WithHeaders(n string, fn func(map[string]string)) func(e *EnvOptionsReader) {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
@ -79,7 +79,7 @@ func WithHeaders(n string, fn func(map[string]string)) func(e *EnvOptionsReader)
|
||||
}
|
||||
}
|
||||
|
||||
// WithURL retrieves the specified config and passes it to ConfigFn as a net/url.URL
|
||||
// WithURL retrieves the specified config and passes it to ConfigFn as a net/url.URL.
|
||||
func WithURL(n string, fn func(*url.URL)) func(e *EnvOptionsReader) {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
@ -90,7 +90,7 @@ func WithURL(n string, fn func(*url.URL)) func(e *EnvOptionsReader) {
|
||||
}
|
||||
}
|
||||
|
||||
// WithTLSConfig retrieves the specified config and passes it to ConfigFn as a crypto/tls.Config
|
||||
// WithTLSConfig retrieves the specified config and passes it to ConfigFn as a crypto/tls.Config.
|
||||
func WithTLSConfig(n string, fn func(*tls.Config)) func(e *EnvOptionsReader) {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
|
@ -40,7 +40,7 @@ var (
|
||||
|
||||
// ErrIncompatibleAgg is returned when
|
||||
// aggregation.Kind implies an interface conversion that has
|
||||
// failed
|
||||
// failed.
|
||||
ErrIncompatibleAgg = errors.New("incompatible aggregation type")
|
||||
|
||||
// ErrUnknownValueType is returned when a transformation of an unknown value
|
||||
|
@ -26,14 +26,14 @@ import (
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal/envconfig"
|
||||
)
|
||||
|
||||
// DefaultEnvOptionsReader is the default environments reader
|
||||
// DefaultEnvOptionsReader is the default environments reader.
|
||||
var DefaultEnvOptionsReader = envconfig.EnvOptionsReader{
|
||||
GetEnv: os.Getenv,
|
||||
ReadFile: ioutil.ReadFile,
|
||||
Namespace: "OTEL_EXPORTER_OTLP",
|
||||
}
|
||||
|
||||
// ApplyGRPCEnvConfigs applies the env configurations for gRPC
|
||||
// ApplyGRPCEnvConfigs applies the env configurations for gRPC.
|
||||
func ApplyGRPCEnvConfigs(cfg Config) Config {
|
||||
opts := getOptionsFromEnv()
|
||||
for _, opt := range opts {
|
||||
@ -42,7 +42,7 @@ func ApplyGRPCEnvConfigs(cfg Config) Config {
|
||||
return cfg
|
||||
}
|
||||
|
||||
// ApplyHTTPEnvConfigs applies the env configurations for HTTP
|
||||
// ApplyHTTPEnvConfigs applies the env configurations for HTTP.
|
||||
func ApplyHTTPEnvConfigs(cfg Config) Config {
|
||||
opts := getOptionsFromEnv()
|
||||
for _, opt := range opts {
|
||||
@ -104,7 +104,7 @@ func withEndpointForGRPC(u *url.URL) func(cfg Config) Config {
|
||||
}
|
||||
}
|
||||
|
||||
// WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression
|
||||
// WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression.
|
||||
func WithEnvCompression(n string, fn func(Compression)) func(e *envconfig.EnvOptionsReader) {
|
||||
return func(e *envconfig.EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
|
@ -163,7 +163,7 @@ func TestNewExporterInvokeStartThenStopManyTimes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// This test takes a long time to run: to skip it, run tests using: -short
|
||||
// This test takes a long time to run: to skip it, run tests using: -short.
|
||||
func TestNewExporterCollectorOnBadConnection(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skipf("Skipping this long running test")
|
||||
|
@ -139,7 +139,7 @@ func (mc *mockCollector) GetMetrics() []*metricpb.Metric {
|
||||
return mc.getMetrics()
|
||||
}
|
||||
|
||||
// runMockCollector is a helper function to create a mock Collector
|
||||
// runMockCollector is a helper function to create a mock Collector.
|
||||
func runMockCollector(t *testing.T) *mockCollector {
|
||||
return runMockCollectorAtEndpoint(t, "localhost:0")
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ func NewClient(opts ...Option) otlpmetric.Client {
|
||||
}
|
||||
}
|
||||
|
||||
// Start does nothing in a HTTP client
|
||||
// Start does nothing in a HTTP client.
|
||||
func (d *client) Start(ctx context.Context) error {
|
||||
// nothing to do
|
||||
select {
|
||||
|
@ -26,14 +26,14 @@ import (
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal/envconfig"
|
||||
)
|
||||
|
||||
// DefaultEnvOptionsReader is the default environments reader
|
||||
// DefaultEnvOptionsReader is the default environments reader.
|
||||
var DefaultEnvOptionsReader = envconfig.EnvOptionsReader{
|
||||
GetEnv: os.Getenv,
|
||||
ReadFile: ioutil.ReadFile,
|
||||
Namespace: "OTEL_EXPORTER_OTLP",
|
||||
}
|
||||
|
||||
// ApplyGRPCEnvConfigs applies the env configurations for gRPC
|
||||
// ApplyGRPCEnvConfigs applies the env configurations for gRPC.
|
||||
func ApplyGRPCEnvConfigs(cfg Config) Config {
|
||||
opts := getOptionsFromEnv()
|
||||
for _, opt := range opts {
|
||||
@ -42,7 +42,7 @@ func ApplyGRPCEnvConfigs(cfg Config) Config {
|
||||
return cfg
|
||||
}
|
||||
|
||||
// ApplyHTTPEnvConfigs applies the env configurations for HTTP
|
||||
// ApplyHTTPEnvConfigs applies the env configurations for HTTP.
|
||||
func ApplyHTTPEnvConfigs(cfg Config) Config {
|
||||
opts := getOptionsFromEnv()
|
||||
for _, opt := range opts {
|
||||
@ -113,7 +113,7 @@ func withEndpointForGRPC(u *url.URL) func(cfg Config) Config {
|
||||
}
|
||||
}
|
||||
|
||||
// WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression
|
||||
// WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression.
|
||||
func WithEnvCompression(n string, fn func(Compression)) func(e *envconfig.EnvOptionsReader) {
|
||||
return func(e *envconfig.EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
|
@ -37,7 +37,7 @@ const (
|
||||
GzipCompression
|
||||
)
|
||||
|
||||
// Marshaler describes the kind of message format sent to the collector
|
||||
// Marshaler describes the kind of message format sent to the collector.
|
||||
type Marshaler int
|
||||
|
||||
const (
|
||||
|
@ -167,7 +167,7 @@ func TestNewInvokeStartThenStopManyTimes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// This test takes a long time to run: to skip it, run tests using: -short
|
||||
// This test takes a long time to run: to skip it, run tests using: -short.
|
||||
func TestNewCollectorOnBadConnection(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skipf("Skipping this long running test")
|
||||
|
@ -150,7 +150,7 @@ func (mc *mockCollector) getHeaders() metadata.MD {
|
||||
return mc.traceSvc.getHeaders()
|
||||
}
|
||||
|
||||
// runMockCollector is a helper function to create a mock Collector
|
||||
// runMockCollector is a helper function to create a mock Collector.
|
||||
func runMockCollector(t *testing.T) *mockCollector {
|
||||
return runMockCollectorAtEndpoint(t, "localhost:0")
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ func NewClient(opts ...Option) otlptrace.Client {
|
||||
}
|
||||
}
|
||||
|
||||
// Start does nothing in a HTTP client
|
||||
// Start does nothing in a HTTP client.
|
||||
func (d *client) Start(ctx context.Context) error {
|
||||
// nothing to do
|
||||
select {
|
||||
|
@ -40,7 +40,7 @@ func sanitize(s string) string {
|
||||
return s
|
||||
}
|
||||
|
||||
// converts anything that is not a letter or digit to an underscore
|
||||
// converts anything that is not a letter or digit to an underscore.
|
||||
func sanitizeRune(r rune) rune {
|
||||
if unicode.IsLetter(r) || unicode.IsDigit(r) {
|
||||
return r
|
||||
|
@ -16,13 +16,13 @@ package zipkin // import "go.opentelemetry.io/otel/exporters/zipkin"
|
||||
|
||||
import "os"
|
||||
|
||||
// Environment variable names
|
||||
// Environment variable names.
|
||||
const (
|
||||
// Endpoint for Zipkin collector
|
||||
// Endpoint for Zipkin collector.
|
||||
envEndpoint = "OTEL_EXPORTER_ZIPKIN_ENDPOINT"
|
||||
)
|
||||
|
||||
// envOr returns an env variable's value if it is exists or the default if not
|
||||
// envOr returns an env variable's value if it is exists or the default if not.
|
||||
func envOr(key, defaultValue string) string {
|
||||
if v, ok := os.LookupEnv(key); ok && v != "" {
|
||||
return v
|
||||
|
@ -168,7 +168,7 @@ func attributesToJSONMapString(attributes []attribute.KeyValue) string {
|
||||
return (string)(jsonBytes)
|
||||
}
|
||||
|
||||
// attributeToStringPair serializes each attribute to a string pair
|
||||
// attributeToStringPair serializes each attribute to a string pair.
|
||||
func attributeToStringPair(kv attribute.KeyValue) (string, string) {
|
||||
switch kv.Value.Type() {
|
||||
// For slice attributes, serialize as JSON list string.
|
||||
@ -189,7 +189,7 @@ func attributeToStringPair(kv attribute.KeyValue) (string, string) {
|
||||
}
|
||||
}
|
||||
|
||||
// extraZipkinTags are those that may be added to every outgoing span
|
||||
// extraZipkinTags are those that may be added to every outgoing span.
|
||||
var extraZipkinTags = []string{
|
||||
"otel.status_code",
|
||||
keyInstrumentationLibraryName,
|
||||
|
@ -92,7 +92,7 @@ func SetErrorHandler(h ErrorHandler) {
|
||||
globalErrorHandler.setDelegate(h)
|
||||
}
|
||||
|
||||
// Handle is a convenience function for ErrorHandler().Handle(err)
|
||||
// Handle is a convenience function for ErrorHandler().Handle(err).
|
||||
func Handle(err error) {
|
||||
GetErrorHandler().Handle(err)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ var globalLoggerLock = &sync.RWMutex{}
|
||||
// SetLogger overrides the globalLogger with l.
|
||||
//
|
||||
// To see Info messages use a logger with `l.V(1).Enabled() == true`
|
||||
// To see Debug messages use a logger with `l.V(5).Enabled() == true`
|
||||
// To see Debug messages use a logger with `l.V(5).Enabled() == true`.
|
||||
func SetLogger(l logr.Logger) {
|
||||
globalLoggerLock.Lock()
|
||||
defer globalLoggerLock.Unlock()
|
||||
@ -41,7 +41,7 @@ func SetLogger(l logr.Logger) {
|
||||
}
|
||||
|
||||
// Info prints messages about the general state of the API or SDK.
|
||||
// This should usually be less then 5 messages a minute
|
||||
// This should usually be less then 5 messages a minute.
|
||||
func Info(msg string, keysAndValues ...interface{}) {
|
||||
globalLoggerLock.RLock()
|
||||
defer globalLoggerLock.RUnlock()
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
// ResetForTest configures the test to restores the initial global state during
|
||||
// its Cleanup step
|
||||
// its Cleanup step.
|
||||
func ResetForTest(t testing.TB) {
|
||||
t.Cleanup(func() {
|
||||
globalTracer = defaultTracerValue()
|
||||
|
@ -110,7 +110,7 @@ func ExampleMeter_asynchronous_multiple() {
|
||||
}
|
||||
}
|
||||
|
||||
//This is just an example, see the the contrib runtime instrumentation for real implementation
|
||||
//This is just an example, see the the contrib runtime instrumentation for real implementation.
|
||||
func computeGCPauses(ctx context.Context, recorder syncfloat64.Histogram, pauseBuff []uint64) {
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
// that code provides built-in instrumentation. If the instrumentationName is
|
||||
// empty, then a implementation defined default name will be used instead.
|
||||
//
|
||||
// This is short for MeterProvider().Meter(name)
|
||||
// This is short for MeterProvider().Meter(name).
|
||||
func Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter {
|
||||
return MeterProvider().Meter(instrumentationName, opts...)
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ func (i *aiGauge) unwrap() instrument.Asynchronous {
|
||||
return nil
|
||||
}
|
||||
|
||||
//Sync Instruments
|
||||
//Sync Instruments.
|
||||
type sfCounter struct {
|
||||
name string
|
||||
opts []instrument.Option
|
||||
|
@ -201,7 +201,7 @@ func unwrapInstruments(instruments []instrument.Asynchronous) []instrument.Async
|
||||
return out
|
||||
}
|
||||
|
||||
// SyncInt64 is the namespace for the Synchronous Integer instruments
|
||||
// SyncInt64 is the namespace for the Synchronous Integer instruments.
|
||||
func (m *meter) SyncInt64() syncint64.InstrumentProvider {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.SyncInt64()
|
||||
@ -209,7 +209,7 @@ func (m *meter) SyncInt64() syncint64.InstrumentProvider {
|
||||
return (*siInstProvider)(m)
|
||||
}
|
||||
|
||||
// SyncFloat64 is the namespace for the Synchronous Float instruments
|
||||
// SyncFloat64 is the namespace for the Synchronous Float instruments.
|
||||
func (m *meter) SyncFloat64() syncfloat64.InstrumentProvider {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.SyncFloat64()
|
||||
|
@ -69,19 +69,19 @@ func (m *testMeter) RegisterCallback(insts []instrument.Asynchronous, function f
|
||||
return nil
|
||||
}
|
||||
|
||||
// SyncInt64 is the namespace for the Synchronous Integer instruments
|
||||
// SyncInt64 is the namespace for the Synchronous Integer instruments.
|
||||
func (m *testMeter) SyncInt64() syncint64.InstrumentProvider {
|
||||
m.siCount++
|
||||
return &testSIInstrumentProvider{}
|
||||
}
|
||||
|
||||
// SyncFloat64 is the namespace for the Synchronous Float instruments
|
||||
// SyncFloat64 is the namespace for the Synchronous Float instruments.
|
||||
func (m *testMeter) SyncFloat64() syncfloat64.InstrumentProvider {
|
||||
m.sfCount++
|
||||
return &testSFInstrumentProvider{}
|
||||
}
|
||||
|
||||
// This enables async collection
|
||||
// This enables async collection.
|
||||
func (m *testMeter) collect() {
|
||||
ctx := context.Background()
|
||||
for _, f := range m.callbacks {
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
package types // import "go.opentelemetry.io/otel/schema/v1.0/types"
|
||||
|
||||
// TelemetryVersion is a version number key in the schema file (e.g. "1.7.0")
|
||||
// TelemetryVersion is a version number key in the schema file (e.g. "1.7.0").
|
||||
type TelemetryVersion string
|
||||
|
||||
// SpanName is span name string.
|
||||
|
51
sdk/internal/env/env.go
vendored
51
sdk/internal/env/env.go
vendored
@ -21,56 +21,47 @@ import (
|
||||
"go.opentelemetry.io/otel/internal/global"
|
||||
)
|
||||
|
||||
// Environment variable names
|
||||
// Environment variable names.
|
||||
const (
|
||||
// BatchSpanProcessorScheduleDelayKey
|
||||
// Delay interval between two consecutive exports.
|
||||
// i.e. 5000
|
||||
// BatchSpanProcessorScheduleDelayKey is the delay interval between two
|
||||
// consecutive exports (i.e. 5000).
|
||||
BatchSpanProcessorScheduleDelayKey = "OTEL_BSP_SCHEDULE_DELAY"
|
||||
// BatchSpanProcessorExportTimeoutKey
|
||||
// Maximum allowed time to export data.
|
||||
// i.e. 3000
|
||||
// BatchSpanProcessorExportTimeoutKey is the maximum allowed time to
|
||||
// export data (i.e. 3000).
|
||||
BatchSpanProcessorExportTimeoutKey = "OTEL_BSP_EXPORT_TIMEOUT"
|
||||
// BatchSpanProcessorMaxQueueSizeKey
|
||||
// Maximum queue size
|
||||
// i.e. 2048
|
||||
// BatchSpanProcessorMaxQueueSizeKey is the maximum queue size (i.e. 2048).
|
||||
BatchSpanProcessorMaxQueueSizeKey = "OTEL_BSP_MAX_QUEUE_SIZE"
|
||||
// BatchSpanProcessorMaxExportBatchSizeKey
|
||||
// Maximum batch size
|
||||
// Note: Must be less than or equal to EnvBatchSpanProcessorMaxQueueSize
|
||||
// i.e. 512
|
||||
// BatchSpanProcessorMaxExportBatchSizeKey is the maximum batch size (i.e.
|
||||
// 512). Note: it must be less than or equal to
|
||||
// EnvBatchSpanProcessorMaxQueueSize.
|
||||
BatchSpanProcessorMaxExportBatchSizeKey = "OTEL_BSP_MAX_EXPORT_BATCH_SIZE"
|
||||
|
||||
// AttributeValueLengthKey
|
||||
// Maximum allowed attribute value size.
|
||||
// AttributeValueLengthKey is the maximum allowed attribute value size.
|
||||
AttributeValueLengthKey = "OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT"
|
||||
|
||||
// AttributeCountKey
|
||||
// Maximum allowed span attribute count
|
||||
// AttributeCountKey is the maximum allowed span attribute count.
|
||||
AttributeCountKey = "OTEL_ATTRIBUTE_COUNT_LIMIT"
|
||||
|
||||
// SpanAttributeValueLengthKey
|
||||
// Maximum allowed attribute value size for a span.
|
||||
// SpanAttributeValueLengthKey is the maximum allowed attribute value size
|
||||
// for a span.
|
||||
SpanAttributeValueLengthKey = "OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT"
|
||||
|
||||
// SpanAttributeCountKey
|
||||
// Maximum allowed span attribute count for a span.
|
||||
// SpanAttributeCountKey is the maximum allowed span attribute count for a
|
||||
// span.
|
||||
SpanAttributeCountKey = "OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT"
|
||||
|
||||
// SpanEventCountKey
|
||||
// Maximum allowed span event count.
|
||||
// SpanEventCountKey is the maximum allowed span event count.
|
||||
SpanEventCountKey = "OTEL_SPAN_EVENT_COUNT_LIMIT"
|
||||
|
||||
// SpanEventAttributeCountKey
|
||||
// Maximum allowed attribute per span event count.
|
||||
// SpanEventAttributeCountKey is the maximum allowed attribute per span
|
||||
// event count.
|
||||
SpanEventAttributeCountKey = "OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT"
|
||||
|
||||
// SpanLinkCountKey
|
||||
// Maximum allowed span link count.
|
||||
// SpanLinkCountKey is the maximum allowed span link count.
|
||||
SpanLinkCountKey = "OTEL_SPAN_LINK_COUNT_LIMIT"
|
||||
|
||||
// SpanLinkAttributeCountKey
|
||||
// Maximum allowed attribute per span link count.
|
||||
// SpanLinkAttributeCountKey is the maximum allowed attribute per span
|
||||
// link count.
|
||||
SpanLinkAttributeCountKey = "OTEL_LINK_ATTRIBUTE_COUNT_LIMIT"
|
||||
)
|
||||
|
||||
|
@ -29,11 +29,11 @@ const (
|
||||
SignificandMask = 1<<SignificandWidth - 1
|
||||
|
||||
// ExponentBias is the exponent bias specified for encoding
|
||||
// the IEEE 754 double-precision floating point exponent: 1023
|
||||
// the IEEE 754 double-precision floating point exponent: 1023.
|
||||
ExponentBias = 1<<(ExponentWidth-1) - 1
|
||||
|
||||
// ExponentMask are set to 1 for the bits of an IEEE 754
|
||||
// floating point exponent: 0x7FF0000000000000
|
||||
// floating point exponent: 0x7FF0000000000000.
|
||||
ExponentMask = ((1 << ExponentWidth) - 1) << SignificandWidth
|
||||
|
||||
// SignMask selects the sign bit of an IEEE 754 floating point
|
||||
@ -41,11 +41,11 @@ const (
|
||||
SignMask = (1 << (SignificandWidth + ExponentWidth))
|
||||
|
||||
// MinNormalExponent is the minimum exponent of a normalized
|
||||
// floating point: -1022
|
||||
// floating point: -1022.
|
||||
MinNormalExponent int32 = -ExponentBias + 1
|
||||
|
||||
// MaxNormalExponent is the maximum exponent of a normalized
|
||||
// floating point: 1023
|
||||
// floating point: 1023.
|
||||
MaxNormalExponent int32 = ExponentBias
|
||||
|
||||
// MinValue is the smallest normal number.
|
||||
|
@ -142,7 +142,7 @@ func TestLogarithmIndexMax(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestLogarithmIndexMin ensures that for every valid scale, Non-zero numbers
|
||||
// TestLogarithmIndexMin ensures that for every valid scale, Non-zero numbers.
|
||||
func TestLogarithmIndexMin(t *testing.T) {
|
||||
for scale := MinScale; scale <= MaxScale; scale++ {
|
||||
m, err := NewMapping(scale)
|
||||
|
@ -88,7 +88,7 @@ var defaultFloat64ExplicitBoundaries = []float64{.005, .01, .025, .05, .1, .25,
|
||||
const defaultInt64ExplicitBoundaryMultiplier = 1e6
|
||||
|
||||
// defaultInt64ExplicitBoundaries applies a multiplier to the default
|
||||
// float64 boundaries: [ 5K, 10K, 25K, ..., 2.5M, 5M, 10M ]
|
||||
// float64 boundaries: [ 5K, 10K, 25K, ..., 2.5M, 5M, 10M ].
|
||||
var defaultInt64ExplicitBoundaries = func(bounds []float64) (asint []float64) {
|
||||
for _, f := range bounds {
|
||||
asint = append(asint, defaultInt64ExplicitBoundaryMultiplier*f)
|
||||
|
@ -109,7 +109,7 @@ func TestHistogramPositiveAndNegative(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// Validates count, sum and buckets for a given profile and policy
|
||||
// Validates count, sum and buckets for a given profile and policy.
|
||||
func testHistogram(t *testing.T, profile aggregatortest.Profile, policy policy) {
|
||||
descriptor := aggregatortest.NewAggregatorTest(sdkapi.HistogramInstrumentKind, profile.NumberKind)
|
||||
|
||||
|
@ -55,7 +55,7 @@ type (
|
||||
// Buckets represents histogram buckets boundaries and counts.
|
||||
//
|
||||
// For a Histogram with N defined boundaries, e.g, [x, y, z].
|
||||
// There are N+1 counts: [-inf, x), [x, y), [y, z), [z, +inf]
|
||||
// There are N+1 counts: [-inf, x), [x, y), [y, z), [z, +inf].
|
||||
Buckets struct {
|
||||
// Boundaries are floating point numbers, even when
|
||||
// aggregating integers.
|
||||
|
@ -34,7 +34,7 @@ const (
|
||||
Float64Kind
|
||||
)
|
||||
|
||||
// Zero returns a zero value for a given Kind
|
||||
// Zero returns a zero value for a given Kind.
|
||||
func (k Kind) Zero() Number {
|
||||
switch k {
|
||||
case Int64Kind:
|
||||
@ -47,7 +47,7 @@ func (k Kind) Zero() Number {
|
||||
}
|
||||
|
||||
// Minimum returns the minimum representable value
|
||||
// for a given Kind
|
||||
// for a given Kind.
|
||||
func (k Kind) Minimum() Number {
|
||||
switch k {
|
||||
case Int64Kind:
|
||||
@ -60,7 +60,7 @@ func (k Kind) Minimum() Number {
|
||||
}
|
||||
|
||||
// Maximum returns the maximum representable value
|
||||
// for a given Kind
|
||||
// for a given Kind.
|
||||
func (k Kind) Maximum() Number {
|
||||
switch k {
|
||||
case Int64Kind:
|
||||
|
@ -70,7 +70,7 @@ func unwrap(impl interface{}, err error) (sdkapi.InstrumentImpl, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO Replace with controller
|
||||
// TODO Replace with controller.
|
||||
func testMeterWithRegistry(name string) metric.Meter {
|
||||
return sdkapi.WrapMeterImpl(
|
||||
registry.NewUniqueInstrumentMeterImpl(
|
||||
|
@ -27,7 +27,7 @@ var (
|
||||
ErrPartialResource = errors.New("partial resource")
|
||||
)
|
||||
|
||||
// Detector detects OpenTelemetry resource information
|
||||
// Detector detects OpenTelemetry resource information.
|
||||
type Detector interface {
|
||||
// DO NOT CHANGE: any modification will not be backwards compatible and
|
||||
// must never be done outside of a new major release.
|
||||
|
@ -92,7 +92,7 @@ func (sd stringDetector) Detect(ctx context.Context) (*Resource, error) {
|
||||
return NewWithAttributes(sd.schemaURL, sd.K.String(value)), nil
|
||||
}
|
||||
|
||||
// Detect implements Detector
|
||||
// Detect implements Detector.
|
||||
func (defaultServiceNameDetector) Detect(ctx context.Context) (*Resource, error) {
|
||||
return StringDetector(
|
||||
semconv.SchemaURL,
|
||||
|
@ -42,10 +42,10 @@ var (
|
||||
// builtin.
|
||||
type fromEnv struct{}
|
||||
|
||||
// compile time assertion that FromEnv implements Detector interface
|
||||
// compile time assertion that FromEnv implements Detector interface.
|
||||
var _ Detector = fromEnv{}
|
||||
|
||||
// Detect collects resources from environment
|
||||
// Detect collects resources from environment.
|
||||
func (fromEnv) Detect(context.Context) (*Resource, error) {
|
||||
attrs := strings.TrimSpace(os.Getenv(resourceAttrKey))
|
||||
svcName := strings.TrimSpace(os.Getenv(svcNameKey))
|
||||
|
@ -31,7 +31,7 @@ const (
|
||||
defaultTracerName = "go.opentelemetry.io/otel/sdk/tracer"
|
||||
)
|
||||
|
||||
// tracerProviderConfig
|
||||
// tracerProviderConfig.
|
||||
type tracerProviderConfig struct {
|
||||
// processors contains collection of SpanProcessors that are processing pipeline
|
||||
// for spans in the trace signal.
|
||||
@ -156,7 +156,7 @@ func (p *TracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.T
|
||||
return t
|
||||
}
|
||||
|
||||
// RegisterSpanProcessor adds the given SpanProcessor to the list of SpanProcessors
|
||||
// RegisterSpanProcessor adds the given SpanProcessor to the list of SpanProcessors.
|
||||
func (p *TracerProvider) RegisterSpanProcessor(s SpanProcessor) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@ -172,7 +172,7 @@ func (p *TracerProvider) RegisterSpanProcessor(s SpanProcessor) {
|
||||
p.spanProcessors.Store(new)
|
||||
}
|
||||
|
||||
// UnregisterSpanProcessor removes the given SpanProcessor from the list of SpanProcessors
|
||||
// UnregisterSpanProcessor removes the given SpanProcessor from the list of SpanProcessors.
|
||||
func (p *TracerProvider) UnregisterSpanProcessor(s SpanProcessor) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
|
@ -53,17 +53,17 @@ type SamplingParameters struct {
|
||||
// SamplingDecision indicates whether a span is dropped, recorded and/or sampled.
|
||||
type SamplingDecision uint8
|
||||
|
||||
// Valid sampling decisions
|
||||
// Valid sampling decisions.
|
||||
const (
|
||||
// Drop will not record the span and all attributes/events will be dropped
|
||||
// Drop will not record the span and all attributes/events will be dropped.
|
||||
Drop SamplingDecision = iota
|
||||
|
||||
// Record indicates the span's `IsRecording() == true`, but `Sampled` flag
|
||||
// *must not* be set
|
||||
// *must not* be set.
|
||||
RecordOnly
|
||||
|
||||
// RecordAndSample has span's `IsRecording() == true` and `Sampled` flag
|
||||
// *must* be set
|
||||
// *must* be set.
|
||||
RecordAndSample
|
||||
)
|
||||
|
||||
|
@ -112,8 +112,7 @@ type SpanLimits struct {
|
||||
//
|
||||
// • LinkCountLimit: OTEL_SPAN_LINK_COUNT_LIMIT (default: 128)
|
||||
//
|
||||
// • AttributePerLinkCountLimit: OTEL_LINK_ATTRIBUTE_COUNT_LIMIT (default:
|
||||
// 128)
|
||||
// • AttributePerLinkCountLimit: OTEL_LINK_ATTRIBUTE_COUNT_LIMIT (default: 128)
|
||||
func NewSpanLimits() SpanLimits {
|
||||
return SpanLimits{
|
||||
AttributeValueLengthLimit: env.SpanAttributeValueLength(DefaultAttributeValueLengthLimit),
|
||||
|
@ -1777,7 +1777,7 @@ func (s stateSampler) Description() string {
|
||||
return "stateSampler"
|
||||
}
|
||||
|
||||
// Check that a new span propagates the SamplerResult.TraceState
|
||||
// Check that a new span propagates the SamplerResult.TraceState.
|
||||
func TestSamplerTraceState(t *testing.T) {
|
||||
mustTS := func(ts trace.TraceState, err error) trace.TraceState {
|
||||
require.NoError(t, err)
|
||||
|
@ -124,7 +124,7 @@ func NewSpanEndConfig(options ...SpanEndOption) SpanConfig {
|
||||
}
|
||||
|
||||
// SpanStartOption applies an option to a SpanConfig. These options are applicable
|
||||
// only when the span is created
|
||||
// only when the span is created.
|
||||
type SpanStartOption interface {
|
||||
applySpanStart(SpanConfig) SpanConfig
|
||||
}
|
||||
|
@ -85,5 +85,5 @@ func (noopSpan) AddEvent(string, ...EventOption) {}
|
||||
// SetName does nothing.
|
||||
func (noopSpan) SetName(string) {}
|
||||
|
||||
// TracerProvider returns a no-op TracerProvider
|
||||
// TracerProvider returns a no-op TracerProvider.
|
||||
func (noopSpan) TracerProvider() TracerProvider { return noopTracerProvider{} }
|
||||
|
@ -63,7 +63,7 @@ func (t TraceID) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(t.String())
|
||||
}
|
||||
|
||||
// String returns the hex string representation form of a TraceID
|
||||
// String returns the hex string representation form of a TraceID.
|
||||
func (t TraceID) String() string {
|
||||
return hex.EncodeToString(t[:])
|
||||
}
|
||||
@ -86,7 +86,7 @@ func (s SpanID) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(s.String())
|
||||
}
|
||||
|
||||
// String returns the hex string representation form of a SpanID
|
||||
// String returns the hex string representation form of a SpanID.
|
||||
func (s SpanID) String() string {
|
||||
return hex.EncodeToString(s[:])
|
||||
}
|
||||
@ -151,7 +151,7 @@ func decodeHex(h string, b []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TraceFlags contains flags that can be set on a SpanContext
|
||||
// TraceFlags contains flags that can be set on a SpanContext.
|
||||
type TraceFlags byte //nolint:revive // revive complains about stutter of `trace.TraceFlags`.
|
||||
|
||||
// IsSampled returns if the sampling bit is set in the TraceFlags.
|
||||
@ -174,7 +174,7 @@ func (tf TraceFlags) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(tf.String())
|
||||
}
|
||||
|
||||
// String returns the hex string representation form of TraceFlags
|
||||
// String returns the hex string representation form of TraceFlags.
|
||||
func (tf TraceFlags) String() string {
|
||||
return hex.EncodeToString([]byte{byte(tf)}[:])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user