@mark1russell7/otel-ts 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/node.ts CHANGED
@@ -29,10 +29,10 @@ import { NodeSDK, type NodeSDKConfiguration } from "@opentelemetry/sdk-node";
29
29
  import type { LogRecordExporter } from "@opentelemetry/sdk-logs";
30
30
  import type { SpanExporter } from "@opentelemetry/sdk-trace-base";
31
31
  import { ContextPropagator, claimContextRegistration } from "./context-propagator.js";
32
- import { contextMetricView } from "./context-processors.js";
33
- import { nodeLogRecordProcessors, nodeSpanProcessors } from "./node-exporters.js";
32
+ import { contextMetricViews } from "./context-processors.js";
33
+ import { histogramAggregation, nodeLogRecordProcessors, nodeSpanProcessors } from "./node-exporters.js";
34
34
 
35
- export { exporterNames, otlpProtocol, type ExporterName, type OtlpProtocol, type OtlpSignal } from "./node-exporters.js";
35
+ export { exporterNames, histogramAggregation, otlpProtocol, type ExporterName, type OtlpProtocol, type OtlpSignal } from "./node-exporters.js";
36
36
 
37
37
  export { outgoingTraceparent, createTraceEcho, runInRemoteTrace, type RemoteTraceOptions, type TraceEcho } from "./trace-echo.js";
38
38
 
@@ -121,7 +121,9 @@ export function startNodeTelemetry(options: NodeTelemetryOptions = {}): NodeTele
121
121
  sdk = new NodeSDK({
122
122
  serviceName: options.serviceName ?? env["OTEL_SERVICE_NAME"] ?? "node-service",
123
123
  textMapPropagator: new ContextPropagator(),
124
- views: [contextMetricView()],
124
+ // The aggregation of OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION:
125
+ // the views replace the preference of each reader
126
+ views: contextMetricViews(histogramAggregation(env)),
125
127
  ...exports,
126
128
  ...(options.instrumentations ? { instrumentations: options.instrumentations } : {}),
127
129
  });
package/src/tracing.ts CHANGED
@@ -8,6 +8,8 @@ import { LongTaskInstrumentation } from "@opentelemetry/instrumentation-long-tas
8
8
  import { registerInstrumentations } from "@opentelemetry/instrumentation";
9
9
  import type { ResolvedConfig } from "./types.js";
10
10
  import { hasDom } from "./env.js";
11
+ import { createContextSpanProcessor } from "./context-processors.js";
12
+ import { ContextPropagator } from "./context-propagator.js";
11
13
  import {
12
14
  createSessionSpanProcessor,
13
15
  type SessionIdReader,
@@ -30,11 +32,15 @@ export function setupTracing(
30
32
  resource,
31
33
  spanProcessors: [
32
34
  createSessionSpanProcessor(getSessionId),
35
+ // The context keys (docs/CONTEXT-DESIGN.md), before the export too
36
+ createContextSpanProcessor(),
33
37
  new BatchSpanProcessor(exporter),
34
38
  ],
35
39
  });
36
40
 
37
- provider.register({ contextManager });
41
+ // The propagator of otel-ts: `traceparent` on each call that the
42
+ // instrumentations permit, `baggage` only on an internal call
43
+ provider.register({ contextManager, propagator: new ContextPropagator() });
38
44
 
39
45
  registerInstrumentations({
40
46
  instrumentations: [