File tree Expand file tree Collapse file tree
packages/opentelemetry-node/src/exporters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,18 +8,31 @@ import {
88 AggregationTemporality ,
99 ExportResult ,
1010 ExportResultCode ,
11- ResourceMetrics
11+ ResourceMetrics ,
12+ INodeClient
1213} from "@traceo-sdk/node-core" ;
14+ import { getGlobalTraceo } from "@traceo-sdk/node-core/dist/utils" ;
1315
1416export class TraceoOTLPMetricExporter extends OTLPMetricExporter {
15- constructor ( config : OTLPExporterNodeConfigBase ) {
17+ private client : INodeClient ;
18+
19+ constructor ( config ?: OTLPExporterNodeConfigBase ) {
1620 super ( {
1721 ...config ,
1822 temporalityPreference : AggregationTemporality . DELTA
1923 } ) ;
24+
25+ this . client = getGlobalTraceo ( ) ;
2026 }
2127
2228 public export ( metrics : ResourceMetrics , resultCallback : ( result : ExportResult ) => void ) : void {
29+ const isOffline = this . client . options . offline ;
30+ const isCollectMetrics = this . client . options . collectMetrics ;
31+
32+ if ( isOffline || ! isCollectMetrics ) {
33+ return ;
34+ }
35+
2336 const scopeMetrics : ScopeMetrics [ ] = metrics . scopeMetrics ;
2437 const flatMetrics : MetricData [ ] = scopeMetrics . flatMap ( scope => scope . metrics || [ ] ) ;
2538
You can’t perform that action at this time.
0 commit comments