Skip to content

Commit

Permalink
Merge 32335c5 into a56cd59
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacd authored Jun 26, 2023
2 parents a56cd59 + 32335c5 commit 5c3e341
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 50 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Unreleased

## [1.18.4](https://github.com/lightstep/otel-launcher-go/releases/tag/v1.18.4) - 2023-06-26)

- Disable self-tracing, enable self-metrics, and make these optional behaviors. Bugfix in span event timestamps. [#494](https://github.com/lightstep/otel-launcher-go/pull/494)

## [1.18.3](https://github.com/lightstep/otel-launcher-go/releases/tag/v1.18.3) - 2023-06-21)

- Re-release. [#492](https://github.com/lightstep/otel-launcher-go/pull/492)
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ test:
$(GOTEST) ./...); \
done

.PHONY: fmt
fmt:
set -e; for dir in $(ALL_GO_MOD_DIRS); do \
echo "go fmt in $${dir}"; \
(cd "$${dir}" && \
go fmt ./...); \
done

.PHONY: test-386
test-386:
if [ $(SKIP_386_TEST) = true ] ; then \
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.18.3
1.18.4
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/lightstep/otel-launcher-go
go 1.18

require (
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.18.3
github.com/lightstep/otel-launcher-go/pipelines v1.18.3
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.18.4
github.com/lightstep/otel-launcher-go/pipelines v1.18.4
github.com/sethvargo/go-envconfig v0.8.3
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/otel v1.16.0
Expand Down Expand Up @@ -42,8 +42,8 @@ require (
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/lightstep/go-expohisto v1.0.0 // indirect
github.com/lightstep/otel-launcher-go/lightstep/instrumentation v1.18.3 // indirect
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.3 // indirect
github.com/lightstep/otel-launcher-go/lightstep/instrumentation v1.18.4 // indirect
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.4 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
Expand Down
2 changes: 1 addition & 1 deletion launcher/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

package launcher

const version = "1.18.3"
const version = "1.18.4"
4 changes: 2 additions & 2 deletions lightstep/sdk/metric/example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/example
go 1.18

require (
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.18.3
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.18.4
github.com/lightstep/otel-launcher-go/pipelines v1.8.0
go.opentelemetry.io/proto/otlp v0.20.0
)
Expand Down Expand Up @@ -35,7 +35,7 @@ require (
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/lightstep/go-expohisto v1.0.0 // indirect
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.3 // indirect
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.4 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand Down
34 changes: 23 additions & 11 deletions lightstep/sdk/metric/exporters/otlp/otelcol/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ import (
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/batchprocessor"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric/noop"
apitrace "go.opentelemetry.io/otel/trace"
"go.uber.org/multierr"
"go.uber.org/zap"
)

type Option func(*Config)

// TODO: Config, Option, and the option impls are duplicated between
// this package and the metric exporter. Fix this.
type Config struct {
Batcher batchprocessor.Config
Exporter otlpexporter.Config
SelfMetrics bool
SelfSpans bool
Batcher batchprocessor.Config
Exporter otlpexporter.Config
}

type client struct {
Expand All @@ -54,6 +60,8 @@ type client struct {

func NewDefaultConfig() Config {
return Config{
SelfMetrics: true,
SelfSpans: false,
Batcher: batchprocessor.Config{
Timeout: 0,
SendBatchSize: 0,
Expand Down Expand Up @@ -130,9 +138,9 @@ func NewExporter(ctx context.Context, cfg Config) (metric.PushExporter, error) {
c := &client{}

if !cfg.Exporter.Arrow.Disabled {
c.settings.ID = component.NewID("otel/sdk/arrow")
c.settings.ID = component.NewID("otel/sdk/metric/arrow")
} else {
c.settings.ID = component.NewID("otel/sdk/otlp")
c.settings.ID = component.NewID("otel/sdk/metric/otlp")
}
logger, err := zap.NewProduction()
if err != nil {
Expand All @@ -141,14 +149,18 @@ func NewExporter(ctx context.Context, cfg Config) (metric.PushExporter, error) {

c.settings.TelemetrySettings.Logger = logger

// This is meta and we rely on global dependency injection,
// but we're hoping this works.
// Note: becomes otel.GetMeterProvider()
c.settings.TelemetrySettings.MeterProvider = otel.GetMeterProvider()
c.settings.TelemetrySettings.MetricsLevel = configtelemetry.LevelNormal
if cfg.SelfSpans {
c.settings.TelemetrySettings.TracerProvider = otel.GetTracerProvider()
} else {
c.settings.TelemetrySettings.TracerProvider = apitrace.NewNoopTracerProvider()
}

// Note: this may be too much tracing.
c.settings.TelemetrySettings.TracerProvider = otel.GetTracerProvider()
if cfg.SelfMetrics {
c.settings.TelemetrySettings.MeterProvider = otel.GetMeterProvider()
c.settings.TelemetrySettings.MetricsLevel = configtelemetry.LevelNormal
} else {
c.settings.TelemetrySettings.MeterProvider = noop.NewMeterProvider()
}

exp, err := otlpexporter.NewFactory().CreateMetricsExporter(ctx, c.settings, &cfg.Exporter)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions lightstep/sdk/metric/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.5.9
github.com/lightstep/go-expohisto v1.0.0
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.3
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.4
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector v0.79.0
go.opentelemetry.io/collector/component v0.79.0
Expand All @@ -22,6 +22,7 @@ require (
go.opentelemetry.io/otel v1.16.0
go.opentelemetry.io/otel/metric v1.16.0
go.opentelemetry.io/otel/sdk v1.16.0
go.opentelemetry.io/otel/trace v1.16.0
go.opentelemetry.io/proto/otlp v0.20.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.24.0
Expand Down Expand Up @@ -71,7 +72,6 @@ require (
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0012 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.10.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion lightstep/sdk/metric/internal/doevery/doevery.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ type invocationKey struct {
// same duration.
//
// Example usage:
// end := time.Now().Add(5 * time.Second)
//
// end := time.Now().Add(5 * time.Second)
// for end.After(time.Now()) {
// doevery.TimePeriod(1*time.Second, func() {
// fmt.Println("This will only appear once per second.")
Expand Down
5 changes: 3 additions & 2 deletions lightstep/sdk/metric/internal/syncstate/refcount_mapped.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ func (rm *refcountMapped) unref() {

// tryUnmap flips the mapped bit to "unmapped" state and returns true if both of the
// following conditions are true upon entry to this function:
// * There are no active references;
// * The mapped bit is in "mapped" state.
// - There are no active references;
// - The mapped bit is in "mapped" state.
//
// Otherwise no changes are done to mapped bit and false is returned.
func (rm *refcountMapped) tryUnmap() bool {
if atomic.LoadInt64(&rm.value) != 0 {
Expand Down
30 changes: 24 additions & 6 deletions lightstep/sdk/trace/exporters/otlp/otelcol/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,29 @@ import (
"go.opentelemetry.io/collector/config/configcompression"
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/batchprocessor"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric/noop"
"go.opentelemetry.io/otel/sdk/trace"
apitrace "go.opentelemetry.io/otel/trace"
"go.uber.org/multierr"
"go.uber.org/zap"
)

type Option func(*Config)

// TODO: Config, Option, and the option impls are duplicated between
// this package and the metric exporter. Fix this.
type Config struct {
Batcher batchprocessor.Config
Exporter otlpexporter.Config
SelfMetrics bool
SelfSpans bool
Batcher batchprocessor.Config
Exporter otlpexporter.Config
}

type client struct {
Expand Down Expand Up @@ -67,6 +74,8 @@ func (c *client) Shutdown(ctx context.Context) error {

func NewDefaultConfig() Config {
return Config{
SelfMetrics: true,
SelfSpans: false,
Batcher: batchprocessor.Config{
Timeout: 0,
SendBatchSize: 0,
Expand Down Expand Up @@ -143,9 +152,9 @@ func NewExporter(ctx context.Context, cfg Config) (trace.SpanExporter, error) {
c := &client{}

if !cfg.Exporter.Arrow.Disabled {
c.settings.ID = component.NewID("otel/sdk/arrow")
c.settings.ID = component.NewID("otel/sdk/trace/arrow")
} else {
c.settings.ID = component.NewID("otel/sdk/otlp")
c.settings.ID = component.NewID("otel/sdk/trace/otlp")
}
logger, err := zap.NewProduction()
if err != nil {
Expand All @@ -154,8 +163,17 @@ func NewExporter(ctx context.Context, cfg Config) (trace.SpanExporter, error) {

c.settings.TelemetrySettings.Logger = logger

// Note: this may be too much tracing.
c.settings.TelemetrySettings.TracerProvider = otel.GetTracerProvider()
if cfg.SelfSpans {
c.settings.TelemetrySettings.TracerProvider = otel.GetTracerProvider()
} else {
c.settings.TelemetrySettings.TracerProvider = apitrace.NewNoopTracerProvider()
}
if cfg.SelfMetrics {
c.settings.TelemetrySettings.MeterProvider = otel.GetMeterProvider()
c.settings.TelemetrySettings.MetricsLevel = configtelemetry.LevelNormal
} else {
c.settings.TelemetrySettings.MeterProvider = noop.NewMeterProvider()
}

exp, err := otlpexporter.NewFactory().CreateTracesExporter(ctx, c.settings, &cfg.Exporter)
if err != nil {
Expand Down
28 changes: 14 additions & 14 deletions lightstep/sdk/trace/exporters/otlp/otelcol/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ import (
"go.opentelemetry.io/collector/receiver/receivertest"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/resource"
"go.opentelemetry.io/otel/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
coltracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
tracev1 "go.opentelemetry.io/proto/otlp/trace/v1"
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
resourcev1 "go.opentelemetry.io/proto/otlp/resource/v1"
tracev1 "go.opentelemetry.io/proto/otlp/trace/v1"
// "google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
)
Expand Down Expand Up @@ -173,7 +173,7 @@ func (t *clientTestSuite) TestSpan() {
tracer := t.sdk.Tracer("test-tracer")
_, span := tracer.Start(ctx, "ExecuteRequest")
span.SetAttributes(attribute.String("test-attribute-1", "test-value-1"))
span.AddEvent("test event", trace.WithAttributes(attribute.String("test-event-attribute-1", "test-event-value-1")))
span.AddEvent("test event", trace.WithAttributes(attribute.String("test-event-attribute-1", "test-event-value-1")))
span.End()

_ = t.sdk.Shutdown(ctx)
Expand Down Expand Up @@ -203,15 +203,15 @@ func (t *clientTestSuite) TestSpan() {
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{
StringValue: "value",
},
},
},
},
&commonpb.KeyValue{
Key: "service.name",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{
StringValue: "tester",
},
},
},
},
},
Expand All @@ -223,11 +223,11 @@ func (t *clientTestSuite) TestSpan() {
},
Spans: []*tracev1.Span{
&tracev1.Span{
SpanId: []byte(unqSpanID),
SpanId: []byte(unqSpanID),
TraceId: []byte(unqTraceID),
Kind: tracev1.Span_SPAN_KIND_INTERNAL,
Name: "ExecuteRequest",
Status: &tracev1.Status{},
Kind: tracev1.Span_SPAN_KIND_INTERNAL,
Name: "ExecuteRequest",
Status: &tracev1.Status{},
Attributes: []*commonpb.KeyValue{
&commonpb.KeyValue{
Key: "test-attribute-1",
Expand All @@ -240,8 +240,8 @@ func (t *clientTestSuite) TestSpan() {
},
Events: []*tracev1.Span_Event{
{
TimeUnixNano: uint64(roSpan.Events()[0].Time.Nanosecond()),
Name: "test event",
TimeUnixNano: uint64(roSpan.Events()[0].Time.UnixNano()),
Name: "test event",
Attributes: []*commonpb.KeyValue{
{
Key: "test-event-attribute-1",
Expand All @@ -252,7 +252,7 @@ func (t *clientTestSuite) TestSpan() {
},
},
},
DroppedAttributesCount: uint32(roSpan.DroppedAttributes()),
DroppedAttributesCount: uint32(roSpan.DroppedAttributes()),
},
},
},
Expand Down Expand Up @@ -321,7 +321,7 @@ func (t *clientTestSuite) TestD2PD() {
t.Equal(event.Time.Nanosecond(), actualEvent.Timestamp().AsTime().Nanosecond())
t.Equal(event.Name, actualEvent.Name())
t.Equal(uint32(event.DroppedAttributeCount), actualEvent.DroppedAttributesCount())

for _, attr := range event.Attributes {
actualEventVal, ok := actualEvent.Attributes().Get(string(attr.Key))
t.True(ok)
Expand All @@ -342,4 +342,4 @@ func (t *clientTestSuite) TestD2PD() {
t.Equal(attr.Value.AsString(), actualLinkVal.AsString())
}
}
}
}
2 changes: 1 addition & 1 deletion lightstep/sdk/trace/exporters/otlp/otelcol/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func copyEvents(dest ptrace.SpanEventSlice, events []trace.Event) {
e1 := dest.AppendEmpty()
e1.SetDroppedAttributesCount(uint32(event.DroppedAttributeCount))
e1.SetName(event.Name)
e1.SetTimestamp(pcommon.Timestamp((event.Time.Nanosecond())))
e1.SetTimestamp(pcommon.NewTimestampFromTime(event.Time))

internal.CopyAttributes(e1.Attributes(), attribute.NewSet(event.Attributes...))
}
Expand Down
4 changes: 2 additions & 2 deletions lightstep/sdk/trace/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/f5/otel-arrow-adapter v0.0.0-20230612212022-445aac7c6ae8
github.com/google/go-cmp v0.5.9
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.3
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.4
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector v0.79.0
go.opentelemetry.io/collector/component v0.79.0
Expand All @@ -15,6 +15,7 @@ require (
go.opentelemetry.io/collector/processor/batchprocessor v0.79.0
go.opentelemetry.io/collector/receiver v0.79.0
go.opentelemetry.io/otel v1.16.0
go.opentelemetry.io/otel/metric v1.16.0
go.opentelemetry.io/otel/sdk v1.16.0
go.opentelemetry.io/otel/trace v1.16.0
go.opentelemetry.io/proto/otlp v0.20.0
Expand Down Expand Up @@ -67,7 +68,6 @@ require (
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0012 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
golang.org/x/mod v0.9.0 // indirect
Expand Down
Loading

0 comments on commit 5c3e341

Please sign in to comment.