@sentry/opentelemetry 9.25.0 → 9.26.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.
@@ -1 +1 @@
1
- {"type":"module","version":"9.25.0","sideEffects":false}
1
+ {"type":"module","version":"9.26.0","sideEffects":false}
@@ -1,5 +1,9 @@
1
1
  import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
2
2
  import type { TransactionEvent } from '@sentry/core';
3
+ import type { SpanNode } from './utils/groupSpansWithParents';
4
+ type SpanNodeCompleted = SpanNode & {
5
+ span: ReadableSpan;
6
+ };
3
7
  /**
4
8
  * A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.
5
9
  */
@@ -9,10 +13,24 @@ export declare class SentrySpanExporter {
9
13
  private _finishedSpanBucketSize;
10
14
  private _spansToBucketEntry;
11
15
  private _lastCleanupTimestampInS;
16
+ private _sentSpans;
12
17
  constructor(options?: {
13
18
  /** Lower bound of time in seconds until spans that are buffered but have not been sent as part of a transaction get cleared from memory. */
14
19
  timeout?: number;
15
20
  });
21
+ /**
22
+ * Check if a span with the given ID has already been sent using the `_sentSpans` as a cache.
23
+ * Purges "expired" spans from the cache upon checking.
24
+ * @param spanId The span id to check.
25
+ * @returns Whether the span is already sent in the past X seconds.
26
+ */
27
+ isSpanAlreadySent(spanId: string): boolean;
28
+ /** Remove "expired" span id entries from the _sentSpans cache. */
29
+ flushSentSpanCache(): void;
30
+ /** Check if a node is a completed root node or a node whose parent has already been sent */
31
+ nodeIsCompletedRootNode(node: SpanNode): node is SpanNodeCompleted;
32
+ /** Get all completed root nodes from a list of nodes */
33
+ getCompletedRootNodes(nodes: SpanNode[]): SpanNodeCompleted[];
16
34
  /** Export a single span. */
17
35
  export(span: ReadableSpan): void;
18
36
  /** Try to flush any pending spans immediately. */
@@ -21,7 +39,18 @@ export declare class SentrySpanExporter {
21
39
  clear(): void;
22
40
  /** Clear the flush timeout. */
23
41
  private _clearTimeout;
42
+ /**
43
+ * Send the given spans, but only if they are part of a finished transaction.
44
+ *
45
+ * Returns the sent spans.
46
+ * Spans remain unsent when their parent span is not yet finished.
47
+ * This will happen regularly, as child spans are generally finished before their parents.
48
+ * But it _could_ also happen because, for whatever reason, a parent span was lost.
49
+ * In this case, we'll eventually need to clean this up.
50
+ */
51
+ private _maybeSend;
24
52
  }
25
53
  /** Exported only for tests. */
26
54
  export declare function createTransactionForOtelSpan(span: ReadableSpan): TransactionEvent;
55
+ export {};
27
56
  //# sourceMappingURL=spanExporter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spanExporter.d.ts","sourceRoot":"","sources":["../../src/spanExporter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,KAAK,EAKV,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AAmCtB;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,aAAa,CAA4C;IAkBjE,OAAO,CAAC,oBAAoB,CAAqC;IACjE,OAAO,CAAC,uBAAuB,CAAS;IACxC,OAAO,CAAC,mBAAmB,CAA4C;IACvE,OAAO,CAAC,wBAAwB,CAAS;gBAEtB,OAAO,CAAC,EAAE;QAC3B,4IAA4I;QAC5I,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAOD,4BAA4B;IACrB,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAyCvC,kDAAkD;IAC3C,KAAK,IAAI,IAAI;IA6BpB,0BAA0B;IACnB,KAAK,IAAI,IAAI;IAKpB,+BAA+B;IAC/B,OAAO,CAAC,aAAa;CAMtB;AAiED,+BAA+B;AAC/B,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAoEjF"}
1
+ {"version":3,"file":"spanExporter.d.ts","sourceRoot":"","sources":["../../src/spanExporter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM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 import { SpanNode } from './utils/groupSpansWithParents';
4
+ type SpanNodeCompleted = SpanNode & {
5
+ span: ReadableSpan;
6
+ };
3
7
  /**
4
8
  * A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.
5
9
  */
@@ -9,10 +13,24 @@ export declare class SentrySpanExporter {
9
13
  private _finishedSpanBucketSize;
10
14
  private _spansToBucketEntry;
11
15
  private _lastCleanupTimestampInS;
16
+ private _sentSpans;
12
17
  constructor(options?: {
13
18
  /** Lower bound of time in seconds until spans that are buffered but have not been sent as part of a transaction get cleared from memory. */
14
19
  timeout?: number;
15
20
  });
21
+ /**
22
+ * Check if a span with the given ID has already been sent using the `_sentSpans` as a cache.
23
+ * Purges "expired" spans from the cache upon checking.
24
+ * @param spanId The span id to check.
25
+ * @returns Whether the span is already sent in the past X seconds.
26
+ */
27
+ isSpanAlreadySent(spanId: string): boolean;
28
+ /** Remove "expired" span id entries from the _sentSpans cache. */
29
+ flushSentSpanCache(): void;
30
+ /** Check if a node is a completed root node or a node whose parent has already been sent */
31
+ nodeIsCompletedRootNode(node: SpanNode): node is SpanNodeCompleted;
32
+ /** Get all completed root nodes from a list of nodes */
33
+ getCompletedRootNodes(nodes: SpanNode[]): SpanNodeCompleted[];
16
34
  /** Export a single span. */
17
35
  export(span: ReadableSpan): void;
18
36
  /** Try to flush any pending spans immediately. */
@@ -21,7 +39,18 @@ export declare class SentrySpanExporter {
21
39
  clear(): void;
22
40
  /** Clear the flush timeout. */
23
41
  private _clearTimeout;
42
+ /**
43
+ * Send the given spans, but only if they are part of a finished transaction.
44
+ *
45
+ * Returns the sent spans.
46
+ * Spans remain unsent when their parent span is not yet finished.
47
+ * This will happen regularly, as child spans are generally finished before their parents.
48
+ * But it _could_ also happen because, for whatever reason, a parent span was lost.
49
+ * In this case, we'll eventually need to clean this up.
50
+ */
51
+ private _maybeSend;
24
52
  }
25
53
  /** Exported only for tests. */
26
54
  export declare function createTransactionForOtelSpan(span: ReadableSpan): TransactionEvent;
55
+ export {};
27
56
  //# sourceMappingURL=spanExporter.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/opentelemetry",
3
- "version": "9.25.0",
3
+ "version": "9.26.0",
4
4
  "description": "Official Sentry utilities for OpenTelemetry",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/opentelemetry",
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@sentry/core": "9.25.0"
42
+ "@sentry/core": "9.26.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@opentelemetry/api": "^1.9.0",