Skip to content

Commit

Permalink
Add lowmemory preference, keep stateless as an alias (#597)
Browse files Browse the repository at this point in the history
Update "stateless" names to "lowmemory" throughout the code, for
clarity.

**Description:** 

**Link to tracking Issue:** 

Fixes #347.

**Documentation:** Updated.
  • Loading branch information
jmacd authored Jan 5, 2024
1 parent 3b55ac7 commit d783b1e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Unreleased

- Add "lowmemory" temporality naming, leaving "stateless" as an alias. [#597](https://github.com/lightstep/otel-launcher-go/pull/597)

## [1.23.0](https://github.com/lightstep/otel-launcher-go/releases/tag/v1.23.0) - 2023-12-20)

- Update to OTel-Arrow v0.13.0 dependencies. [#591](https://github.com/lightstep/otel-launcher-go/pull/591)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,16 @@ to be maintained. The temporality preference is configured by calling
`OTEL_EXPORTER_OTLP_METRIC_TEMPORALITY_PREFERENCE` environment
variable.

The launcher supports a "stateless" temporality preference. This
selection configures the ideal behavior for Lightstep by mixing
temporality setings.
The launcher supports the standard "lowmemory" temporality preference,
also known as "stateless" in this library. This selection configures
the ideal behavior for Lightstep by mixing temporality setings.

The 1.x launcher release series configures the "cumulative"
temporality preference by default. The next major release of launcher
will configure the "stateless" temporality preference.
will configure the "lowmemory" temporality preference.

Lightstep users are recommended to select either the "cumulative" or
"stateless" preference. The OpenTelemetry-specified "delta"
"lowmemory" preference. The OpenTelemetry-specified "delta"
temporality preference is not recommended for Lightstep users.

------
Expand Down
4 changes: 2 additions & 2 deletions launcher/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func (suite *testSuite) TestConfigurationOverrides() {
WithSpanExporterInsecure(false),
WithMetricExporterEndpoint("override-metrics-url"),
WithMetricExporterInsecure(false),
WithMetricExporterTemporalityPreference("stateless"),
WithMetricExporterTemporalityPreference("lowmemory"),
WithLogLevel("info"),
WithLogger(&suite.testLogger),
WithErrorHandler(&suite.testErrorHandler),
Expand Down Expand Up @@ -447,7 +447,7 @@ func (suite *testSuite) TestConfigurationOverrides() {
MetricExporterEndpoint: "override-metrics-url",
MetricExporterEndpointInsecure: false,
MetricReportingPeriod: "30s",
MetricExporterTemporalityPreference: "stateless",
MetricExporterTemporalityPreference: "lowmemory",
Headers: map[string]string{"lightstep-access-token": "override-access-token"},
LogLevel: "info",
Propagators: []string{"b3"},
Expand Down
2 changes: 1 addition & 1 deletion lightstep/sdk/metric/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Differences from the OpenTelemetry metrics SDK specification:
point](https://opentelemetry.io/docs/reference/specification/metrics/datamodel/#histogram).
Note that this aggregation only encodes the `.Min` and `.Max`
fields when configured with delta temporality. [Consider using the
"stateless" temporality preference in the launcher.](../../../README.md#temporality-settings).
"lowmemory" temporality preference in the launcher.](../../../README.md#temporality-settings).
3. Synchronous Gauge instrument behavior is [supported using an API
hint](#metric-instrument-hints-api).
4. The OTLP exporter is the only provided exporter. The OTLP exporter
Expand Down
12 changes: 6 additions & 6 deletions lightstep/sdk/metric/internal/viewstate/collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ func (p *statefulSyncInstrument[N, Storage, Methods]) Collect(seq data.Sequence,
}
}

// statelessSyncInstrument is a synchronous instrument that maintains no state.
type statelessSyncInstrument[N number.Any, Storage any, Methods aggregator.Methods[N, Storage]] struct {
// lowmemorySyncInstrument is a synchronous instrument that maintains no state.
type lowmemorySyncInstrument[N number.Any, Storage any, Methods aggregator.Methods[N, Storage]] struct {
compiledSyncBase[N, Storage, Methods]
}

// Collect for synchronous delta temporality.
func (p *statelessSyncInstrument[N, Storage, Methods]) Collect(seq data.Sequence, output *[]data.Instrument) {
func (p *lowmemorySyncInstrument[N, Storage, Methods]) Collect(seq data.Sequence, output *[]data.Instrument) {
var methods Methods

p.instLock.Lock()
Expand Down Expand Up @@ -91,14 +91,14 @@ func (p *statelessSyncInstrument[N, Storage, Methods]) Collect(seq data.Sequence
}
}

// statelessAsyncInstrument is an asynchronous instrument that keeps
// lowmemoryAsyncInstrument is an asynchronous instrument that keeps
// maintains no state.
type statelessAsyncInstrument[N number.Any, Storage any, Methods aggregator.Methods[N, Storage]] struct {
type lowmemoryAsyncInstrument[N number.Any, Storage any, Methods aggregator.Methods[N, Storage]] struct {
compiledAsyncBase[N, Storage, Methods]
}

// Collect for asynchronous cumulative temporality.
func (p *statelessAsyncInstrument[N, Storage, Methods]) Collect(seq data.Sequence, output *[]data.Instrument) {
func (p *lowmemoryAsyncInstrument[N, Storage, Methods]) Collect(seq data.Sequence, output *[]data.Instrument) {
p.instLock.Lock()
defer p.instLock.Unlock()

Expand Down
14 changes: 7 additions & 7 deletions lightstep/sdk/metric/internal/viewstate/viewstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,9 @@ func buildView[N number.Any, Traits number.Traits[N]](behavior singleBehavior) l
}

// newSyncView returns a compiled synchronous instrument. If the view
// calls for delta temporality, a stateless instrument is returned,
// calls for delta temporality, a lowmemory instrument is returned,
// otherwise for cumulative temporality a stateful instrument will be
// used. I.e., Delta->Stateless, Cumulative->Stateful.
// used. I.e., Delta->Lowmemory, Cumulative->Stateful.
func newSyncView[
N number.Any,
Storage any,
Expand All @@ -435,7 +435,7 @@ func newSyncView[
instrumentBase: metric, //nolint:govet
}
if behavior.tempo == aggregation.DeltaTemporality {
return &statelessSyncInstrument[N, Storage, Methods]{
return &lowmemorySyncInstrument[N, Storage, Methods]{
compiledSyncBase: instrument, //nolint:govet
}
}
Expand Down Expand Up @@ -487,8 +487,8 @@ func compileSync[N number.Any, Traits number.Traits[N]](behavior singleBehavior)

// newAsyncView returns a compiled asynchronous instrument. If the
// view calls for delta temporality, a stateful instrument is
// returned, otherwise for cumulative temporality a stateless
// instrument will be used. I.e., Cumulative->Stateless,
// returned, otherwise for cumulative temporality a lowmemory
// instrument will be used. I.e., Cumulative->Lowmemory,
// Delta->Stateful.
func newAsyncView[
N number.Any,
Expand Down Expand Up @@ -518,11 +518,11 @@ func newAsyncView[
compiledAsyncBase: instrument, //nolint:govet
}
}
// Gauges fall through to the stateless behavior
// Gauges fall through to the lowmemory behavior
// regardless of delta temporality.
}

return &statelessAsyncInstrument[N, Storage, Methods]{
return &lowmemoryAsyncInstrument[N, Storage, Methods]{
compiledAsyncBase: instrument, //nolint:govet
}
}
Expand Down
6 changes: 3 additions & 3 deletions lightstep/sdk/metric/internal/viewstate/viewstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ func TestSyncDeltaTemporalityMapDeletion(t *testing.T) {
acc2.(Updater[float64]).Update(1)

// There are two references to one entry in the map.
require.Equal(t, 1, len(inst.(*statelessSyncInstrument[float64, sum.MonotonicFloat64, sum.MonotonicFloat64Methods]).data))
require.Equal(t, 1, len(inst.(*lowmemorySyncInstrument[float64, sum.MonotonicFloat64, sum.MonotonicFloat64Methods]).data))

acc1.SnapshotAndProcess(false)
acc2.SnapshotAndProcess(true)
Expand All @@ -1408,7 +1408,7 @@ func TestSyncDeltaTemporalityMapDeletion(t *testing.T) {
),
)

require.Equal(t, 1, len(inst.(*statelessSyncInstrument[float64, sum.MonotonicFloat64, sum.MonotonicFloat64Methods]).data))
require.Equal(t, 1, len(inst.(*lowmemorySyncInstrument[float64, sum.MonotonicFloat64, sum.MonotonicFloat64Methods]).data))

acc1.SnapshotAndProcess(true)

Expand All @@ -1419,7 +1419,7 @@ func TestSyncDeltaTemporalityMapDeletion(t *testing.T) {
),
)

require.Equal(t, 0, len(inst.(*statelessSyncInstrument[float64, sum.MonotonicFloat64, sum.MonotonicFloat64Methods]).data))
require.Equal(t, 0, len(inst.(*lowmemorySyncInstrument[float64, sum.MonotonicFloat64, sum.MonotonicFloat64Methods]).data))
}

func TestRegexpMatch(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pipelines/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type PipelineConfig struct {
// cputime: v1 is lightstep/instrumentation/cputime
MetricsBuiltinLibraries []string

// TemporalityPreference is one of "cumulative", "delta", or "stateless"
// TemporalityPreference is one of "cumulative", "delta", or "lowmemory" (a.k.a. "stateless")
TemporalityPreference string

// Credentials carries the TLS settings.
Expand Down
2 changes: 1 addition & 1 deletion pipelines/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func tempoOptions(c PipelineConfig) (view.Option, otelsdkmetric.TemporalitySelec
otelSelector = func(otelsdkmetric.InstrumentKind) metricdata.Temporality {
return metricdata.DeltaTemporality
}
case "stateless":
case "stateless", "lowmemory":
// asyncPref set above.
syncPref = aggregation.DeltaTemporality

Expand Down

0 comments on commit d783b1e

Please sign in to comment.