Merge pull request #6047 from ktock/fix-build-main

This commit is contained in:
Fu Wei 2021-09-26 23:12:36 +08:00 committed by GitHub
commit f40df655cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 530 additions and 879 deletions

View File

@ -35,6 +35,7 @@ import (
"github.com/containerd/containerd/services/server" "github.com/containerd/containerd/services/server"
srvconfig "github.com/containerd/containerd/services/server/config" srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/containerd/containerd/sys" "github.com/containerd/containerd/sys"
"github.com/containerd/containerd/tracing"
"github.com/containerd/containerd/version" "github.com/containerd/containerd/version"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"

8
go.mod
View File

@ -56,10 +56,10 @@ require (
github.com/urfave/cli v1.22.2 github.com/urfave/cli v1.22.2
go.etcd.io/bbolt v1.3.6 go.etcd.io/bbolt v1.3.6
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.21.0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.21.0
go.opentelemetry.io/otel v1.0.0 go.opentelemetry.io/otel v1.0.0-RC2
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2
go.opentelemetry.io/otel/sdk v1.0.0 go.opentelemetry.io/otel/sdk v1.0.0-RC2
go.opentelemetry.io/otel/trace v1.0.0 go.opentelemetry.io/otel/trace v1.0.0-RC2
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 golang.org/x/net v0.0.0-20210520170846-37e1c6afe023
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c

21
go.sum
View File

@ -579,27 +579,27 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.2
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0/go.mod h1:2AboqHi0CiIZU0qwhtUfCYD1GeUzvvIXWNkhDt7ZMG4= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0/go.mod h1:2AboqHi0CiIZU0qwhtUfCYD1GeUzvvIXWNkhDt7ZMG4=
go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo= go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo=
go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I= go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I=
go.opentelemetry.io/otel v1.0.0 h1:qTTn6x71GVBvoafHK/yaRUmFzI4LcONZD0/kXxl5PHI= go.opentelemetry.io/otel v1.0.0-RC2 h1:SHhxSjB+omnGZPgGlKe+QMp3MyazcOHdQ8qwo89oKbg=
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg= go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM=
go.opentelemetry.io/otel/exporters/otlp v0.20.0 h1:PTNgq9MRmQqqJY0REVbZFvwkYOA85vbdQU/nVfxDyqg= go.opentelemetry.io/otel/exporters/otlp v0.20.0 h1:PTNgq9MRmQqqJY0REVbZFvwkYOA85vbdQU/nVfxDyqg=
go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0 h1:Vv4wbLEjheCTPV07jEav7fyUpJkyftQK7Ss2G7qgdSo= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2 h1:Z/91DSYkOqnVuECrd+hxCU9lzeo5Fihjp28uq0Izfpw=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0/go.mod h1:3VqVbIbjAycfL1C7sIu/Uh/kACIUPWHztt8ODYwR3oM= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2/go.mod h1:T+s8GKi1OqMwPuZ+ouDtZW4vWYpJuzIzh2Matq4Jo9k=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0 h1:B9VtEB1u41Ohnl8U6rMCh1jjedu8HwFh4D0QeB+1N+0= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2 h1:PaSlrCE+hRbamroLGGgFDmzDamCxp7ID+hBvPmOhcSc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0/go.mod h1:zhEt6O5GGJ3NCAICr4hlCPoDb2GQuh4Obb4gZBgkoQQ= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2/go.mod h1:3shayJIFcDqHi9/GT2fAHyMI/bRgc6FO0CAkhaDkhi0=
go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU= go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU=
go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw= go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw=
go.opentelemetry.io/otel/oteltest v1.0.0-RC1 h1:G685iP3XiskCwk/z0eIabL55XUl2gk0cljhGk9sB0Yk= go.opentelemetry.io/otel/oteltest v1.0.0-RC1 h1:G685iP3XiskCwk/z0eIabL55XUl2gk0cljhGk9sB0Yk=
go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4= go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4=
go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc= go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc=
go.opentelemetry.io/otel/sdk v1.0.0 h1:BNPMYUONPNbLneMttKSjQhOTlFLOD9U22HNG1KrIN2Y= go.opentelemetry.io/otel/sdk v1.0.0-RC2 h1:ROuteeSCBaZNjiT9JcFzZepmInDvLktR28Y6qKo8bCs=
go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM= go.opentelemetry.io/otel/sdk v1.0.0-RC2/go.mod h1:fgwHyiDn4e5k40TD9VX243rOxXR+jzsWBZYA2P5jpEw=
go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE= go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE=
go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE=
go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw=
go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg= go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg=
go.opentelemetry.io/otel/trace v1.0.0 h1:TSBr8GTEtKevYMG/2d21M989r5WJYVimhTHBKVEZuh4= go.opentelemetry.io/otel/trace v1.0.0-RC2 h1:dunAP0qDULMIT82atj34m5RgvsIK6LcsXf1c/MsYg1w=
go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs= go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4= go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4=
go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg= go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg=
@ -860,6 +860,7 @@ google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG
google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q= google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=

View File

@ -535,20 +535,20 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.2
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0/go.mod h1:2AboqHi0CiIZU0qwhtUfCYD1GeUzvvIXWNkhDt7ZMG4= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0/go.mod h1:2AboqHi0CiIZU0qwhtUfCYD1GeUzvvIXWNkhDt7ZMG4=
go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo= go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo=
go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I= go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I=
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg= go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM=
go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0/go.mod h1:3VqVbIbjAycfL1C7sIu/Uh/kACIUPWHztt8ODYwR3oM= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2/go.mod h1:T+s8GKi1OqMwPuZ+ouDtZW4vWYpJuzIzh2Matq4Jo9k=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0/go.mod h1:zhEt6O5GGJ3NCAICr4hlCPoDb2GQuh4Obb4gZBgkoQQ= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2/go.mod h1:3shayJIFcDqHi9/GT2fAHyMI/bRgc6FO0CAkhaDkhi0=
go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU= go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU=
go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw= go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw=
go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4= go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4=
go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc= go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc=
go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM= go.opentelemetry.io/otel/sdk v1.0.0-RC2/go.mod h1:fgwHyiDn4e5k40TD9VX243rOxXR+jzsWBZYA2P5jpEw=
go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE= go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE=
go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE=
go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw=
go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg= go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg=
go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs= go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg= go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
@ -804,6 +804,7 @@ google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG
google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q= google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=

View File

@ -10,7 +10,6 @@ coverage.*
gen/ gen/
/example/fib/fib
/example/jaeger/jaeger /example/jaeger/jaeger
/example/namedtracer/namedtracer /example/namedtracer/namedtracer
/example/opencensus/opencensus /example/opencensus/opencensus

View File

@ -8,86 +8,21 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [Unreleased] ## [Unreleased]
### Changed
- NoopMeterProvider is now private and NewNoopMeterProvider must be used to obtain a noopMeterProvider. (#2237)
## [1.0.0] - 2021-09-20
This is the first stable release for the project.
This release includes an API and SDK for the tracing signal that will comply with the stability guarantees defined by the projects [versioning policy](./VERSIONING.md).
### Added ### Added
- OTLP trace exporter now sets the `SchemaURL` field in the exported telemetry if the Tracer has `WithSchemaURL` option. (#2242)
### Fixed
- Slice-valued attributes can correctly be used as map keys. (#2223)
### Removed
- Removed the `"go.opentelemetry.io/otel/exporters/zipkin".WithSDKOptions` function. (#2248)
- Removed the deprecated package `go.opentelemetry.io/otel/oteltest`. (#2234)
- Removed the deprecated package `go.opentelemetry.io/otel/bridge/opencensus/utils`. (#2233)
- Removed deprecated functions, types, and methods from `go.opentelemetry.io/otel/attribute` package.
Use the typed functions and methods added to the package instead. (#2235)
- The `Key.Array` method is removed.
- The `Array` function is removed.
- The `Any` function is removed.
- The `ArrayValue` function is removed.
- The `AsArray` function is removed.
## [1.0.0-RC3] - 2021-09-02
### Added
- Added `ErrorHandlerFunc` to use a function as an `"go.opentelemetry.io/otel".ErrorHandler`. (#2149)
- Added `"go.opentelemetry.io/otel/trace".WithStackTrace` option to add a stack trace when using `span.RecordError` or when panic is handled in `span.End`. (#2163)
- Added typed slice attribute types and functionality to the `go.opentelemetry.io/otel/attribute` package to replace the existing array type and functions. (#2162)
- `BoolSlice`, `IntSlice`, `Int64Slice`, `Float64Slice`, and `StringSlice` replace the use of the `Array` function in the package.
- Added the `go.opentelemetry.io/otel/example/fib` example package.
Included is an example application that computes Fibonacci numbers. (#2203)
### Changed ### Changed
- Metric instruments have been renamed to match the (feature-frozen) metric API specification:
- ValueRecorder becomes Histogram
- ValueObserver becomes Gauge
- SumObserver becomes CounterObserver
- UpDownSumObserver becomes UpDownCounterObserver
The API exported from this project is still considered experimental. (#2202)
- Metric SDK/API implementation type `InstrumentKind` moves into `sdkapi` sub-package. (#2091)
- The Metrics SDK export record no longer contains a Resource pointer, the SDK `"go.opentelemetry.io/otel/sdk/trace/export/metric".Exporter.Export()` function for push-based exporters now takes a single Resource argument, pull-based exporters use `"go.opentelemetry.io/otel/sdk/metric/controller/basic".Controller.Resource()`. (#2120)
- The JSON output of the `go.opentelemetry.io/otel/exporters/stdout/stdouttrace` is harmonized now such that the output is "plain" JSON objects after each other of the form `{ ... } { ... } { ... }`. Earlier the JSON objects describing a span were wrapped in a slice for each `Exporter.ExportSpans` call, like `[ { ... } ][ { ... } { ... } ]`. Outputting JSON object directly after each other is consistent with JSON loggers, and a bit easier to parse and read. (#2196)
- Update the `NewTracerConfig`, `NewSpanStartConfig`, `NewSpanEndConfig`, and `NewEventConfig` function in the `go.opentelemetry.io/otel/trace` package to return their respective configurations as structs instead of pointers to the struct. (#2212)
### Deprecated ### Deprecated
- The `go.opentelemetry.io/otel/bridge/opencensus/utils` package is deprecated.
All functionality from this package now exists in the `go.opentelemetry.io/otel/bridge/opencensus` package.
The functions from that package should be used instead. (#2166)
- The `"go.opentelemetry.io/otel/attribute".Array` function and the related `ARRAY` value type is deprecated.
Use the typed `*Slice` functions and types added to the package instead. (#2162)
- The `"go.opentelemetry.io/otel/attribute".Any` function is deprecated.
Use the typed functions instead. (#2181)
- The `go.opentelemetry.io/otel/oteltest` package is deprecated.
The `"go.opentelemetry.io/otel/sdk/trace/tracetest".SpanRecorder` can be registered with the default SDK (`go.opentelemetry.io/otel/sdk/trace`) as a `SpanProcessor` and used as a replacement for this deprecated package. (#2188)
### Removed ### Removed
- Removed metrics test package `go.opentelemetry.io/otel/sdk/export/metric/metrictest`. (#2105) - Removed metrics test package `go.opentelemetry.io/otel/sdk/export/metric/metrictest`. (#2105)
### Fixed ### Fixed
- The `fromEnv` detector no longer throws an error when `OTEL_RESOURCE_ATTRIBUTES` environment variable is not set or empty. (#2138) ### Security
- Setting the global `ErrorHandler` with `"go.opentelemetry.io/otel".SetErrorHandler` multiple times is now supported. (#2160, #2140)
- The `"go.opentelemetry.io/otel/attribute".Any` function now supports `int32` values. (#2169)
- Multiple calls to `"go.opentelemetry.io/otel/sdk/metric/controller/basic".WithResource()` are handled correctly, and when no resources are provided `"go.opentelemetry.io/otel/sdk/resource".Default()` is used. (#2120)
- The `WithoutTimestamps` option for the `go.opentelemetry.io/otel/exporters/stdout/stdouttrace` exporter causes the exporter to correctly ommit timestamps. (#2195)
- Fixed typos in resources.go. (#2201)
## [1.0.0-RC2] - 2021-07-26 ## [v1.0.0-RC2] - 2021-07-26
### Added ### Added
@ -99,13 +34,12 @@ This release includes an API and SDK for the tracing signal that will comply wit
- Added a new `Link` type under the SDK `otel/sdk/trace` package that counts the number of attributes that were dropped for surpassing the `AttributePerLinkCountLimit` configured in the Span's `SpanLimits`. - Added a new `Link` type under the SDK `otel/sdk/trace` package that counts the number of attributes that were dropped for surpassing the `AttributePerLinkCountLimit` configured in the Span's `SpanLimits`.
This new type replaces the equal-named API `Link` type found in the `otel/trace` package for most usages within the SDK. This new type replaces the equal-named API `Link` type found in the `otel/trace` package for most usages within the SDK.
For example, instances of this type are now returned by the `Links()` function of `ReadOnlySpan`s provided in places like the `OnEnd` function of `SpanProcessor` implementations. (#2118) For example, instances of this type are now returned by the `Links()` function of `ReadOnlySpan`s provided in places like the `OnEnd` function of `SpanProcessor` implementations. (#2118)
- Added the `SpanRecorder` type to the `go.opentelemetry.io/otel/skd/trace/tracetest` package.
This type can be used with the default SDK as a `SpanProcessor` during testing. (#2132)
### Changed ### Changed
- The `SpanModels` function is now exported from the `go.opentelemetry.io/otel/exporters/zipkin` package to convert OpenTelemetry spans into Zipkin model spans. (#2027) - The `SpanModels` function is now exported from the `go.opentelemetry.io/otel/exporters/zipkin` package to convert OpenTelemetry spans into Zipkin model spans. (#2027)
- Rename the `"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc".RetrySettings` to `RetryConfig`. (#2095) - Rename the `"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc".RetrySettings` to `RetryConfig`. (#2095)
- Rename the `"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp".RetrySettings` to `RetryConfig`. (#2095)
### Deprecated ### Deprecated
@ -132,7 +66,6 @@ This release includes an API and SDK for the tracing signal that will comply wit
- The OTel span status is correctly transformed into the OTLP status in the `go.opentelemetry.io/otel/exporters/otlp/otlptrace` package. - The OTel span status is correctly transformed into the OTLP status in the `go.opentelemetry.io/otel/exporters/otlp/otlptrace` package.
This fix will by default set the status to `Unset` if it is not explicitly set to `Ok` or `Error`. (#2099 #2102) This fix will by default set the status to `Unset` if it is not explicitly set to `Ok` or `Error`. (#2099 #2102)
- The `Inject` method for the `"go.opentelemetry.io/otel/propagation".TraceContext` type no longer injects empty `tracestate` values. (#2108) - The `Inject` method for the `"go.opentelemetry.io/otel/propagation".TraceContext` type no longer injects empty `tracestate` values. (#2108)
- Use `6831` as default Jaeger agent port instead of `6832`. (#2131)
## [Experimental Metrics v0.22.0] - 2021-07-19 ## [Experimental Metrics v0.22.0] - 2021-07-19
@ -1539,9 +1472,7 @@ It contains api and sdk for trace and meter.
- CircleCI build CI manifest files. - CircleCI build CI manifest files.
- CODEOWNERS file to track owners of this project. - CODEOWNERS file to track owners of this project.
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.0.0...HEAD [Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.0.0-RC2...HEAD
[1.0.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.0.0
[1.0.0-RC3]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.0.0-RC3
[1.0.0-RC2]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.0.0-RC2 [1.0.0-RC2]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.0.0-RC2
[Experimental Metrics v0.22.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/metric/v0.22.0 [Experimental Metrics v0.22.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/metric/v0.22.0
[1.0.0-RC1]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.0.0-RC1 [1.0.0-RC1]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.0.0-RC1

View File

@ -40,8 +40,8 @@ $(TOOLS)/%: | $(TOOLS)
cd $(TOOLS_MOD_DIR) && \ cd $(TOOLS_MOD_DIR) && \
$(GO) build -o $@ $(PACKAGE) $(GO) build -o $@ $(PACKAGE)
SEMCONVGEN = $(TOOLS)/semconvgen SEMCONVGEN = $(TOOLS)/semconv-gen
$(TOOLS)/semconvgen: PACKAGE=go.opentelemetry.io/build-tools/semconvgen $(TOOLS)/semconv-gen: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/semconv-gen
CROSSLINK = $(TOOLS)/crosslink CROSSLINK = $(TOOLS)/crosslink
$(TOOLS)/crosslink: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/crosslink $(TOOLS)/crosslink: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/crosslink
@ -52,16 +52,13 @@ $(TOOLS)/golangci-lint: PACKAGE=github.com/golangci/golangci-lint/cmd/golangci-l
MISSPELL = $(TOOLS)/misspell MISSPELL = $(TOOLS)/misspell
$(TOOLS)/misspell: PACKAGE= github.com/client9/misspell/cmd/misspell $(TOOLS)/misspell: PACKAGE= github.com/client9/misspell/cmd/misspell
GOCOVMERGE = $(TOOLS)/gocovmerge
$(TOOLS)/gocovmerge: PACKAGE= github.com/wadey/gocovmerge
STRINGER = $(TOOLS)/stringer STRINGER = $(TOOLS)/stringer
$(TOOLS)/stringer: PACKAGE=golang.org/x/tools/cmd/stringer $(TOOLS)/stringer: PACKAGE=golang.org/x/tools/cmd/stringer
$(TOOLS)/gojq: PACKAGE=github.com/itchyny/gojq/cmd/gojq $(TOOLS)/gojq: PACKAGE=github.com/itchyny/gojq/cmd/gojq
.PHONY: tools .PHONY: tools
tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(TOOLS)/gojq $(SEMCONVGEN) tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(STRINGER) $(TOOLS)/gojq $(SEMCONVGEN)
# Build # Build
@ -114,18 +111,19 @@ test:
COVERAGE_MODE = atomic COVERAGE_MODE = atomic
COVERAGE_PROFILE = coverage.out COVERAGE_PROFILE = coverage.out
.PHONY: test-coverage .PHONY: test-coverage
test-coverage: | $(GOCOVMERGE) test-coverage:
@set -e; \ @set -e; \
printf "" > coverage.txt; \ printf "" > coverage.txt; \
for dir in $(ALL_COVERAGE_MOD_DIRS); do \ for dir in $(ALL_COVERAGE_MOD_DIRS); do \
echo "$(GO) test -coverpkg=go.opentelemetry.io/otel/... -covermode=$(COVERAGE_MODE) -coverprofile="$(COVERAGE_PROFILE)" $${dir}/..."; \ echo "$(GO) test -coverpkg=./... -covermode=$(COVERAGE_MODE) -coverprofile="$(COVERAGE_PROFILE)" $${dir}/..."; \
(cd "$${dir}" && \ (cd "$${dir}" && \
$(GO) list ./... \ $(GO) list ./... \
| grep -v third_party \ | grep -v third_party \
| xargs $(GO) test -coverpkg=./... -covermode=$(COVERAGE_MODE) -coverprofile="$(COVERAGE_PROFILE)" && \ | xargs $(GO) test -coverpkg=./... -covermode=$(COVERAGE_MODE) -coverprofile="$(COVERAGE_PROFILE)" && \
$(GO) tool cover -html=coverage.out -o coverage.html); \ $(GO) tool cover -html=coverage.out -o coverage.html); \
[ -f "$${dir}/coverage.out" ] && cat "$${dir}/coverage.out" >> coverage.txt; \
done; \ done; \
$(GOCOVMERGE) $$(find . -name coverage.out) > coverage.txt sed -i.bak -e '2,$$ { /^mode: /d; }' coverage.txt
.PHONY: lint .PHONY: lint
lint: misspell lint-modules | $(GOLANGCI_LINT) lint: misspell lint-modules | $(GOLANGCI_LINT)

View File

@ -11,13 +11,15 @@ It provides a set of APIs to directly measure performance and behavior of your s
## Project Status ## Project Status
| Signal | Status | Project | | Signal | Status | Project |
| ------- | ---------- | ------- | | ------- | ---------------------- | ----------------------------------------------------------- |
| Traces | Stable | N/A | | Traces | Release Candidate | [1.0.0](https://github.com/orgs/open-telemetry/projects/15) |
| Metrics | Alpha | N/A | | Metrics | Development paused [1] | N/A |
| Logs | Frozen [1] | N/A | | Logs | Frozen [2] | N/A |
- [1]: The Logs signal development is halted for this project while we develop both Traces and Metrics. - [1]: The development of the metrics API and SDK has paused due to limited development resources, prioritization of a stable Traces release, and instability of the official overall design from the OpenTelemetry specification.
Pull Requests for metrics related issues are not being accepted currently outside of security vulnerability mitigations.
- [2]: The Logs signal development is halted for this project while we develop both Traces and Metrics.
No Logs Pull Requests are currently being accepted. No Logs Pull Requests are currently being accepted.
Progress and status specific to this repository is tracked in our local Progress and status specific to this repository is tracked in our local

View File

@ -3,8 +3,8 @@
## Semantic Convention Generation ## Semantic Convention Generation
If a new version of the OpenTelemetry Specification has been released it will be necessary to generate a new If a new version of the OpenTelemetry Specification has been released it will be necessary to generate a new
semantic convention package from the YAML definitions in the specification repository. There is a `semconvgen` utility semantic convention package from the YAML definitions in the specification repository. There is a utility in
installed by `make tools` that can be used to generate the a package with the name matching the specification `internal/tools/semconv-gen` that can be used to generate the a package with the name matching the specification
version number under the `semconv` package. This will ideally be done soon after the specification release is version number under the `semconv` package. This will ideally be done soon after the specification release is
tagged. Make sure that the specification repo contains a checkout of the the latest tagged release so that the tagged. Make sure that the specification repo contains a checkout of the the latest tagged release so that the
generated files match the released semantic conventions. generated files match the released semantic conventions.
@ -12,8 +12,9 @@ generated files match the released semantic conventions.
There are currently two categories of semantic conventions that must be generated, `resource` and `trace`. There are currently two categories of semantic conventions that must be generated, `resource` and `trace`.
``` ```
.tools/semconvgen -i /path/to/specification/repo/semantic_conventions/resource -t semconv/template.j2 cd internal/tools/semconv-gen
.tools/semconvgen -i /path/to/specification/repo/semantic_conventions/trace -t semconv/template.j2 go run generator.go -i /path/to/specification/repo/semantic_conventions/resource
go run generator.go -i /path/to/specification/repo/semantic_conventions/trace
``` ```
Using default values for all options other than `input` will result in using the `template.j2` template to Using default values for all options other than `input` will result in using the `template.j2` template to

View File

@ -150,10 +150,10 @@ The `otel` package is refactored to remove its dependencies on `otel/metric` so
it can be released as stable as well. With that done the following release it can be released as stable as well. With that done the following release
candidates are made: candidates are made:
* `otel`: `v1.0.0-RC1` * `otel`: `v1.0.0-rc.1`
* `otel/trace`: `v1.0.0-RC1` * `otel/trace`: `v1.0.0-rc.1`
* `otel/baggage`: `v1.0.0-RC1` * `otel/baggage`: `v1.0.0-rc.1`
* `otel/sdk/trace`: `v1.0.0-RC1` * `otel/sdk/trace`: `v1.0.0-rc.1`
The `otel/metric` and `otel/sdk/metric` modules remain at `v0.14.0`. The `otel/metric` and `otel/sdk/metric` modules remain at `v0.14.0`.
@ -161,10 +161,10 @@ A few minor issues are discovered in the `otel/trace` package. These issues are
resolved with some minor, but backwards incompatible, changes and are released resolved with some minor, but backwards incompatible, changes and are released
as a second release candidate: as a second release candidate:
* `otel`: `v1.0.0-RC2` * `otel`: `v1.0.0-rc.2`
* `otel/trace`: `v1.0.0-RC2` * `otel/trace`: `v1.0.0-rc.2`
* `otel/baggage`: `v1.0.0-RC2` * `otel/baggage`: `v1.0.0-rc.2`
* `otel/sdk/trace`: `v1.0.0-RC2` * `otel/sdk/trace`: `v1.0.0-rc.2`
Notice that all module version numbers are incremented to adhere to our Notice that all module version numbers are incremented to adhere to our
versioning policy. versioning policy.
@ -205,12 +205,12 @@ As we progress, the `otel/metric` and `otel/sdk/metric` packages have reached a
point where they should be evaluated for stability. The `otel` module is point where they should be evaluated for stability. The `otel` module is
reintegrated with the `otel/metric` package and the following release is made: reintegrated with the `otel/metric` package and the following release is made:
* `otel`: `v1.1.0-RC1` * `otel`: `v1.1.0-rc.1`
* `otel/trace`: `v1.1.0-RC1` * `otel/trace`: `v1.1.0-rc.1`
* `otel/metric`: `v1.1.0-RC1` * `otel/metric`: `v1.1.0-rc.1`
* `otel/baggage`: `v1.1.0-RC1` * `otel/baggage`: `v1.1.0-rc.1`
* `otel/sdk/trace`: `v1.1.0-RC1` * `otel/sdk/trace`: `v1.1.0-rc.1`
* `otel/sdk/metric`: `v1.1.0-RC1` * `otel/sdk/metric`: `v1.1.0-rc.1`
All the modules are evaluated and determined to a viable stable release. They All the modules are evaluated and determined to a viable stable release. They
are then released as version `v1.1.0` (the minor version is incremented to are then released as version `v1.1.0` (the minor version is incremented to

View File

@ -12,5 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// Package attribute provides key and value attributes. // package attribute provides key and value attributes.
//
// This package is currently in a Release Candidate phase. Backwards incompatible changes
// may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
package attribute // import "go.opentelemetry.io/otel/attribute" package attribute // import "go.opentelemetry.io/otel/attribute"

View File

@ -20,8 +20,10 @@ type Key string
// Bool creates a KeyValue instance with a BOOL Value. // Bool creates a KeyValue instance with a BOOL Value.
// //
// If creating both a key and value at the same time, use the provided // If creating both key and a bool value at the same time, then
// convenience function instead -- Bool(name, value). // instead of calling Key(name).Bool(value) consider using a
// convenience function provided by the api/key package -
// key.Bool(name, value).
func (k Key) Bool(v bool) KeyValue { func (k Key) Bool(v bool) KeyValue {
return KeyValue{ return KeyValue{
Key: k, Key: k,
@ -29,43 +31,12 @@ func (k Key) Bool(v bool) KeyValue {
} }
} }
// BoolSlice creates a KeyValue instance with a BOOLSLICE Value.
//
// If creating both a key and value at the same time, use the provided
// convenience function instead -- BoolSlice(name, value).
func (k Key) BoolSlice(v []bool) KeyValue {
return KeyValue{
Key: k,
Value: BoolSliceValue(v),
}
}
// Int creates a KeyValue instance with an INT64 Value.
//
// If creating both a key and value at the same time, use the provided
// convenience function instead -- Int(name, value).
func (k Key) Int(v int) KeyValue {
return KeyValue{
Key: k,
Value: IntValue(v),
}
}
// IntSlice creates a KeyValue instance with an INT64SLICE Value.
//
// If creating both a key and value at the same time, use the provided
// convenience function instead -- IntSlice(name, value).
func (k Key) IntSlice(v []int) KeyValue {
return KeyValue{
Key: k,
Value: IntSliceValue(v),
}
}
// Int64 creates a KeyValue instance with an INT64 Value. // Int64 creates a KeyValue instance with an INT64 Value.
// //
// If creating both a key and value at the same time, use the provided // If creating both key and an int64 value at the same time, then
// convenience function instead -- Int64(name, value). // instead of calling Key(name).Int64(value) consider using a
// convenience function provided by the api/key package -
// key.Int64(name, value).
func (k Key) Int64(v int64) KeyValue { func (k Key) Int64(v int64) KeyValue {
return KeyValue{ return KeyValue{
Key: k, Key: k,
@ -73,21 +44,12 @@ func (k Key) Int64(v int64) KeyValue {
} }
} }
// Int64Slice creates a KeyValue instance with an INT64SLICE Value.
//
// If creating both a key and value at the same time, use the provided
// convenience function instead -- Int64Slice(name, value).
func (k Key) Int64Slice(v []int64) KeyValue {
return KeyValue{
Key: k,
Value: Int64SliceValue(v),
}
}
// Float64 creates a KeyValue instance with a FLOAT64 Value. // Float64 creates a KeyValue instance with a FLOAT64 Value.
// //
// If creating both a key and value at the same time, use the provided // If creating both key and a float64 value at the same time, then
// convenience function instead -- Float64(name, value). // instead of calling Key(name).Float64(value) consider using a
// convenience function provided by the api/key package -
// key.Float64(name, value).
func (k Key) Float64(v float64) KeyValue { func (k Key) Float64(v float64) KeyValue {
return KeyValue{ return KeyValue{
Key: k, Key: k,
@ -95,21 +57,12 @@ func (k Key) Float64(v float64) KeyValue {
} }
} }
// Float64Slice creates a KeyValue instance with a FLOAT64SLICE Value.
//
// If creating both a key and value at the same time, use the provided
// convenience function instead -- Float64(name, value).
func (k Key) Float64Slice(v []float64) KeyValue {
return KeyValue{
Key: k,
Value: Float64SliceValue(v),
}
}
// String creates a KeyValue instance with a STRING Value. // String creates a KeyValue instance with a STRING Value.
// //
// If creating both a key and value at the same time, use the provided // If creating both key and a string value at the same time, then
// convenience function instead -- String(name, value). // instead of calling Key(name).String(value) consider using a
// convenience function provided by the api/key package -
// key.String(name, value).
func (k Key) String(v string) KeyValue { func (k Key) String(v string) KeyValue {
return KeyValue{ return KeyValue{
Key: k, Key: k,
@ -117,14 +70,16 @@ func (k Key) String(v string) KeyValue {
} }
} }
// StringSlice creates a KeyValue instance with a STRINGSLICE Value. // Int creates a KeyValue instance with an INT64 Value.
// //
// If creating both a key and value at the same time, use the provided // If creating both key and an int value at the same time, then
// convenience function instead -- StringSlice(name, value). // instead of calling Key(name).Int(value) consider using a
func (k Key) StringSlice(v []string) KeyValue { // convenience function provided by the api/key package -
// key.Int(name, value).
func (k Key) Int(v int) KeyValue {
return KeyValue{ return KeyValue{
Key: k, Key: k,
Value: StringSliceValue(v), Value: IntValue(v),
} }
} }
@ -132,3 +87,16 @@ func (k Key) StringSlice(v []string) KeyValue {
func (k Key) Defined() bool { func (k Key) Defined() bool {
return len(k) != 0 return len(k) != 0
} }
// Array creates a KeyValue instance with a ARRAY Value.
//
// If creating both key and a array value at the same time, then
// instead of calling Key(name).String(value) consider using a
// convenience function provided by the api/key package -
// key.Array(name, value).
func (k Key) Array(v interface{}) KeyValue {
return KeyValue{
Key: k,
Value: ArrayValue(v),
}
}

View File

@ -15,7 +15,9 @@
package attribute // import "go.opentelemetry.io/otel/attribute" package attribute // import "go.opentelemetry.io/otel/attribute"
import ( import (
"encoding/json"
"fmt" "fmt"
"reflect"
) )
// KeyValue holds a key and value pair. // KeyValue holds a key and value pair.
@ -29,58 +31,78 @@ func (kv KeyValue) Valid() bool {
return kv.Key != "" && kv.Value.Type() != INVALID return kv.Key != "" && kv.Value.Type() != INVALID
} }
// Bool creates a KeyValue with a BOOL Value type. // Bool creates a new key-value pair with a passed name and a bool
// value.
func Bool(k string, v bool) KeyValue { func Bool(k string, v bool) KeyValue {
return Key(k).Bool(v) return Key(k).Bool(v)
} }
// BoolSlice creates a KeyValue with a BOOLSLICE Value type. // Int64 creates a new key-value pair with a passed name and an int64
func BoolSlice(k string, v []bool) KeyValue { // value.
return Key(k).BoolSlice(v)
}
// Int creates a KeyValue with an INT64 Value type.
func Int(k string, v int) KeyValue {
return Key(k).Int(v)
}
// IntSlice creates a KeyValue with an INT64SLICE Value type.
func IntSlice(k string, v []int) KeyValue {
return Key(k).IntSlice(v)
}
// Int64 creates a KeyValue with an INT64 Value type.
func Int64(k string, v int64) KeyValue { func Int64(k string, v int64) KeyValue {
return Key(k).Int64(v) return Key(k).Int64(v)
} }
// Int64Slice creates a KeyValue with an INT64SLICE Value type. // Float64 creates a new key-value pair with a passed name and a float64
func Int64Slice(k string, v []int64) KeyValue { // value.
return Key(k).Int64Slice(v)
}
// Float64 creates a KeyValue with a FLOAT64 Value type.
func Float64(k string, v float64) KeyValue { func Float64(k string, v float64) KeyValue {
return Key(k).Float64(v) return Key(k).Float64(v)
} }
// Float64Slice creates a KeyValue with a FLOAT64SLICE Value type. // String creates a new key-value pair with a passed name and a string
func Float64Slice(k string, v []float64) KeyValue { // value.
return Key(k).Float64Slice(v)
}
// String creates a KeyValue with a STRING Value type.
func String(k, v string) KeyValue { func String(k, v string) KeyValue {
return Key(k).String(v) return Key(k).String(v)
} }
// StringSlice creates a KeyValue with a STRINGSLICE Value type.
func StringSlice(k string, v []string) KeyValue {
return Key(k).StringSlice(v)
}
// Stringer creates a new key-value pair with a passed name and a string // Stringer creates a new key-value pair with a passed name and a string
// value generated by the passed Stringer interface. // value generated by the passed Stringer interface.
func Stringer(k string, v fmt.Stringer) KeyValue { func Stringer(k string, v fmt.Stringer) KeyValue {
return Key(k).String(v.String()) return Key(k).String(v.String())
} }
// Int creates a new key-value pair instance with a passed name and
// either an int32 or an int64 value, depending on whether the int
// type is 32 or 64 bits wide.
func Int(k string, v int) KeyValue {
return Key(k).Int(v)
}
// Array creates a new key-value pair with a passed name and a array.
// Only arrays of primitive type are supported.
func Array(k string, v interface{}) KeyValue {
return Key(k).Array(v)
}
// Any creates a new key-value pair instance with a passed name and
// automatic type inference. This is slower, and not type-safe.
func Any(k string, value interface{}) KeyValue {
if value == nil {
return String(k, "<nil>")
}
if stringer, ok := value.(fmt.Stringer); ok {
return String(k, stringer.String())
}
rv := reflect.ValueOf(value)
switch rv.Kind() {
case reflect.Array, reflect.Slice:
return Array(k, value)
case reflect.Bool:
return Bool(k, rv.Bool())
case reflect.Int, reflect.Int8, reflect.Int16:
return Int(k, int(rv.Int()))
case reflect.Int64:
return Int64(k, rv.Int())
case reflect.Float64:
return Float64(k, rv.Float())
case reflect.String:
return String(k, rv.String())
}
if b, err := json.Marshal(value); b != nil && err == nil {
return String(k, string(b))
}
return String(k, fmt.Sprint(value))
}

View File

@ -13,15 +13,12 @@ func _() {
_ = x[INT64-2] _ = x[INT64-2]
_ = x[FLOAT64-3] _ = x[FLOAT64-3]
_ = x[STRING-4] _ = x[STRING-4]
_ = x[BOOLSLICE-5] _ = x[ARRAY-5]
_ = x[INT64SLICE-6]
_ = x[FLOAT64SLICE-7]
_ = x[STRINGSLICE-8]
} }
const _Type_name = "INVALIDBOOLINT64FLOAT64STRINGBOOLSLICEINT64SLICEFLOAT64SLICESTRINGSLICE" const _Type_name = "INVALIDBOOLINT64FLOAT64STRINGARRAY"
var _Type_index = [...]uint8{0, 7, 11, 16, 23, 29, 38, 48, 60, 71} var _Type_index = [...]uint8{0, 7, 11, 16, 23, 29, 34}
func (i Type) String() string { func (i Type) String() string {
if i < 0 || i >= Type(len(_Type_index)-1) { if i < 0 || i >= Type(len(_Type_index)-1) {

View File

@ -17,6 +17,7 @@ package attribute // import "go.opentelemetry.io/otel/attribute"
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"reflect"
"strconv" "strconv"
"go.opentelemetry.io/otel/internal" "go.opentelemetry.io/otel/internal"
@ -32,7 +33,9 @@ type Value struct {
vtype Type vtype Type
numeric uint64 numeric uint64
stringly string stringly string
slice interface{} // TODO Lazy value type?
array interface{}
} }
const ( const (
@ -46,14 +49,10 @@ const (
FLOAT64 FLOAT64
// STRING is a string Type Value. // STRING is a string Type Value.
STRING STRING
// BOOLSLICE is a slice of booleans Type Value. // ARRAY is an array Type Value used to store 1-dimensional slices or
BOOLSLICE // arrays of bool, int, int32, int64, uint, uint32, uint64, float,
// INT64SLICE is a slice of 64-bit signed integral numbers Type Value. // float32, float64, or string types.
INT64SLICE ARRAY
// FLOAT64SLICE is a slice of 64-bit floating point numbers Type Value.
FLOAT64SLICE
// STRINGSLICE is a slice of strings Type Value.
STRINGSLICE
) )
// BoolValue creates a BOOL Value. // BoolValue creates a BOOL Value.
@ -64,33 +63,6 @@ func BoolValue(v bool) Value {
} }
} }
// BoolSliceValue creates a BOOLSLICE Value.
func BoolSliceValue(v []bool) Value {
cp := make([]bool, len(v))
copy(cp, v)
return Value{
vtype: BOOLSLICE,
slice: &cp,
}
}
// IntValue creates an INT64 Value.
func IntValue(v int) Value {
return Int64Value(int64(v))
}
// IntSliceValue creates an INTSLICE Value.
func IntSliceValue(v []int) Value {
cp := make([]int64, 0, len(v))
for _, i := range v {
cp = append(cp, int64(i))
}
return Value{
vtype: INT64SLICE,
slice: &cp,
}
}
// Int64Value creates an INT64 Value. // Int64Value creates an INT64 Value.
func Int64Value(v int64) Value { func Int64Value(v int64) Value {
return Value{ return Value{
@ -99,16 +71,6 @@ func Int64Value(v int64) Value {
} }
} }
// Int64SliceValue creates an INT64SLICE Value.
func Int64SliceValue(v []int64) Value {
cp := make([]int64, len(v))
copy(cp, v)
return Value{
vtype: INT64SLICE,
slice: &cp,
}
}
// Float64Value creates a FLOAT64 Value. // Float64Value creates a FLOAT64 Value.
func Float64Value(v float64) Value { func Float64Value(v float64) Value {
return Value{ return Value{
@ -117,16 +79,6 @@ func Float64Value(v float64) Value {
} }
} }
// Float64SliceValue creates a FLOAT64SLICE Value.
func Float64SliceValue(v []float64) Value {
cp := make([]float64, len(v))
copy(cp, v)
return Value{
vtype: FLOAT64SLICE,
slice: &cp,
}
}
// StringValue creates a STRING Value. // StringValue creates a STRING Value.
func StringValue(v string) Value { func StringValue(v string) Value {
return Value{ return Value{
@ -135,14 +87,38 @@ func StringValue(v string) Value {
} }
} }
// StringSliceValue creates a STRINGSLICE Value. // IntValue creates an INT64 Value.
func StringSliceValue(v []string) Value { func IntValue(v int) Value {
cp := make([]string, len(v)) return Int64Value(int64(v))
copy(cp, v) }
return Value{
vtype: STRINGSLICE, // ArrayValue creates an ARRAY value from an array or slice.
slice: &cp, // Only arrays or slices of bool, int, int64, float, float64, or string types are allowed.
// Specifically, arrays and slices can not contain other arrays, slices, structs, or non-standard
// types. If the passed value is not an array or slice of these types an
// INVALID value is returned.
func ArrayValue(v interface{}) Value {
switch reflect.TypeOf(v).Kind() {
case reflect.Array, reflect.Slice:
// get array type regardless of dimensions
typ := reflect.TypeOf(v).Elem()
kind := typ.Kind()
switch kind {
case reflect.Bool, reflect.Int, reflect.Int64,
reflect.Float64, reflect.String:
val := reflect.ValueOf(v)
length := val.Len()
frozen := reflect.Indirect(reflect.New(reflect.ArrayOf(length, typ)))
reflect.Copy(frozen, val)
return Value{
vtype: ARRAY,
array: frozen.Interface(),
}
default:
return Value{vtype: INVALID}
}
} }
return Value{vtype: INVALID}
} }
// Type returns a type of the Value. // Type returns a type of the Value.
@ -156,58 +132,27 @@ func (v Value) AsBool() bool {
return internal.RawToBool(v.numeric) return internal.RawToBool(v.numeric)
} }
// AsBoolSlice returns the []bool value. Make sure that the Value's type is
// BOOLSLICE.
func (v Value) AsBoolSlice() []bool {
if s, ok := v.slice.(*[]bool); ok {
return *s
}
return nil
}
// AsInt64 returns the int64 value. Make sure that the Value's type is // AsInt64 returns the int64 value. Make sure that the Value's type is
// INT64. // INT64.
func (v Value) AsInt64() int64 { func (v Value) AsInt64() int64 {
return internal.RawToInt64(v.numeric) return internal.RawToInt64(v.numeric)
} }
// AsInt64Slice returns the []int64 value. Make sure that the Value's type is
// INT64SLICE.
func (v Value) AsInt64Slice() []int64 {
if s, ok := v.slice.(*[]int64); ok {
return *s
}
return nil
}
// AsFloat64 returns the float64 value. Make sure that the Value's // AsFloat64 returns the float64 value. Make sure that the Value's
// type is FLOAT64. // type is FLOAT64.
func (v Value) AsFloat64() float64 { func (v Value) AsFloat64() float64 {
return internal.RawToFloat64(v.numeric) return internal.RawToFloat64(v.numeric)
} }
// AsFloat64Slice returns the []float64 value. Make sure that the Value's type is
// INT64SLICE.
func (v Value) AsFloat64Slice() []float64 {
if s, ok := v.slice.(*[]float64); ok {
return *s
}
return nil
}
// AsString returns the string value. Make sure that the Value's type // AsString returns the string value. Make sure that the Value's type
// is STRING. // is STRING.
func (v Value) AsString() string { func (v Value) AsString() string {
return v.stringly return v.stringly
} }
// AsStringSlice returns the []string value. Make sure that the Value's type is // AsArray returns the array Value as an interface{}.
// INT64SLICE. func (v Value) AsArray() interface{} {
func (v Value) AsStringSlice() []string { return v.array
if s, ok := v.slice.(*[]string); ok {
return *s
}
return nil
} }
type unknownValueType struct{} type unknownValueType struct{}
@ -215,22 +160,16 @@ type unknownValueType struct{}
// AsInterface returns Value's data as interface{}. // AsInterface returns Value's data as interface{}.
func (v Value) AsInterface() interface{} { func (v Value) AsInterface() interface{} {
switch v.Type() { switch v.Type() {
case ARRAY:
return v.AsArray()
case BOOL: case BOOL:
return v.AsBool() return v.AsBool()
case BOOLSLICE:
return v.AsBoolSlice()
case INT64: case INT64:
return v.AsInt64() return v.AsInt64()
case INT64SLICE:
return v.AsInt64Slice()
case FLOAT64: case FLOAT64:
return v.AsFloat64() return v.AsFloat64()
case FLOAT64SLICE:
return v.AsFloat64Slice()
case STRING: case STRING:
return v.stringly return v.stringly
case STRINGSLICE:
return v.AsStringSlice()
} }
return unknownValueType{} return unknownValueType{}
} }
@ -238,20 +177,14 @@ func (v Value) AsInterface() interface{} {
// Emit returns a string representation of Value's data. // Emit returns a string representation of Value's data.
func (v Value) Emit() string { func (v Value) Emit() string {
switch v.Type() { switch v.Type() {
case BOOLSLICE: case ARRAY:
return fmt.Sprint(*(v.slice.(*[]bool))) return fmt.Sprint(v.array)
case BOOL: case BOOL:
return strconv.FormatBool(v.AsBool()) return strconv.FormatBool(v.AsBool())
case INT64SLICE:
return fmt.Sprint(*(v.slice.(*[]int64)))
case INT64: case INT64:
return strconv.FormatInt(v.AsInt64(), 10) return strconv.FormatInt(v.AsInt64(), 10)
case FLOAT64SLICE:
return fmt.Sprint(*(v.slice.(*[]float64)))
case FLOAT64: case FLOAT64:
return fmt.Sprint(v.AsFloat64()) return fmt.Sprint(v.AsFloat64())
case STRINGSLICE:
return fmt.Sprint(*(v.slice.(*[]string)))
case STRING: case STRING:
return v.stringly return v.stringly
default: default:

View File

@ -16,5 +16,8 @@
Package baggage provides functionality for storing and retrieving Package baggage provides functionality for storing and retrieving
baggage items in Go context. For propagating the baggage, see the baggage items in Go context. For propagating the baggage, see the
go.opentelemetry.io/otel/propagation package. go.opentelemetry.io/otel/propagation package.
This package is currently in a Release Candidate phase. Backwards incompatible changes
may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
*/ */
package baggage // import "go.opentelemetry.io/otel/baggage" package baggage // import "go.opentelemetry.io/otel/baggage"

View File

@ -15,6 +15,9 @@
/* /*
Package codes defines the canonical error codes used by OpenTelemetry. Package codes defines the canonical error codes used by OpenTelemetry.
This package is currently in a Release Candidate phase. Backwards incompatible changes
may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
It conforms to [the OpenTelemetry It conforms to [the OpenTelemetry
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#statuscanonicalcode). specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#statuscanonicalcode).
*/ */

View File

@ -16,6 +16,9 @@
Package otel provides global access to the OpenTelemetry API. The subpackages of Package otel provides global access to the OpenTelemetry API. The subpackages of
the otel package provide an implementation of the OpenTelemetry API. the otel package provide an implementation of the OpenTelemetry API.
This package is currently in a Release Candidate phase. Backwards incompatible changes
may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
The provided API is used to instrument code and measure data about that code's The provided API is used to instrument code and measure data about that code's
performance and operation. The measured data, by default, is not processed or performance and operation. The measured data, by default, is not processed or
transmitted anywhere. An implementation of the OpenTelemetry SDK, like the transmitted anywhere. An implementation of the OpenTelemetry SDK, like the

View File

@ -25,14 +25,3 @@ type ErrorHandler 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.
} }
// ErrorHandlerFunc is a convenience adapter to allow the use of a function
// as an ErrorHandler.
type ErrorHandlerFunc func(error)
var _ ErrorHandler = ErrorHandlerFunc(nil)
// Handle handles the irremediable error by calling the ErrorHandlerFunc itself.
func (f ErrorHandlerFunc) Handle(err error) {
f(err)
}

View File

@ -1,47 +0,0 @@
# OpenTelemetry-Go OTLP Span Exporter
[![Go Reference](https://pkg.go.dev/badge/go.opentelemetry.io/otel/exporters/otlp/otlptrace.svg)](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace)
[OpenTelemetry Protocol Exporter](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.5.0/specification/protocol/exporter.md) implementation.
## Installation
```
go get -u go.opentelemetry.io/otel/exporters/otlp/otlptrace
```
## Examples
- [Exporter setup and examples](./otlptracehttp/example_test.go)
- [Full example sending telemetry to a local collector](../../../example/otel-collector)
## [`otlptrace`](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace)
The `otlptrace` package provides an exporter implementing the OTel span exporter interface.
This exporter is configured using a client satisfying the `otlptrace.Client` interface.
This client handles the transformation of data into wire format and the transmission of that data to the collector.
## [`otlptracegrpc`](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc)
The `otlptracegrpc` package implements a client for the span exporter that sends trace telemetry data to the collector using gRPC with protobuf-encoded payloads.
## [`otlptracehttp`](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp)
The `otlptracehttp` package implements a client for the span exporter that sends trace telemetry data to the collector using HTTP with protobuf-encoded payloads.
## Configuration
### Environment Variables
The following environment variables can be used
(instead of options objects) to override the default configuration.
| Environment variable | Option | Default value |
| ------------------------------------------------------------------------ |------------------------------ | ----------------------------------- |
| `OTEL_EXPORTER_OTLP_ENDPOINT` `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | `WithEndpoint` `WithInsecure` | `https://localhost:4317` |
| `OTEL_EXPORTER_OTLP_CERTIFICATE` `OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE` | `WithTLSClientConfig` | |
| `OTEL_EXPORTER_OTLP_HEADERS` `OTEL_EXPORTER_OTLP_TRACES_HEADERS` | `WithHeaders` | |
| `OTEL_EXPORTER_OTLP_COMPRESSION` `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION` | `WithCompression` | |
| `OTEL_EXPORTER_OTLP_TIMEOUT` `OTEL_EXPORTER_OTLP_TRACES_TIMEOUT` | `WithTimeout` | `10s` |
Configuration using options have precedence over the environment variables.

View File

@ -6,12 +6,12 @@ require (
github.com/cenkalti/backoff/v4 v4.1.1 github.com/cenkalti/backoff/v4 v4.1.1
github.com/google/go-cmp v0.5.6 github.com/google/go-cmp v0.5.6
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.0.0 go.opentelemetry.io/otel v1.0.0-RC2
go.opentelemetry.io/otel/sdk v1.0.0 go.opentelemetry.io/otel/sdk v1.0.0-RC2
go.opentelemetry.io/otel/trace v1.0.0 go.opentelemetry.io/otel/trace v1.0.0-RC2
go.opentelemetry.io/proto/otlp v0.9.0 go.opentelemetry.io/proto/otlp v0.9.0
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
google.golang.org/grpc v1.40.0 google.golang.org/grpc v1.39.0
google.golang.org/protobuf v1.27.1 google.golang.org/protobuf v1.27.1
) )
@ -21,6 +21,8 @@ replace go.opentelemetry.io/otel/sdk => ../../../sdk
replace go.opentelemetry.io/otel/metric => ../../../metric replace go.opentelemetry.io/otel/metric => ../../../metric
replace go.opentelemetry.io/otel/oteltest => ../../../oteltest
replace go.opentelemetry.io/otel/trace => ../../../trace replace go.opentelemetry.io/otel/trace => ../../../trace
replace go.opentelemetry.io/otel/bridge/opencensus => ../../../bridge/opencensus replace go.opentelemetry.io/otel/bridge/opencensus => ../../../bridge/opencensus
@ -72,7 +74,3 @@ replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../stdout/s
replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../stdout/stdouttrace replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../stdout/stdouttrace
replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp => ../otlpmetric/otlpmetrichttp replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp => ../otlpmetric/otlpmetrichttp
replace go.opentelemetry.io/otel/bridge/opencensus/test => ../../../bridge/opencensus/test
replace go.opentelemetry.io/otel/example/fib => ../../../example/fib

View File

@ -1,12 +1,10 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ= github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
@ -52,7 +50,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
@ -109,8 +106,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q= google.golang.org/grpc v1.39.0 h1:Klz8I9kdtkIN6EpHHUOMLCYhTn/2WAe5a0s1hcBkdTI=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig" package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/internal/otlpconfig"
import ( import (
"crypto/tls" "crypto/tls"

View File

@ -15,145 +15,127 @@
package tracetransform package tracetransform
import ( import (
"reflect"
"go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/attribute"
commonpb "go.opentelemetry.io/proto/otlp/common/v1" commonpb "go.opentelemetry.io/proto/otlp/common/v1"
"go.opentelemetry.io/otel/sdk/resource" "go.opentelemetry.io/otel/sdk/resource"
) )
// KeyValues transforms a slice of attribute KeyValues into OTLP key-values. // Attributes transforms a slice of KeyValues into a slice of OTLP attribute key-values.
func KeyValues(attrs []attribute.KeyValue) []*commonpb.KeyValue { func Attributes(attrs []attribute.KeyValue) []*commonpb.KeyValue {
if len(attrs) == 0 { if len(attrs) == 0 {
return nil return nil
} }
out := make([]*commonpb.KeyValue, 0, len(attrs)) out := make([]*commonpb.KeyValue, 0, len(attrs))
for _, kv := range attrs { for _, kv := range attrs {
out = append(out, KeyValue(kv)) out = append(out, toAttribute(kv))
} }
return out return out
} }
// Iterator transforms an attribute iterator into OTLP key-values. // ResourceAttributes transforms a Resource into a slice of OTLP attribute key-values.
func Iterator(iter attribute.Iterator) []*commonpb.KeyValue { func ResourceAttributes(resource *resource.Resource) []*commonpb.KeyValue {
l := iter.Len() if resource.Len() == 0 {
if l == 0 {
return nil return nil
} }
out := make([]*commonpb.KeyValue, 0, l) out := make([]*commonpb.KeyValue, 0, resource.Len())
for iter.Next() { for iter := resource.Iter(); iter.Next(); {
out = append(out, KeyValue(iter.Attribute())) out = append(out, toAttribute(iter.Attribute()))
} }
return out return out
} }
// ResourceAttributes transforms a Resource OTLP key-values. func toAttribute(v attribute.KeyValue) *commonpb.KeyValue {
func ResourceAttributes(resource *resource.Resource) []*commonpb.KeyValue { result := &commonpb.KeyValue{
return Iterator(resource.Iter()) Key: string(v.Key),
} Value: new(commonpb.AnyValue),
}
// KeyValue transforms an attribute KeyValue into an OTLP key-value. switch v.Value.Type() {
func KeyValue(kv attribute.KeyValue) *commonpb.KeyValue {
return &commonpb.KeyValue{Key: string(kv.Key), Value: Value(kv.Value)}
}
// Value transforms an attribute Value into an OTLP AnyValue.
func Value(v attribute.Value) *commonpb.AnyValue {
av := new(commonpb.AnyValue)
switch v.Type() {
case attribute.BOOL: case attribute.BOOL:
av.Value = &commonpb.AnyValue_BoolValue{ result.Value.Value = &commonpb.AnyValue_BoolValue{
BoolValue: v.AsBool(), BoolValue: v.Value.AsBool(),
}
case attribute.BOOLSLICE:
av.Value = &commonpb.AnyValue_ArrayValue{
ArrayValue: &commonpb.ArrayValue{
Values: boolSliceValues(v.AsBoolSlice()),
},
} }
case attribute.INT64: case attribute.INT64:
av.Value = &commonpb.AnyValue_IntValue{ result.Value.Value = &commonpb.AnyValue_IntValue{
IntValue: v.AsInt64(), IntValue: v.Value.AsInt64(),
}
case attribute.INT64SLICE:
av.Value = &commonpb.AnyValue_ArrayValue{
ArrayValue: &commonpb.ArrayValue{
Values: int64SliceValues(v.AsInt64Slice()),
},
} }
case attribute.FLOAT64: case attribute.FLOAT64:
av.Value = &commonpb.AnyValue_DoubleValue{ result.Value.Value = &commonpb.AnyValue_DoubleValue{
DoubleValue: v.AsFloat64(), DoubleValue: v.Value.AsFloat64(),
}
case attribute.FLOAT64SLICE:
av.Value = &commonpb.AnyValue_ArrayValue{
ArrayValue: &commonpb.ArrayValue{
Values: float64SliceValues(v.AsFloat64Slice()),
},
} }
case attribute.STRING: case attribute.STRING:
av.Value = &commonpb.AnyValue_StringValue{ result.Value.Value = &commonpb.AnyValue_StringValue{
StringValue: v.AsString(), StringValue: v.Value.AsString(),
} }
case attribute.STRINGSLICE: case attribute.ARRAY:
av.Value = &commonpb.AnyValue_ArrayValue{ result.Value.Value = &commonpb.AnyValue_ArrayValue{
ArrayValue: &commonpb.ArrayValue{ ArrayValue: &commonpb.ArrayValue{
Values: stringSliceValues(v.AsStringSlice()), Values: arrayValues(v),
}, },
} }
default: default:
av.Value = &commonpb.AnyValue_StringValue{ result.Value.Value = &commonpb.AnyValue_StringValue{
StringValue: "INVALID", StringValue: "INVALID",
} }
} }
return av return result
} }
func boolSliceValues(vals []bool) []*commonpb.AnyValue { func arrayValues(kv attribute.KeyValue) []*commonpb.AnyValue {
converted := make([]*commonpb.AnyValue, len(vals)) a := kv.Value.AsArray()
for i, v := range vals { aType := reflect.TypeOf(a)
converted[i] = &commonpb.AnyValue{ var valueFunc func(reflect.Value) *commonpb.AnyValue
Value: &commonpb.AnyValue_BoolValue{ switch aType.Elem().Kind() {
BoolValue: v, case reflect.Bool:
}, valueFunc = func(v reflect.Value) *commonpb.AnyValue {
return &commonpb.AnyValue{
Value: &commonpb.AnyValue_BoolValue{
BoolValue: v.Bool(),
},
}
}
case reflect.Int, reflect.Int64:
valueFunc = func(v reflect.Value) *commonpb.AnyValue {
return &commonpb.AnyValue{
Value: &commonpb.AnyValue_IntValue{
IntValue: v.Int(),
},
}
}
case reflect.Uintptr:
valueFunc = func(v reflect.Value) *commonpb.AnyValue {
return &commonpb.AnyValue{
Value: &commonpb.AnyValue_IntValue{
IntValue: int64(v.Uint()),
},
}
}
case reflect.Float64:
valueFunc = func(v reflect.Value) *commonpb.AnyValue {
return &commonpb.AnyValue{
Value: &commonpb.AnyValue_DoubleValue{
DoubleValue: v.Float(),
},
}
}
case reflect.String:
valueFunc = func(v reflect.Value) *commonpb.AnyValue {
return &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{
StringValue: v.String(),
},
}
} }
} }
return converted
}
func int64SliceValues(vals []int64) []*commonpb.AnyValue { results := make([]*commonpb.AnyValue, aType.Len())
converted := make([]*commonpb.AnyValue, len(vals)) for i, aValue := 0, reflect.ValueOf(a); i < aValue.Len(); i++ {
for i, v := range vals { results[i] = valueFunc(aValue.Index(i))
converted[i] = &commonpb.AnyValue{
Value: &commonpb.AnyValue_IntValue{
IntValue: v,
},
}
} }
return converted return results
}
func float64SliceValues(vals []float64) []*commonpb.AnyValue {
converted := make([]*commonpb.AnyValue, len(vals))
for i, v := range vals {
converted[i] = &commonpb.AnyValue{
Value: &commonpb.AnyValue_DoubleValue{
DoubleValue: v,
},
}
}
return converted
}
func stringSliceValues(vals []string) []*commonpb.AnyValue {
converted := make([]*commonpb.AnyValue, len(vals))
for i, v := range vals {
converted[i] = &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{
StringValue: v,
},
}
}
return converted
} }

View File

@ -60,7 +60,6 @@ func Spans(sdl []tracesdk.ReadOnlySpan) []*tracepb.ResourceSpans {
ils = &tracepb.InstrumentationLibrarySpans{ ils = &tracepb.InstrumentationLibrarySpans{
InstrumentationLibrary: InstrumentationLibrary(sd.InstrumentationLibrary()), InstrumentationLibrary: InstrumentationLibrary(sd.InstrumentationLibrary()),
Spans: []*tracepb.Span{}, Spans: []*tracepb.Span{},
SchemaUrl: sd.InstrumentationLibrary().SchemaURL,
} }
} }
ils.Spans = append(ils.Spans, span(sd)) ils.Spans = append(ils.Spans, span(sd))
@ -73,7 +72,6 @@ func Spans(sdl []tracesdk.ReadOnlySpan) []*tracepb.ResourceSpans {
rs = &tracepb.ResourceSpans{ rs = &tracepb.ResourceSpans{
Resource: Resource(sd.Resource()), Resource: Resource(sd.Resource()),
InstrumentationLibrarySpans: []*tracepb.InstrumentationLibrarySpans{ils}, InstrumentationLibrarySpans: []*tracepb.InstrumentationLibrarySpans{ils},
SchemaUrl: sd.Resource().SchemaURL(),
} }
rsm[rKey] = rs rsm[rKey] = rs
continue continue
@ -116,7 +114,7 @@ func span(sd tracesdk.ReadOnlySpan) *tracepb.Span {
Links: links(sd.Links()), Links: links(sd.Links()),
Kind: spanKind(sd.SpanKind()), Kind: spanKind(sd.SpanKind()),
Name: sd.Name(), Name: sd.Name(),
Attributes: KeyValues(sd.Attributes()), Attributes: Attributes(sd.Attributes()),
Events: spanEvents(sd.Events()), Events: spanEvents(sd.Events()),
DroppedAttributesCount: uint32(sd.DroppedAttributes()), DroppedAttributesCount: uint32(sd.DroppedAttributes()),
DroppedEventsCount: uint32(sd.DroppedEvents()), DroppedEventsCount: uint32(sd.DroppedEvents()),
@ -165,7 +163,7 @@ func links(links []tracesdk.Link) []*tracepb.Span_Link {
sl = append(sl, &tracepb.Span_Link{ sl = append(sl, &tracepb.Span_Link{
TraceId: tid[:], TraceId: tid[:],
SpanId: sid[:], SpanId: sid[:],
Attributes: KeyValues(otLink.Attributes), Attributes: Attributes(otLink.Attributes),
}) })
} }
return sl return sl
@ -194,7 +192,7 @@ func spanEvents(es []tracesdk.Event) []*tracepb.Span_Event {
&tracepb.Span_Event{ &tracepb.Span_Event{
Name: e.Name, Name: e.Name,
TimeUnixNano: uint64(e.Time.UnixNano()), TimeUnixNano: uint64(e.Time.UnixNano()),
Attributes: KeyValues(e.Attributes), Attributes: Attributes(e.Attributes),
// TODO (rghetia) : Add Drop Counts when supported. // TODO (rghetia) : Add Drop Counts when supported.
}, },
) )

View File

@ -4,11 +4,11 @@ go 1.15
require ( require (
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.0.0 go.opentelemetry.io/otel v1.0.0-RC2
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2
go.opentelemetry.io/otel/sdk v1.0.0 go.opentelemetry.io/otel/sdk v1.0.0-RC2
go.opentelemetry.io/proto/otlp v0.9.0 go.opentelemetry.io/proto/otlp v0.9.0
google.golang.org/grpc v1.40.0 google.golang.org/grpc v1.39.0
) )
replace go.opentelemetry.io/otel => ../../../.. replace go.opentelemetry.io/otel => ../../../..
@ -19,6 +19,8 @@ replace go.opentelemetry.io/otel/exporters/otlp/otlptrace => ../
replace go.opentelemetry.io/otel/metric => ../../../../metric replace go.opentelemetry.io/otel/metric => ../../../../metric
replace go.opentelemetry.io/otel/oteltest => ../../../../oteltest
replace go.opentelemetry.io/otel/trace => ../../../../trace replace go.opentelemetry.io/otel/trace => ../../../../trace
replace go.opentelemetry.io/otel/bridge/opencensus => ../../../../bridge/opencensus replace go.opentelemetry.io/otel/bridge/opencensus => ../../../../bridge/opencensus
@ -68,7 +70,3 @@ replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../../stdou
replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../../stdout/stdouttrace replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../../stdout/stdouttrace
replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp => ../../otlpmetric/otlpmetrichttp replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp => ../../otlpmetric/otlpmetrichttp
replace go.opentelemetry.io/otel/bridge/opencensus/test => ../../../../bridge/opencensus/test
replace go.opentelemetry.io/otel/example/fib => ../../../../example/fib

View File

@ -1,12 +1,10 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ= github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
@ -52,7 +50,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
@ -109,8 +106,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q= google.golang.org/grpc v1.39.0 h1:Klz8I9kdtkIN6EpHHUOMLCYhTn/2WAe5a0s1hcBkdTI=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

View File

@ -5,7 +5,7 @@ go 1.15
require ( require (
github.com/google/go-cmp v0.5.6 github.com/google/go-cmp v0.5.6
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel/trace v1.0.0 go.opentelemetry.io/otel/trace v1.0.0-RC2
) )
replace go.opentelemetry.io/otel => ./ replace go.opentelemetry.io/otel => ./
@ -42,6 +42,8 @@ replace go.opentelemetry.io/otel/internal/metric => ./internal/metric
replace go.opentelemetry.io/otel/metric => ./metric replace go.opentelemetry.io/otel/metric => ./metric
replace go.opentelemetry.io/otel/oteltest => ./oteltest
replace go.opentelemetry.io/otel/sdk/export/metric => ./sdk/export/metric replace go.opentelemetry.io/otel/sdk/export/metric => ./sdk/export/metric
replace go.opentelemetry.io/otel/sdk/metric => ./sdk/metric replace go.opentelemetry.io/otel/sdk/metric => ./sdk/metric
@ -65,7 +67,3 @@ replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ./exporters/st
replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ./exporters/stdout/stdouttrace replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ./exporters/stdout/stdouttrace
replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp => ./exporters/otlp/otlpmetric/otlpmetrichttp replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp => ./exporters/otlp/otlpmetric/otlpmetrichttp
replace go.opentelemetry.io/otel/bridge/opencensus/test => ./bridge/opencensus/test
replace go.opentelemetry.io/otel/example/fib => ./example/fib

View File

@ -26,42 +26,36 @@ var (
// throughout an OpenTelemetry instrumented project. When a user // throughout an OpenTelemetry instrumented project. When a user
// specified ErrorHandler is registered (`SetErrorHandler`) all calls to // specified ErrorHandler is registered (`SetErrorHandler`) all calls to
// `Handle` and will be delegated to the registered ErrorHandler. // `Handle` and will be delegated to the registered ErrorHandler.
globalErrorHandler = defaultErrorHandler() globalErrorHandler = &loggingErrorHandler{
l: log.New(os.Stderr, "", log.LstdFlags),
}
// delegateErrorHandlerOnce ensures that a user provided ErrorHandler is // delegateErrorHandlerOnce ensures that a user provided ErrorHandler is
// only ever registered once. // only ever registered once.
delegateErrorHandlerOnce sync.Once delegateErrorHandlerOnce sync.Once
// Compile-time check that delegator implements ErrorHandler. // Comiple time check that loggingErrorHandler implements ErrorHandler.
_ ErrorHandler = (*delegator)(nil) _ ErrorHandler = (*loggingErrorHandler)(nil)
) )
type holder struct { // loggingErrorHandler logs all errors to STDERR.
eh ErrorHandler type loggingErrorHandler struct {
}
func defaultErrorHandler() *atomic.Value {
v := &atomic.Value{}
v.Store(holder{eh: &delegator{l: log.New(os.Stderr, "", log.LstdFlags)}})
return v
}
// delegator logs errors if no delegate is set, otherwise they are delegated.
type delegator struct {
delegate atomic.Value delegate atomic.Value
l *log.Logger l *log.Logger
} }
// setDelegate sets the ErrorHandler delegate. // setDelegate sets the ErrorHandler delegate if one is not already set.
func (h *delegator) setDelegate(d ErrorHandler) { func (h *loggingErrorHandler) setDelegate(d ErrorHandler) {
// It is critical this is guarded with delegateErrorHandlerOnce, if it is if h.delegate.Load() != nil {
// called again with a different concrete type it will panic. // Delegate already registered
return
}
h.delegate.Store(d) h.delegate.Store(d)
} }
// Handle logs err if no delegate is set, otherwise it is delegated. // Handle implements ErrorHandler.
func (h *delegator) Handle(err error) { func (h *loggingErrorHandler) Handle(err error) {
if d := h.delegate.Load(); d != nil { if d := h.delegate.Load(); d != nil {
d.(ErrorHandler).Handle(err) d.(ErrorHandler).Handle(err)
return return
@ -69,39 +63,27 @@ func (h *delegator) Handle(err error) {
h.l.Print(err) h.l.Print(err)
} }
// GetErrorHandler returns the global ErrorHandler instance. // GetErrorHandler returns the global ErrorHandler instance. If no ErrorHandler
// // instance has been set (`SetErrorHandler`), the default ErrorHandler which
// The default ErrorHandler instance returned will log all errors to STDERR // logs errors to STDERR is returned.
// until an override ErrorHandler is set with SetErrorHandler. All
// ErrorHandler returned prior to this will automatically forward errors to
// the set instance instead of logging.
//
// Subsequent calls to SetErrorHandler after the first will not forward errors
// to the new ErrorHandler for prior returned instances.
func GetErrorHandler() ErrorHandler { func GetErrorHandler() ErrorHandler {
return globalErrorHandler.Load().(holder).eh return globalErrorHandler
} }
// SetErrorHandler sets the global ErrorHandler to h. // SetErrorHandler sets the global ErrorHandler to be h.
//
// The first time this is called all ErrorHandler previously returned from
// GetErrorHandler will send errors to h instead of the default logging
// ErrorHandler. Subsequent calls will set the global ErrorHandler, but not
// delegate errors to h.
func SetErrorHandler(h ErrorHandler) { func SetErrorHandler(h ErrorHandler) {
delegateErrorHandlerOnce.Do(func() { delegateErrorHandlerOnce.Do(func() {
current := GetErrorHandler() current := GetErrorHandler()
if current == h { if current == h {
return return
} }
if internalHandler, ok := current.(*delegator); ok { if internalHandler, ok := current.(*loggingErrorHandler); ok {
internalHandler.setDelegate(h) internalHandler.setDelegate(h)
} }
}) })
globalErrorHandler.Store(holder{eh: h})
} }
// Handle is a convenience function for ErrorHandler().Handle(err) // Handle is a convience function for ErrorHandler().Handle(err)
func Handle(err error) { func Handle(err error) {
GetErrorHandler().Handle(err) GetErrorHandler().Handle(err)
} }

View File

@ -90,10 +90,9 @@ func (p *tracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.T
// At this moment it is guaranteed that no sdk is installed, save the tracer in the tracers map. // At this moment it is guaranteed that no sdk is installed, save the tracer in the tracers map.
c := trace.NewTracerConfig(opts...)
key := il{ key := il{
name: name, name: name,
version: c.InstrumentationVersion(), version: trace.NewTracerConfig(opts...).InstrumentationVersion(),
} }
if p.tracers == nil { if p.tracers == nil {

View File

@ -15,6 +15,9 @@
/* /*
Package propagation contains OpenTelemetry context propagators. Package propagation contains OpenTelemetry context propagators.
This package is currently in a Release Candidate phase. Backwards incompatible changes
may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
OpenTelemetry propagators are used to extract and inject context data from and OpenTelemetry propagators are used to extract and inject context data from and
into messages exchanged by applications. The propagator supported by this into messages exchanged by applications. The propagator supported by this
package is the W3C Trace Context encoding package is the W3C Trace Context encoding

View File

@ -78,7 +78,7 @@ type TextMapPropagator 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.
// Fields returns the keys whose values are set with Inject. // Fields returns the keys who's values are set with Inject.
Fields() []string Fields() []string
// 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.

View File

@ -16,6 +16,9 @@
Package instrumentation provides an instrumentation library structure to be Package instrumentation provides an instrumentation library structure to be
passed to both the OpenTelemetry Tracer and Meter components. passed to both the OpenTelemetry Tracer and Meter components.
This package is currently in a Release Candidate phase. Backwards incompatible changes
may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
For more information see For more information see
[this](https://github.com/open-telemetry/oteps/blob/main/text/0083-component.md). [this](https://github.com/open-telemetry/oteps/blob/main/text/0083-component.md).
*/ */

View File

@ -14,6 +14,9 @@
// Package resource provides detecting and representing resources. // Package resource provides detecting and representing resources.
// //
// This package is currently in a Release Candidate phase. Backwards incompatible changes
// may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
//
// The fundamental struct is a Resource which holds identifying information // The fundamental struct is a Resource which holds identifying information
// about the entities for which telemetry is exported. // about the entities for which telemetry is exported.
// //

View File

@ -76,9 +76,6 @@ func (fromEnv) Detect(context.Context) (*Resource, error) {
} }
func constructOTResources(s string) (*Resource, error) { func constructOTResources(s string) (*Resource, error) {
if s == "" {
return Empty(), nil
}
pairs := strings.Split(s, ",") pairs := strings.Split(s, ",")
attrs := []attribute.KeyValue{} attrs := []attribute.KeyValue{}
var invalid []string var invalid []string

View File

@ -138,7 +138,7 @@ func (processExecutablePathDetector) Detect(ctx context.Context) (*Resource, err
// Detect returns a *Resource that describes all the command arguments as received // Detect returns a *Resource that describes all the command arguments as received
// by the process. // by the process.
func (processCommandArgsDetector) Detect(ctx context.Context) (*Resource, error) { func (processCommandArgsDetector) Detect(ctx context.Context) (*Resource, error) {
return NewWithAttributes(semconv.SchemaURL, semconv.ProcessCommandArgsKey.StringSlice(commandArgs())), nil return NewWithAttributes(semconv.SchemaURL, semconv.ProcessCommandArgsKey.Array(commandArgs())), nil
} }
// Detect returns a *Resource that describes the username of the user that owns the // Detect returns a *Resource that describes the username of the user that owns the

View File

@ -132,13 +132,10 @@ func (r *Resource) Attributes() []attribute.KeyValue {
} }
func (r *Resource) SchemaURL() string { func (r *Resource) SchemaURL() string {
if r == nil {
return ""
}
return r.schemaURL return r.schemaURL
} }
// Iter returns an iterator of the Resource attributes. // Iter returns an interator of the Resource attributes.
// This is ideal to use if you do not want a copy of the attributes. // This is ideal to use if you do not want a copy of the attributes.
func (r *Resource) Iter() attribute.Iterator { func (r *Resource) Iter() attribute.Iterator {
if r == nil { if r == nil {
@ -202,14 +199,14 @@ func Merge(a, b *Resource) (*Resource, error) {
return merged, nil return merged, nil
} }
// Empty returns an instance of Resource with no attributes. It is // Empty returns an instance of Resource with no attributes. It is
// equivalent to a `nil` Resource. // equivalent to a `nil` Resource.
func Empty() *Resource { func Empty() *Resource {
return &emptyResource return &emptyResource
} }
// Default returns an instance of Resource with a default // Default returns an instance of Resource with a default
// "service.name" and OpenTelemetrySDK attributes. // "service.name" and OpenTelemetrySDK attributes
func Default() *Resource { func Default() *Resource {
return defaultResource return defaultResource
} }
@ -226,13 +223,13 @@ func Environment() *Resource {
} }
// Equivalent returns an object that can be compared for equality // Equivalent returns an object that can be compared for equality
// between two resources. This value is suitable for use as a key in // between two resources. This value is suitable for use as a key in
// a map. // a map.
func (r *Resource) Equivalent() attribute.Distinct { func (r *Resource) Equivalent() attribute.Distinct {
return r.Set().Equivalent() return r.Set().Equivalent()
} }
// Set returns the equivalent *attribute.Set of this resource's attributes. // Set returns the equivalent *attribute.Set of this resources attributes.
func (r *Resource) Set() *attribute.Set { func (r *Resource) Set() *attribute.Set {
if r == nil { if r == nil {
r = Empty() r = Empty()

View File

@ -15,6 +15,9 @@
/* /*
Package trace contains support for OpenTelemetry distributed tracing. Package trace contains support for OpenTelemetry distributed tracing.
This package is currently in a Release Candidate phase. Backwards incompatible changes
may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
The following assumes a basic familiarity with OpenTelemetry concepts. The following assumes a basic familiarity with OpenTelemetry concepts.
See https://opentelemetry.io. See https://opentelemetry.io.
*/ */

View File

@ -18,8 +18,6 @@ import (
"context" "context"
"fmt" "fmt"
"reflect" "reflect"
"runtime"
rt "runtime/trace"
"sync" "sync"
"time" "time"
@ -99,9 +97,9 @@ type ReadWriteSpan interface {
ReadOnlySpan ReadOnlySpan
} }
// recordingSpan is an implementation of the OpenTelemetry Span API // span is an implementation of the OpenTelemetry Span API representing the
// representing the individual component of a trace that is sampled. // individual component of a trace.
type recordingSpan struct { type span struct {
// mu protects the contents of this span. // mu protects the contents of this span.
mu sync.Mutex mu sync.Mutex
@ -158,11 +156,10 @@ type recordingSpan struct {
spanLimits SpanLimits spanLimits SpanLimits
} }
var _ ReadWriteSpan = (*recordingSpan)(nil) var _ trace.Span = &span{}
var _ runtimeTracer = (*recordingSpan)(nil)
// SpanContext returns the SpanContext of this span. // SpanContext returns the SpanContext of this span.
func (s *recordingSpan) SpanContext() trace.SpanContext { func (s *span) SpanContext() trace.SpanContext {
if s == nil { if s == nil {
return trace.SpanContext{} return trace.SpanContext{}
} }
@ -171,21 +168,21 @@ func (s *recordingSpan) SpanContext() trace.SpanContext {
// IsRecording returns if this span is being recorded. If this span has ended // IsRecording returns if this span is being recorded. If this span has ended
// this will return false. // this will return false.
func (s *recordingSpan) IsRecording() bool { func (s *span) IsRecording() bool {
if s == nil { if s == nil {
return false return false
} }
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.endTime.IsZero() return !s.startTime.IsZero() && s.endTime.IsZero()
} }
// SetStatus sets the status of the Span in the form of a code and a // SetStatus sets the status of the Span in the form of a code and a
// description, overriding previous values set. The description is only // description, overriding previous values set. The description is only
// included in the set status when the code is for an error. If this span is // included in the set status when the code is for an error. If this span is
// not being recorded than this method does nothing. // not being recorded than this method does nothing.
func (s *recordingSpan) SetStatus(code codes.Code, description string) { func (s *span) SetStatus(code codes.Code, description string) {
if !s.IsRecording() { if !s.IsRecording() {
return return
} }
@ -206,7 +203,7 @@ func (s *recordingSpan) SetStatus(code codes.Code, description string) {
// will be overwritten with the value contained in attributes. // will be overwritten with the value contained in attributes.
// //
// If this span is not being recorded than this method does nothing. // If this span is not being recorded than this method does nothing.
func (s *recordingSpan) SetAttributes(attributes ...attribute.KeyValue) { func (s *span) SetAttributes(attributes ...attribute.KeyValue) {
if !s.IsRecording() { if !s.IsRecording() {
return return
} }
@ -221,7 +218,7 @@ func (s *recordingSpan) SetAttributes(attributes ...attribute.KeyValue) {
// //
// If this method is called while panicking an error event is added to the // If this method is called while panicking an error event is added to the
// Span before ending it and the panic is continued. // Span before ending it and the panic is continued.
func (s *recordingSpan) End(options ...trace.SpanEndOption) { func (s *span) End(options ...trace.SpanEndOption) {
// Do not start by checking if the span is being recorded which requires // Do not start by checking if the span is being recorded which requires
// acquiring a lock. Make a minimal check that the span is not nil. // acquiring a lock. Make a minimal check that the span is not nil.
if s == nil { if s == nil {
@ -238,30 +235,24 @@ func (s *recordingSpan) End(options ...trace.SpanEndOption) {
return return
} }
config := trace.NewSpanEndConfig(options...)
if recovered := recover(); recovered != nil { if recovered := recover(); recovered != nil {
// Record but don't stop the panic. // Record but don't stop the panic.
defer panic(recovered) defer panic(recovered)
opts := []trace.EventOption{ s.addEvent(
semconv.ExceptionEventName,
trace.WithAttributes( trace.WithAttributes(
semconv.ExceptionTypeKey.String(typeStr(recovered)), semconv.ExceptionTypeKey.String(typeStr(recovered)),
semconv.ExceptionMessageKey.String(fmt.Sprint(recovered)), semconv.ExceptionMessageKey.String(fmt.Sprint(recovered)),
), ),
} )
if config.StackTrace() {
opts = append(opts, trace.WithAttributes(
semconv.ExceptionStacktraceKey.String(recordStackTrace()),
))
}
s.addEvent(semconv.ExceptionEventName, opts...)
} }
if s.executionTracerTaskEnd != nil { if s.executionTracerTaskEnd != nil {
s.executionTracerTaskEnd() s.executionTracerTaskEnd()
} }
config := trace.NewSpanEndConfig(options...)
s.mu.Lock() s.mu.Lock()
// Setting endTime to non-zero marks the span as ended and not recording. // Setting endTime to non-zero marks the span as ended and not recording.
if config.Timestamp().IsZero() { if config.Timestamp().IsZero() {
@ -286,7 +277,7 @@ func (s *recordingSpan) End(options ...trace.SpanEndOption) {
// SetStatus is required if the Status of the Span should be set to Error, this method // SetStatus is required if the Status of the Span should be set to Error, this method
// does not change the Span status. If this span is not being recorded or err is nil // does not change the Span status. If this span is not being recorded or err is nil
// than this method does nothing. // than this method does nothing.
func (s *recordingSpan) RecordError(err error, opts ...trace.EventOption) { func (s *span) RecordError(err error, opts ...trace.EventOption) {
if s == nil || err == nil || !s.IsRecording() { if s == nil || err == nil || !s.IsRecording() {
return return
} }
@ -295,14 +286,6 @@ func (s *recordingSpan) RecordError(err error, opts ...trace.EventOption) {
semconv.ExceptionTypeKey.String(typeStr(err)), semconv.ExceptionTypeKey.String(typeStr(err)),
semconv.ExceptionMessageKey.String(err.Error()), semconv.ExceptionMessageKey.String(err.Error()),
)) ))
c := trace.NewEventConfig(opts...)
if c.StackTrace() {
opts = append(opts, trace.WithAttributes(
semconv.ExceptionStacktraceKey.String(recordStackTrace()),
))
}
s.addEvent(semconv.ExceptionEventName, opts...) s.addEvent(semconv.ExceptionEventName, opts...)
} }
@ -315,23 +298,16 @@ func typeStr(i interface{}) string {
return fmt.Sprintf("%s.%s", t.PkgPath(), t.Name()) return fmt.Sprintf("%s.%s", t.PkgPath(), t.Name())
} }
func recordStackTrace() string {
stackTrace := make([]byte, 2048)
n := runtime.Stack(stackTrace, false)
return string(stackTrace[0:n])
}
// AddEvent adds an event with the provided name and options. If this span is // AddEvent adds an event with the provided name and options. If this span is
// not being recorded than this method does nothing. // not being recorded than this method does nothing.
func (s *recordingSpan) AddEvent(name string, o ...trace.EventOption) { func (s *span) AddEvent(name string, o ...trace.EventOption) {
if !s.IsRecording() { if !s.IsRecording() {
return return
} }
s.addEvent(name, o...) s.addEvent(name, o...)
} }
func (s *recordingSpan) addEvent(name string, o ...trace.EventOption) { func (s *span) addEvent(name string, o ...trace.EventOption) {
c := trace.NewEventConfig(o...) c := trace.NewEventConfig(o...)
// Discard over limited attributes // Discard over limited attributes
@ -353,7 +329,7 @@ func (s *recordingSpan) addEvent(name string, o ...trace.EventOption) {
// SetName sets the name of this span. If this span is not being recorded than // SetName sets the name of this span. If this span is not being recorded than
// this method does nothing. // this method does nothing.
func (s *recordingSpan) SetName(name string) { func (s *span) SetName(name string) {
if !s.IsRecording() { if !s.IsRecording() {
return return
} }
@ -364,28 +340,28 @@ func (s *recordingSpan) SetName(name string) {
} }
// Name returns the name of this span. // Name returns the name of this span.
func (s *recordingSpan) Name() string { func (s *span) Name() string {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.name return s.name
} }
// Name returns the SpanContext of this span's parent span. // Name returns the SpanContext of this span's parent span.
func (s *recordingSpan) Parent() trace.SpanContext { func (s *span) Parent() trace.SpanContext {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.parent return s.parent
} }
// SpanKind returns the SpanKind of this span. // SpanKind returns the SpanKind of this span.
func (s *recordingSpan) SpanKind() trace.SpanKind { func (s *span) SpanKind() trace.SpanKind {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.spanKind return s.spanKind
} }
// StartTime returns the time this span started. // StartTime returns the time this span started.
func (s *recordingSpan) StartTime() time.Time { func (s *span) StartTime() time.Time {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.startTime return s.startTime
@ -393,14 +369,14 @@ func (s *recordingSpan) StartTime() time.Time {
// EndTime returns the time this span ended. For spans that have not yet // EndTime returns the time this span ended. For spans that have not yet
// ended, the returned value will be the zero value of time.Time. // ended, the returned value will be the zero value of time.Time.
func (s *recordingSpan) EndTime() time.Time { func (s *span) EndTime() time.Time {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.endTime return s.endTime
} }
// Attributes returns the attributes of this span. // Attributes returns the attributes of this span.
func (s *recordingSpan) Attributes() []attribute.KeyValue { func (s *span) Attributes() []attribute.KeyValue {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
if s.attributes.evictList.Len() == 0 { if s.attributes.evictList.Len() == 0 {
@ -410,7 +386,7 @@ func (s *recordingSpan) Attributes() []attribute.KeyValue {
} }
// Links returns the links of this span. // Links returns the links of this span.
func (s *recordingSpan) Links() []Link { func (s *span) Links() []Link {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
if len(s.links.queue) == 0 { if len(s.links.queue) == 0 {
@ -420,7 +396,7 @@ func (s *recordingSpan) Links() []Link {
} }
// Events returns the events of this span. // Events returns the events of this span.
func (s *recordingSpan) Events() []Event { func (s *span) Events() []Event {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
if len(s.events.queue) == 0 { if len(s.events.queue) == 0 {
@ -430,7 +406,7 @@ func (s *recordingSpan) Events() []Event {
} }
// Status returns the status of this span. // Status returns the status of this span.
func (s *recordingSpan) Status() Status { func (s *span) Status() Status {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.status return s.status
@ -438,7 +414,7 @@ func (s *recordingSpan) Status() Status {
// InstrumentationLibrary returns the instrumentation.Library associated with // InstrumentationLibrary returns the instrumentation.Library associated with
// the Tracer that created this span. // the Tracer that created this span.
func (s *recordingSpan) InstrumentationLibrary() instrumentation.Library { func (s *span) InstrumentationLibrary() instrumentation.Library {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.instrumentationLibrary return s.instrumentationLibrary
@ -446,13 +422,13 @@ func (s *recordingSpan) InstrumentationLibrary() instrumentation.Library {
// Resource returns the Resource associated with the Tracer that created this // Resource returns the Resource associated with the Tracer that created this
// span. // span.
func (s *recordingSpan) Resource() *resource.Resource { func (s *span) Resource() *resource.Resource {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.resource return s.resource
} }
func (s *recordingSpan) addLink(link trace.Link) { func (s *span) addLink(link trace.Link) {
if !s.IsRecording() { if !s.IsRecording() {
return return
} }
@ -472,7 +448,7 @@ func (s *recordingSpan) addLink(link trace.Link) {
// DroppedAttributes returns the number of attributes dropped by the span // DroppedAttributes returns the number of attributes dropped by the span
// due to limits being reached. // due to limits being reached.
func (s *recordingSpan) DroppedAttributes() int { func (s *span) DroppedAttributes() int {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.attributes.droppedCount return s.attributes.droppedCount
@ -480,7 +456,7 @@ func (s *recordingSpan) DroppedAttributes() int {
// DroppedLinks returns the number of links dropped by the span due to limits // DroppedLinks returns the number of links dropped by the span due to limits
// being reached. // being reached.
func (s *recordingSpan) DroppedLinks() int { func (s *span) DroppedLinks() int {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.links.droppedCount return s.links.droppedCount
@ -488,7 +464,7 @@ func (s *recordingSpan) DroppedLinks() int {
// DroppedEvents returns the number of events dropped by the span due to // DroppedEvents returns the number of events dropped by the span due to
// limits being reached. // limits being reached.
func (s *recordingSpan) DroppedEvents() int { func (s *span) DroppedEvents() int {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.events.droppedCount return s.events.droppedCount
@ -496,7 +472,7 @@ func (s *recordingSpan) DroppedEvents() int {
// ChildSpanCount returns the count of spans that consider the span a // ChildSpanCount returns the count of spans that consider the span a
// direct parent. // direct parent.
func (s *recordingSpan) ChildSpanCount() int { func (s *span) ChildSpanCount() int {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
return s.childSpanCount return s.childSpanCount
@ -504,12 +480,12 @@ func (s *recordingSpan) ChildSpanCount() int {
// TracerProvider returns a trace.TracerProvider that can be used to generate // TracerProvider returns a trace.TracerProvider that can be used to generate
// additional Spans on the same telemetry pipeline as the current Span. // additional Spans on the same telemetry pipeline as the current Span.
func (s *recordingSpan) TracerProvider() trace.TracerProvider { func (s *span) TracerProvider() trace.TracerProvider {
return s.tracer.provider return s.tracer.provider
} }
// snapshot creates a read-only copy of the current state of the span. // snapshot creates a read-only copy of the current state of the span.
func (s *recordingSpan) snapshot() ReadOnlySpan { func (s *span) snapshot() ReadOnlySpan {
var sd snapshot var sd snapshot
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
@ -540,7 +516,7 @@ func (s *recordingSpan) snapshot() ReadOnlySpan {
return &sd return &sd
} }
func (s *recordingSpan) interfaceArrayToLinksArray() []Link { func (s *span) interfaceArrayToLinksArray() []Link {
linkArr := make([]Link, 0) linkArr := make([]Link, 0)
for _, value := range s.links.queue { for _, value := range s.links.queue {
linkArr = append(linkArr, value.(Link)) linkArr = append(linkArr, value.(Link))
@ -548,7 +524,7 @@ func (s *recordingSpan) interfaceArrayToLinksArray() []Link {
return linkArr return linkArr
} }
func (s *recordingSpan) interfaceArrayToEventArray() []Event { func (s *span) interfaceArrayToEventArray() []Event {
eventArr := make([]Event, 0) eventArr := make([]Event, 0)
for _, value := range s.events.queue { for _, value := range s.events.queue {
eventArr = append(eventArr, value.(Event)) eventArr = append(eventArr, value.(Event))
@ -556,7 +532,7 @@ func (s *recordingSpan) interfaceArrayToEventArray() []Event {
return eventArr return eventArr
} }
func (s *recordingSpan) copyToCappedAttributes(attributes ...attribute.KeyValue) { func (s *span) copyToCappedAttributes(attributes ...attribute.KeyValue) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
for _, a := range attributes { for _, a := range attributes {
@ -568,7 +544,7 @@ func (s *recordingSpan) copyToCappedAttributes(attributes ...attribute.KeyValue)
} }
} }
func (s *recordingSpan) addChild() { func (s *span) addChild() {
if !s.IsRecording() { if !s.IsRecording() {
return return
} }
@ -577,66 +553,82 @@ func (s *recordingSpan) addChild() {
s.mu.Unlock() s.mu.Unlock()
} }
func (*recordingSpan) private() {} func (*span) private() {}
// runtimeTrace starts a "runtime/trace".Task for the span and returns a func startSpanInternal(ctx context.Context, tr *tracer, name string, o *trace.SpanConfig) *span {
// context containing the task. span := &span{}
func (s *recordingSpan) runtimeTrace(ctx context.Context) context.Context {
if !rt.IsEnabled() { provider := tr.provider
// Avoid additional overhead if runtime/trace is not enabled.
return ctx // If told explicitly to make this a new root use a zero value SpanContext
// as a parent which contains an invalid trace ID and is not remote.
var psc trace.SpanContext
if o.NewRoot() {
ctx = trace.ContextWithSpanContext(ctx, psc)
} else {
psc = trace.SpanContextFromContext(ctx)
} }
nctx, task := rt.NewTask(ctx, s.name)
s.mu.Lock() // If there is a valid parent trace ID, use it to ensure the continuity of
s.executionTracerTaskEnd = task.End // the trace. Always generate a new span ID so other components can rely
s.mu.Unlock() // on a unique span ID, even if the Span is non-recording.
var tid trace.TraceID
var sid trace.SpanID
if !psc.TraceID().IsValid() {
tid, sid = provider.idGenerator.NewIDs(ctx)
} else {
tid = psc.TraceID()
sid = provider.idGenerator.NewSpanID(ctx, tid)
}
return nctx spanLimits := provider.spanLimits
span.attributes = newAttributesMap(spanLimits.AttributeCountLimit)
span.events = newEvictedQueue(spanLimits.EventCountLimit)
span.links = newEvictedQueue(spanLimits.LinkCountLimit)
span.spanLimits = spanLimits
samplingResult := provider.sampler.ShouldSample(SamplingParameters{
ParentContext: ctx,
TraceID: tid,
Name: name,
Kind: o.SpanKind(),
Attributes: o.Attributes(),
Links: o.Links(),
})
scc := trace.SpanContextConfig{
TraceID: tid,
SpanID: sid,
TraceState: samplingResult.Tracestate,
}
if isSampled(samplingResult) {
scc.TraceFlags = psc.TraceFlags() | trace.FlagsSampled
} else {
scc.TraceFlags = psc.TraceFlags() &^ trace.FlagsSampled
}
span.spanContext = trace.NewSpanContext(scc)
if !isRecording(samplingResult) {
return span
}
startTime := o.Timestamp()
if startTime.IsZero() {
startTime = time.Now()
}
span.startTime = startTime
span.spanKind = trace.ValidateSpanKind(o.SpanKind())
span.name = name
span.parent = psc
span.resource = provider.resource
span.instrumentationLibrary = tr.instrumentationLibrary
span.SetAttributes(samplingResult.Attributes...)
return span
} }
// nonRecordingSpan is a minimal implementation of the OpenTelemetry Span API
// that wraps a SpanContext. It performs no operations other than to return
// the wrapped SpanContext or TracerProvider that created it.
type nonRecordingSpan struct {
// tracer is the SDK tracer that created this span.
tracer *tracer
sc trace.SpanContext
}
var _ trace.Span = nonRecordingSpan{}
// SpanContext returns the wrapped SpanContext.
func (s nonRecordingSpan) SpanContext() trace.SpanContext { return s.sc }
// IsRecording always returns false.
func (nonRecordingSpan) IsRecording() bool { return false }
// SetStatus does nothing.
func (nonRecordingSpan) SetStatus(codes.Code, string) {}
// SetError does nothing.
func (nonRecordingSpan) SetError(bool) {}
// SetAttributes does nothing.
func (nonRecordingSpan) SetAttributes(...attribute.KeyValue) {}
// End does nothing.
func (nonRecordingSpan) End(...trace.SpanEndOption) {}
// RecordError does nothing.
func (nonRecordingSpan) RecordError(error, ...trace.EventOption) {}
// AddEvent does nothing.
func (nonRecordingSpan) AddEvent(string, ...trace.EventOption) {}
// SetName does nothing.
func (nonRecordingSpan) SetName(string) {}
// TracerProvider returns the trace.TracerProvider that provided the Tracer
// that created this span.
func (s nonRecordingSpan) TracerProvider() trace.TracerProvider { return s.tracer.provider }
func isRecording(s SamplingResult) bool { func isRecording(s SamplingResult) bool {
return s.Decision == RecordOnly || s.Decision == RecordAndSample return s.Decision == RecordOnly || s.Decision == RecordAndSample
} }

View File

@ -16,7 +16,7 @@ package trace // import "go.opentelemetry.io/otel/sdk/trace"
import ( import (
"context" "context"
"time" rt "runtime/trace"
"go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace"
@ -34,120 +34,42 @@ var _ trace.Tracer = &tracer{}
// //
// The Span is created with the provided name and as a child of any existing // The Span is created with the provided name and as a child of any existing
// span context found in the passed context. The created Span will be // span context found in the passed context. The created Span will be
// configured appropriately by any SpanOption passed. // configured appropriately by any SpanOption passed. Any Timestamp option
// passed will be used as the start time of the Span's life-cycle.
func (tr *tracer) Start(ctx context.Context, name string, options ...trace.SpanStartOption) (context.Context, trace.Span) { func (tr *tracer) Start(ctx context.Context, name string, options ...trace.SpanStartOption) (context.Context, trace.Span) {
config := trace.NewSpanStartConfig(options...) config := trace.NewSpanStartConfig(options...)
// For local spans created by this SDK, track child span count. // For local spans created by this SDK, track child span count.
if p := trace.SpanFromContext(ctx); p != nil { if p := trace.SpanFromContext(ctx); p != nil {
if sdkSpan, ok := p.(*recordingSpan); ok { if sdkSpan, ok := p.(*span); ok {
sdkSpan.addChild() sdkSpan.addChild()
} }
} }
s := tr.newSpan(ctx, name, &config) span := startSpanInternal(ctx, tr, name, config)
if rw, ok := s.(ReadWriteSpan); ok && s.IsRecording() { for _, l := range config.Links() {
span.addLink(l)
}
span.SetAttributes(config.Attributes()...)
span.tracer = tr
if span.IsRecording() {
sps, _ := tr.provider.spanProcessors.Load().(spanProcessorStates) sps, _ := tr.provider.spanProcessors.Load().(spanProcessorStates)
for _, sp := range sps { for _, sp := range sps {
sp.sp.OnStart(ctx, rw) sp.sp.OnStart(ctx, span)
} }
} }
if rtt, ok := s.(runtimeTracer); ok {
ctx = rtt.runtimeTrace(ctx)
}
return trace.ContextWithSpan(ctx, s), s ctx, span.executionTracerTaskEnd = func(ctx context.Context) (context.Context, func()) {
} if !rt.IsEnabled() {
// Avoid additional overhead if
type runtimeTracer interface { // runtime/trace is not enabled.
// runtimeTrace starts a "runtime/trace".Task for the span and return ctx, func() {}
// returns a context containing the task. }
runtimeTrace(ctx context.Context) context.Context nctx, task := rt.NewTask(ctx, name)
} return nctx, task.End
}(ctx)
// newSpan returns a new configured span.
func (tr *tracer) newSpan(ctx context.Context, name string, config *trace.SpanConfig) trace.Span { return trace.ContextWithSpan(ctx, span), span
// If told explicitly to make this a new root use a zero value SpanContext
// as a parent which contains an invalid trace ID and is not remote.
var psc trace.SpanContext
if config.NewRoot() {
ctx = trace.ContextWithSpanContext(ctx, psc)
} else {
psc = trace.SpanContextFromContext(ctx)
}
// If there is a valid parent trace ID, use it to ensure the continuity of
// the trace. Always generate a new span ID so other components can rely
// on a unique span ID, even if the Span is non-recording.
var tid trace.TraceID
var sid trace.SpanID
if !psc.TraceID().IsValid() {
tid, sid = tr.provider.idGenerator.NewIDs(ctx)
} else {
tid = psc.TraceID()
sid = tr.provider.idGenerator.NewSpanID(ctx, tid)
}
samplingResult := tr.provider.sampler.ShouldSample(SamplingParameters{
ParentContext: ctx,
TraceID: tid,
Name: name,
Kind: config.SpanKind(),
Attributes: config.Attributes(),
Links: config.Links(),
})
scc := trace.SpanContextConfig{
TraceID: tid,
SpanID: sid,
TraceState: samplingResult.Tracestate,
}
if isSampled(samplingResult) {
scc.TraceFlags = psc.TraceFlags() | trace.FlagsSampled
} else {
scc.TraceFlags = psc.TraceFlags() &^ trace.FlagsSampled
}
sc := trace.NewSpanContext(scc)
if !isRecording(samplingResult) {
return tr.newNonRecordingSpan(sc)
}
return tr.newRecordingSpan(psc, sc, name, samplingResult, config)
}
// newRecordingSpan returns a new configured recordingSpan.
func (tr *tracer) newRecordingSpan(psc, sc trace.SpanContext, name string, sr SamplingResult, config *trace.SpanConfig) *recordingSpan {
startTime := config.Timestamp()
if startTime.IsZero() {
startTime = time.Now()
}
s := &recordingSpan{
parent: psc,
spanContext: sc,
spanKind: trace.ValidateSpanKind(config.SpanKind()),
name: name,
startTime: startTime,
attributes: newAttributesMap(tr.provider.spanLimits.AttributeCountLimit),
events: newEvictedQueue(tr.provider.spanLimits.EventCountLimit),
links: newEvictedQueue(tr.provider.spanLimits.LinkCountLimit),
tracer: tr,
spanLimits: tr.provider.spanLimits,
resource: tr.provider.resource,
instrumentationLibrary: tr.instrumentationLibrary,
}
for _, l := range config.Links() {
s.addLink(l)
}
s.SetAttributes(sr.Attributes...)
s.SetAttributes(config.Attributes()...)
return s
}
// newNonRecordingSpan returns a new configured nonRecordingSpan.
func (tr *tracer) newNonRecordingSpan(sc trace.SpanContext) nonRecordingSpan {
return nonRecordingSpan{tracer: tr, sc: sc}
} }

View File

@ -14,6 +14,9 @@
// Package semconv implements OpenTelemetry semantic conventions. // Package semconv implements OpenTelemetry semantic conventions.
// //
// This package is currently in a Release Candidate phase. Backwards incompatible changes
// may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
//
// OpenTelemetry semantic conventions are agreed standardized naming // OpenTelemetry semantic conventions are agreed standardized naming
// patterns for OpenTelemetry things. This package represents the conventions // patterns for OpenTelemetry things. This package represents the conventions
// as of the v1.4.0 version of the OpenTelemetry specification. // as of the v1.4.0 version of the OpenTelemetry specification.

View File

@ -31,9 +31,9 @@ func Tracer(name string, opts ...trace.TracerOption) trace.Tracer {
// If none is registered then an instance of NoopTracerProvider is returned. // If none is registered then an instance of NoopTracerProvider is returned.
// //
// Use the trace provider to create a named tracer. E.g. // Use the trace provider to create a named tracer. E.g.
// tracer := otel.GetTracerProvider().Tracer("example.com/foo") // tracer := global.GetTracerProvider().Tracer("example.com/foo")
// or // or
// tracer := otel.Tracer("example.com/foo") // tracer := global.Tracer("example.com/foo")
func GetTracerProvider() trace.TracerProvider { func GetTracerProvider() trace.TracerProvider {
return global.TracerProvider() return global.TracerProvider()
} }

View File

@ -38,10 +38,10 @@ func (t *TracerConfig) SchemaURL() string {
} }
// NewTracerConfig applies all the options to a returned TracerConfig. // NewTracerConfig applies all the options to a returned TracerConfig.
func NewTracerConfig(options ...TracerOption) TracerConfig { func NewTracerConfig(options ...TracerOption) *TracerConfig {
var config TracerConfig config := new(TracerConfig)
for _, option := range options { for _, option := range options {
option.apply(&config) option.apply(config)
} }
return config return config
} }
@ -64,7 +64,6 @@ type SpanConfig struct {
links []Link links []Link
newRoot bool newRoot bool
spanKind SpanKind spanKind SpanKind
stackTrace bool
} }
// Attributes describe the associated qualities of a Span. // Attributes describe the associated qualities of a Span.
@ -77,11 +76,6 @@ func (cfg *SpanConfig) Timestamp() time.Time {
return cfg.timestamp return cfg.timestamp
} }
// StackTrace checks whether stack trace capturing is enabled.
func (cfg *SpanConfig) StackTrace() bool {
return cfg.stackTrace
}
// Links are the associations a Span has with other Spans. // Links are the associations a Span has with other Spans.
func (cfg *SpanConfig) Links() []Link { func (cfg *SpanConfig) Links() []Link {
return cfg.links return cfg.links
@ -103,10 +97,10 @@ func (cfg *SpanConfig) SpanKind() SpanKind {
// No validation is performed on the returned SpanConfig (e.g. no uniqueness // No validation is performed on the returned SpanConfig (e.g. no uniqueness
// checking or bounding of data), it is left to the SDK to perform this // checking or bounding of data), it is left to the SDK to perform this
// action. // action.
func NewSpanStartConfig(options ...SpanStartOption) SpanConfig { func NewSpanStartConfig(options ...SpanStartOption) *SpanConfig {
var c SpanConfig c := new(SpanConfig)
for _, option := range options { for _, option := range options {
option.applySpanStart(&c) option.applySpanStart(c)
} }
return c return c
} }
@ -115,10 +109,10 @@ func NewSpanStartConfig(options ...SpanStartOption) SpanConfig {
// No validation is performed on the returned SpanConfig (e.g. no uniqueness // No validation is performed on the returned SpanConfig (e.g. no uniqueness
// checking or bounding of data), it is left to the SDK to perform this // checking or bounding of data), it is left to the SDK to perform this
// action. // action.
func NewSpanEndConfig(options ...SpanEndOption) SpanConfig { func NewSpanEndConfig(options ...SpanEndOption) *SpanConfig {
var c SpanConfig c := new(SpanConfig)
for _, option := range options { for _, option := range options {
option.applySpanEnd(&c) option.applySpanEnd(c)
} }
return c return c
} }
@ -145,7 +139,6 @@ type SpanEndOption interface {
type EventConfig struct { type EventConfig struct {
attributes []attribute.KeyValue attributes []attribute.KeyValue
timestamp time.Time timestamp time.Time
stackTrace bool
} }
// Attributes describe the associated qualities of an Event. // Attributes describe the associated qualities of an Event.
@ -158,19 +151,14 @@ func (cfg *EventConfig) Timestamp() time.Time {
return cfg.timestamp return cfg.timestamp
} }
// StackTrace checks whether stack trace capturing is enabled. // NewEventConfig applies all the EventOptions to a returned SpanConfig. If no
func (cfg *EventConfig) StackTrace() bool { // timestamp option is passed, the returned SpanConfig will have a Timestamp
return cfg.stackTrace
}
// NewEventConfig applies all the EventOptions to a returned EventConfig. If no
// timestamp option is passed, the returned EventConfig will have a Timestamp
// set to the call time, otherwise no validation is performed on the returned // set to the call time, otherwise no validation is performed on the returned
// EventConfig. // SpanConfig.
func NewEventConfig(options ...EventOption) EventConfig { func NewEventConfig(options ...EventOption) *EventConfig {
var c EventConfig c := new(EventConfig)
for _, option := range options { for _, option := range options {
option.applyEvent(&c) option.applyEvent(c)
} }
if c.timestamp.IsZero() { if c.timestamp.IsZero() {
c.timestamp = time.Now() c.timestamp = time.Now()
@ -195,12 +183,6 @@ type SpanStartEventOption interface {
EventOption EventOption
} }
// SpanEndEventOption are options that can be used at the end of a span, or with an event.
type SpanEndEventOption interface {
SpanEndOption
EventOption
}
type attributeOption []attribute.KeyValue type attributeOption []attribute.KeyValue
func (o attributeOption) applySpan(c *SpanConfig) { func (o attributeOption) applySpan(c *SpanConfig) {
@ -247,17 +229,6 @@ func WithTimestamp(t time.Time) SpanEventOption {
return timestampOption(t) return timestampOption(t)
} }
type stackTraceOption bool
func (o stackTraceOption) applyEvent(c *EventConfig) { c.stackTrace = bool(o) }
func (o stackTraceOption) applySpan(c *SpanConfig) { c.stackTrace = bool(o) }
func (o stackTraceOption) applySpanEnd(c *SpanConfig) { o.applySpan(c) }
// WithStackTrace sets the flag to capture the error with stack trace (e.g. true, false).
func WithStackTrace(b bool) SpanEndEventOption {
return stackTraceOption(b)
}
// WithLinks adds links to a Span. The links are added to the existing Span // WithLinks adds links to a Span. The links are added to the existing Span
// links, i.e. this does not overwrite. // links, i.e. this does not overwrite.
func WithLinks(links ...Link) SpanStartOption { func WithLinks(links ...Link) SpanStartOption {

View File

@ -16,6 +16,9 @@
Package trace provides an implementation of the tracing part of the Package trace provides an implementation of the tracing part of the
OpenTelemetry API. OpenTelemetry API.
This package is currently in a Release Candidate phase. Backwards incompatible changes
may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
To participate in distributed traces a Span needs to be created for the To participate in distributed traces a Span needs to be created for the
operation being performed as part of a traced workflow. It its simplest form: operation being performed as part of a traced workflow. It its simplest form:

View File

@ -32,6 +32,8 @@ replace go.opentelemetry.io/otel/internal/tools => ../internal/tools
replace go.opentelemetry.io/otel/metric => ../metric replace go.opentelemetry.io/otel/metric => ../metric
replace go.opentelemetry.io/otel/oteltest => ../oteltest
replace go.opentelemetry.io/otel/sdk => ../sdk replace go.opentelemetry.io/otel/sdk => ../sdk
replace go.opentelemetry.io/otel/sdk/export/metric => ../sdk/export/metric replace go.opentelemetry.io/otel/sdk/export/metric => ../sdk/export/metric
@ -43,7 +45,7 @@ replace go.opentelemetry.io/otel/trace => ./
require ( require (
github.com/google/go-cmp v0.5.6 github.com/google/go-cmp v0.5.6
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.0.0 go.opentelemetry.io/otel v1.0.0-RC2
) )
replace go.opentelemetry.io/otel/example/passthrough => ../example/passthrough replace go.opentelemetry.io/otel/example/passthrough => ../example/passthrough
@ -65,7 +67,3 @@ replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../exporters/s
replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../exporters/stdout/stdouttrace replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../exporters/stdout/stdouttrace
replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp => ../exporters/otlp/otlpmetric/otlpmetrichttp replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp => ../exporters/otlp/otlpmetric/otlpmetrichttp
replace go.opentelemetry.io/otel/bridge/opencensus/test => ../bridge/opencensus/test
replace go.opentelemetry.io/otel/example/fib => ../example/fib

View File

@ -16,5 +16,5 @@ package otel // import "go.opentelemetry.io/otel"
// Version is the current release version of OpenTelemetry in use. // Version is the current release version of OpenTelemetry in use.
func Version() string { func Version() string {
return "1.0.0" return "1.0.0-RC1"
} }

View File

@ -14,11 +14,10 @@
module-sets: module-sets:
stable-v1: stable-v1:
version: v1.0.0 version: v1.0.0-RC2
modules: modules:
- go.opentelemetry.io/otel - go.opentelemetry.io/otel
- go.opentelemetry.io/otel/bridge/opentracing - go.opentelemetry.io/otel/bridge/opentracing
- go.opentelemetry.io/otel/example/fib
- go.opentelemetry.io/otel/example/jaeger - go.opentelemetry.io/otel/example/jaeger
- go.opentelemetry.io/otel/example/namedtracer - go.opentelemetry.io/otel/example/namedtracer
- go.opentelemetry.io/otel/example/otel-collector - go.opentelemetry.io/otel/example/otel-collector
@ -30,10 +29,11 @@ module-sets:
- go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
- go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
- go.opentelemetry.io/otel/exporters/stdout/stdouttrace - go.opentelemetry.io/otel/exporters/stdout/stdouttrace
- go.opentelemetry.io/otel/oteltest
- go.opentelemetry.io/otel/trace - go.opentelemetry.io/otel/trace
- go.opentelemetry.io/otel/sdk - go.opentelemetry.io/otel/sdk
experimental-metrics: experimental-metrics:
version: v0.23.0 version: v0.22.0
modules: modules:
- go.opentelemetry.io/otel/example/prometheus - go.opentelemetry.io/otel/example/prometheus
- go.opentelemetry.io/otel/exporters/otlp/otlpmetric - go.opentelemetry.io/otel/exporters/otlp/otlpmetric
@ -46,10 +46,9 @@ module-sets:
- go.opentelemetry.io/otel/sdk/export/metric - go.opentelemetry.io/otel/sdk/export/metric
- go.opentelemetry.io/otel/sdk/metric - go.opentelemetry.io/otel/sdk/metric
bridge: bridge:
version: v0.23.0 version: v0.21.0
modules: modules:
- go.opentelemetry.io/otel/bridge/opencensus - go.opentelemetry.io/otel/bridge/opencensus
- go.opentelemetry.io/otel/bridge/opencensus/test
- go.opentelemetry.io/otel/example/opencensus - go.opentelemetry.io/otel/example/opencensus
excluded-modules: excluded-modules:
- go.opentelemetry.io/otel/internal/tools - go.opentelemetry.io/otel/internal/tools

10
vendor/modules.txt vendored
View File

@ -380,7 +380,7 @@ go.opentelemetry.io/contrib
# go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.21.0 # go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.21.0
## explicit ## explicit
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
# go.opentelemetry.io/otel v1.0.0 # go.opentelemetry.io/otel v1.0.0-RC2
## explicit ## explicit
go.opentelemetry.io/otel go.opentelemetry.io/otel
go.opentelemetry.io/otel/attribute go.opentelemetry.io/otel/attribute
@ -391,22 +391,22 @@ go.opentelemetry.io/otel/internal/baggage
go.opentelemetry.io/otel/internal/global go.opentelemetry.io/otel/internal/global
go.opentelemetry.io/otel/propagation go.opentelemetry.io/otel/propagation
go.opentelemetry.io/otel/semconv/v1.4.0 go.opentelemetry.io/otel/semconv/v1.4.0
# go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0 # go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2
go.opentelemetry.io/otel/exporters/otlp/otlptrace go.opentelemetry.io/otel/exporters/otlp/otlptrace
go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/connection go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/connection
go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig
go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/retry go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/retry
go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform
# go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0 # go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2
## explicit ## explicit
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
# go.opentelemetry.io/otel/sdk v1.0.0 # go.opentelemetry.io/otel/sdk v1.0.0-RC2
## explicit ## explicit
go.opentelemetry.io/otel/sdk/instrumentation go.opentelemetry.io/otel/sdk/instrumentation
go.opentelemetry.io/otel/sdk/internal go.opentelemetry.io/otel/sdk/internal
go.opentelemetry.io/otel/sdk/resource go.opentelemetry.io/otel/sdk/resource
go.opentelemetry.io/otel/sdk/trace go.opentelemetry.io/otel/sdk/trace
# go.opentelemetry.io/otel/trace v1.0.0 # go.opentelemetry.io/otel/trace v1.0.0-RC2
## explicit ## explicit
go.opentelemetry.io/otel/trace go.opentelemetry.io/otel/trace
# go.opentelemetry.io/proto/otlp v0.9.0 # go.opentelemetry.io/proto/otlp v0.9.0