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