Skip to content

Commit

Permalink
refactor(exporter-metrics-otlp-http): fix eslint warning
Browse files Browse the repository at this point in the history
Fixes the following eslint warning in exporter-metrics-otlp-http:

```
/home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/OTLPMetricExporterBase.ts
  120:30  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
```

The unused parameter can be explicitly typed as `InstrumentType`,
but since this default selector doesn't actually care about it, it
can also just be elided.

By adding an explict return type, if someone in the future added
the wrong parameter to the default selector function, TypeScript
would reject it.

Ref open-telemetry#5365
  • Loading branch information
chancancode committed Jan 29, 2025
1 parent 3c040c4 commit 7414e45
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,14 @@ function chooseTemporalitySelector(
return chooseTemporalitySelectorFromEnvironment();
}

const DEFAULT_AGGREGATION = Object.freeze({
type: AggregationType.DEFAULT,
});

function chooseAggregationSelector(
config: OTLPMetricExporterOptions | undefined
) {
if (config?.aggregationPreference) {
return config.aggregationPreference;
} else {
return (_instrumentType: any) => {
return {
type: AggregationType.DEFAULT,
};
};
}
): AggregationSelector {
return config?.aggregationPreference ?? (() => DEFAULT_AGGREGATION);
}

export class OTLPMetricExporterBase
Expand Down

0 comments on commit 7414e45

Please # to comment.