Skip to content

[sdk-node, sdk-metrics] support options to ConsoleMetricExporter from declarative config #6957

Description

@trentm

Take this declarative config:

file_format: "1.1"
meter_provider:
  readers:
    - periodic:
        exporter:
          console:
            temporality_preference: delta
            default_histogram_aggregation: base2_exponential_bucket_histogram

Once #6954 is merged, attempting to startNodeSDK() with this declarative config will result in this diag.warn:

Config warning: some specified PushMetricExporter configuration properties were not handled by SDK setup: ["temporality_preference","default_histogram_aggregation"]

This issue is about supporting those temporality_preference and default_histogram_aggregation options.
They could be handled separately, because there are separate issues for each.

default_histogram_aggregation

temporality_preference

ConsoleMetricExporter currently accepts a temporalitySelector?: AggregationTemporalitySelector; argument.

However, some issues here:

  1. This temporalitySelector is not the same type for specifying a temporality_preference config value as is currently accepted by the OTLPMetricExporter classes. They take a temporalityPreference:

export interface OTLPMetricExporterOptions extends OTLPExporterConfigBase {
temporalityPreference?:
| AggregationTemporalityPreference
| AggregationTemporality;
aggregationPreference?: AggregationSelector;
}

Would it be better to have ConsoleMetricExporter and OTLPMetricExporter accept the same type of option for a "temporality preference"?

  1. In addition to that, there is some confusion (and I think a limitation) in the AggregationTemporalitySelector type accepted by ConsoleMetricExporter.

That type is as follows:

export enum AggregationTemporality {
  DELTA,
  CUMULATIVE,
}

export type AggregationTemporalitySelector = (
  instrumentType: InstrumentType
) => AggregationTemporality;

That AggregationTemporality does not support the "low_memory" the value for temporality_preference defined in declarative config:

    "ExporterTemporalityPreference": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "cumulative",
        "delta",
        "low_memory"
      ]
    },

Now look at the type used for OTLPMetricExporter's:

export interface OTLPMetricExporterOptions extends OTLPExporterConfigBase {
  temporalityPreference?:
    | AggregationTemporalityPreference
    | AggregationTemporality;
  aggregationPreference?: AggregationSelector;
}

export enum AggregationTemporalityPreference {
  DELTA,
  CUMULATIVE,
  LOWMEMORY,
}

Why does are there both enum AggregationTemporalityPreference and enum AggregationTemporality?
The latter is missing LOWMEMORY.
I haven't looked at the history here.
Do we need a breaking change to sdk-metrics to get to just one type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions