Skip to content

Commit

Permalink
Use delta temporality for React example
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Sep 8, 2023
1 parent 47254e6 commit 227e7e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
11 changes: 9 additions & 2 deletions examples/react-app-experimental/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useState } from "react";
import {
AggregationTemporalityPreference,
init,
} from "@autometrics/exporter-otlp-http";
import { autometrics } from "@autometrics/autometrics";
import { init } from "@autometrics/exporter-otlp-http";
import { useState } from "react";

import "./App.css";

// In order for Prometheus to succesfully get your client-side app metrics, you
Expand All @@ -21,6 +25,9 @@ init({
commit: import.meta.env.VITE_AUTOMETRICS_COMMIT,
branch: import.meta.env.VITE_AUTOMETRICS_BRANCH,
},
// Delta temporality is important to allow for correct aggregation of
// client-side metrics.
temporalityPreference: AggregationTemporalityPreference.DELTA,
});

type Post = {
Expand Down
15 changes: 6 additions & 9 deletions packages/exporter-otlp-http/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import {
AggregationTemporality,
PeriodicExportingMetricReader,
} from "@opentelemetry/sdk-metrics";
import {
AggregationTemporalityPreference,
OTLPMetricExporter,
Expand All @@ -12,9 +8,12 @@ import {
createDefaultBuildInfo,
recordBuildInfo,
} from "@autometrics/autometrics";
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";

import { registerExporterInternal } from "./registerExporterInternal";

export { AggregationTemporalityPreference };

export type InitOptions = {
/**
* URL of the OpenTelemetry Collector to push metrics to.
Expand Down Expand Up @@ -52,11 +51,9 @@ export type InitOptions = {
* The aggregation temporality preference.
*
* By default, we use `AggregationTemporality.CUMULATIVE`. You may wish to
* change this depending on the OpenTelemetry Collector you use.
* change this depending on the setup you use.
*/
temporalityPreference?:
| AggregationTemporalityPreference
| AggregationTemporality;
temporalityPreference?: AggregationTemporalityPreference;

/**
* Optional build info to be added to the `build_info` metric.
Expand All @@ -73,7 +70,7 @@ export function init({
pushInterval = 5000,
concurrencyLimit,
timeout = 1000,
temporalityPreference = AggregationTemporality.CUMULATIVE,
temporalityPreference = AggregationTemporalityPreference.CUMULATIVE,
buildInfo,
}: InitOptions) {
amLogger.info(`Exporter will push to the OTLP/HTTP endpoint at ${url}`);
Expand Down

0 comments on commit 227e7e4

Please sign in to comment.