Skip to content

Commit 60f3b94

Browse files
authored
Self-instrumentation options; event timestamp bug fix (#494)
1 parent a56cd59 commit 60f3b94

File tree

15 files changed

+94
-50
lines changed

15 files changed

+94
-50
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
88

99
## Unreleased
1010

11+
## [1.18.4](https://github.com/lightstep/otel-launcher-go/releases/tag/v1.18.4) - 2023-06-26)
12+
13+
- 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)
14+
1115
## [1.18.3](https://github.com/lightstep/otel-launcher-go/releases/tag/v1.18.3) - 2023-06-21)
1216

1317
- Re-release. [#492](https://github.com/lightstep/otel-launcher-go/pull/492)

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ test:
102102
$(GOTEST) ./...); \
103103
done
104104

105+
.PHONY: fmt
106+
fmt:
107+
set -e; for dir in $(ALL_GO_MOD_DIRS); do \
108+
echo "go fmt in $${dir}"; \
109+
(cd "$${dir}" && \
110+
go fmt ./...); \
111+
done
112+
105113
.PHONY: test-386
106114
test-386:
107115
if [ $(SKIP_386_TEST) = true ] ; then \

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.18.3
1+
1.18.4

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/lightstep/otel-launcher-go
33
go 1.18
44

55
require (
6-
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.18.3
7-
github.com/lightstep/otel-launcher-go/pipelines v1.18.3
6+
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.18.4
7+
github.com/lightstep/otel-launcher-go/pipelines v1.18.4
88
github.com/sethvargo/go-envconfig v0.8.3
99
github.com/stretchr/testify v1.8.4
1010
go.opentelemetry.io/otel v1.16.0
@@ -42,8 +42,8 @@ require (
4242
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
4343
github.com/knadh/koanf v1.5.0 // indirect
4444
github.com/lightstep/go-expohisto v1.0.0 // indirect
45-
github.com/lightstep/otel-launcher-go/lightstep/instrumentation v1.18.3 // indirect
46-
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.3 // indirect
45+
github.com/lightstep/otel-launcher-go/lightstep/instrumentation v1.18.4 // indirect
46+
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.4 // indirect
4747
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
4848
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
4949
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect

launcher/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
package launcher
1616

17-
const version = "1.18.3"
17+
const version = "1.18.4"

lightstep/sdk/metric/example/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/lightstep/otel-launcher-go/lightstep/sdk/metric/example
33
go 1.18
44

55
require (
6-
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.18.3
6+
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.18.4
77
github.com/lightstep/otel-launcher-go/pipelines v1.8.0
88
go.opentelemetry.io/proto/otlp v0.20.0
99
)
@@ -35,7 +35,7 @@ require (
3535
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
3636
github.com/knadh/koanf v1.5.0 // indirect
3737
github.com/lightstep/go-expohisto v1.0.0 // indirect
38-
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.3 // indirect
38+
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.4 // indirect
3939
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
4040
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
4141
github.com/mitchellh/copystructure v1.2.0 // indirect

lightstep/sdk/metric/exporters/otlp/otelcol/client.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,21 @@ import (
3333
"go.opentelemetry.io/collector/processor"
3434
"go.opentelemetry.io/collector/processor/batchprocessor"
3535
"go.opentelemetry.io/otel"
36+
"go.opentelemetry.io/otel/metric/noop"
37+
apitrace "go.opentelemetry.io/otel/trace"
3638
"go.uber.org/multierr"
3739
"go.uber.org/zap"
3840
)
3941

4042
type Option func(*Config)
4143

44+
// TODO: Config, Option, and the option impls are duplicated between
45+
// this package and the metric exporter. Fix this.
4246
type Config struct {
43-
Batcher batchprocessor.Config
44-
Exporter otlpexporter.Config
47+
SelfMetrics bool
48+
SelfSpans bool
49+
Batcher batchprocessor.Config
50+
Exporter otlpexporter.Config
4551
}
4652

4753
type client struct {
@@ -54,6 +60,8 @@ type client struct {
5460

5561
func NewDefaultConfig() Config {
5662
return Config{
63+
SelfMetrics: true,
64+
SelfSpans: false,
5765
Batcher: batchprocessor.Config{
5866
Timeout: 0,
5967
SendBatchSize: 0,
@@ -130,9 +138,9 @@ func NewExporter(ctx context.Context, cfg Config) (metric.PushExporter, error) {
130138
c := &client{}
131139

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

142150
c.settings.TelemetrySettings.Logger = logger
143151

144-
// This is meta and we rely on global dependency injection,
145-
// but we're hoping this works.
146-
// Note: becomes otel.GetMeterProvider()
147-
c.settings.TelemetrySettings.MeterProvider = otel.GetMeterProvider()
148-
c.settings.TelemetrySettings.MetricsLevel = configtelemetry.LevelNormal
152+
if cfg.SelfSpans {
153+
c.settings.TelemetrySettings.TracerProvider = otel.GetTracerProvider()
154+
} else {
155+
c.settings.TelemetrySettings.TracerProvider = apitrace.NewNoopTracerProvider()
156+
}
149157

150-
// Note: this may be too much tracing.
151-
c.settings.TelemetrySettings.TracerProvider = otel.GetTracerProvider()
158+
if cfg.SelfMetrics {
159+
c.settings.TelemetrySettings.MeterProvider = otel.GetMeterProvider()
160+
c.settings.TelemetrySettings.MetricsLevel = configtelemetry.LevelNormal
161+
} else {
162+
c.settings.TelemetrySettings.MeterProvider = noop.NewMeterProvider()
163+
}
152164

153165
exp, err := otlpexporter.NewFactory().CreateMetricsExporter(ctx, c.settings, &cfg.Exporter)
154166
if err != nil {

lightstep/sdk/metric/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/golang/mock v1.6.0
1111
github.com/google/go-cmp v0.5.9
1212
github.com/lightstep/go-expohisto v1.0.0
13-
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.3
13+
github.com/lightstep/otel-launcher-go/lightstep/sdk/internal v1.18.4
1414
github.com/stretchr/testify v1.8.4
1515
go.opentelemetry.io/collector v0.79.0
1616
go.opentelemetry.io/collector/component v0.79.0
@@ -22,6 +22,7 @@ require (
2222
go.opentelemetry.io/otel v1.16.0
2323
go.opentelemetry.io/otel/metric v1.16.0
2424
go.opentelemetry.io/otel/sdk v1.16.0
25+
go.opentelemetry.io/otel/trace v1.16.0
2526
go.opentelemetry.io/proto/otlp v0.20.0
2627
go.uber.org/multierr v1.11.0
2728
go.uber.org/zap v1.24.0
@@ -71,7 +72,6 @@ require (
7172
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0012 // indirect
7273
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 // indirect
7374
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 // indirect
74-
go.opentelemetry.io/otel/trace v1.16.0 // indirect
7575
go.uber.org/atomic v1.10.0 // indirect
7676
golang.org/x/mod v0.9.0 // indirect
7777
golang.org/x/net v0.10.0 // indirect

lightstep/sdk/metric/internal/doevery/doevery.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ type invocationKey struct {
5555
// same duration.
5656
//
5757
// Example usage:
58-
// end := time.Now().Add(5 * time.Second)
58+
//
59+
// end := time.Now().Add(5 * time.Second)
5960
// for end.After(time.Now()) {
6061
// doevery.TimePeriod(1*time.Second, func() {
6162
// fmt.Println("This will only appear once per second.")

lightstep/sdk/metric/internal/syncstate/refcount_mapped.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ func (rm *refcountMapped) unref() {
5050

5151
// tryUnmap flips the mapped bit to "unmapped" state and returns true if both of the
5252
// following conditions are true upon entry to this function:
53-
// * There are no active references;
54-
// * The mapped bit is in "mapped" state.
53+
// - There are no active references;
54+
// - The mapped bit is in "mapped" state.
55+
//
5556
// Otherwise no changes are done to mapped bit and false is returned.
5657
func (rm *refcountMapped) tryUnmap() bool {
5758
if atomic.LoadInt64(&rm.value) != 0 {

0 commit comments

Comments
 (0)