Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Bump otel 2.0.0 #15518

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/aws-serverless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
"dependencies": {
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/instrumentation": "^0.57.2",
"@opentelemetry/instrumentation": "^0.200.0-dev.0",
"@opentelemetry/instrumentation-aws-lambda": "0.50.3",
"@opentelemetry/instrumentation-aws-sdk": "0.49.1",
"@sentry/core": "9.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/nestjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
},
"dependencies": {
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/core": "^1.30.1",
"@opentelemetry/instrumentation": "0.57.2",
"@opentelemetry/core": "^2.0.0-dev.0",
"@opentelemetry/instrumentation": "0.200.0-dev.0",
"@opentelemetry/instrumentation-nestjs-core": "0.44.1",
"@opentelemetry/semantic-conventions": "^1.30.0",
"@sentry/core": "9.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { isWrapped } from '@opentelemetry/core';
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
import {
InstrumentationBase,
InstrumentationNodeModuleDefinition,
InstrumentationNodeModuleFile,
isWrapped,
} from '@opentelemetry/instrumentation';
import { SDK_VERSION, captureException, startSpan } from '@sentry/core';
import { getEventSpanOptions } from './helpers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { isWrapped } from '@opentelemetry/core';
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
import {
InstrumentationBase,
InstrumentationNodeModuleDefinition,
InstrumentationNodeModuleFile,
isWrapped,
} from '@opentelemetry/instrumentation';
import type { Span } from '@sentry/core';
import {
Expand Down
12 changes: 6 additions & 6 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
},
"dependencies": {
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/context-async-hooks": "^1.30.1",
"@opentelemetry/core": "^1.30.1",
"@opentelemetry/instrumentation": "^0.57.2",
"@opentelemetry/context-async-hooks": "^2.0.0-dev.0",
"@opentelemetry/core": "^2.0.0-dev.0",
"@opentelemetry/instrumentation": "^0.200.0-dev.0",
"@opentelemetry/instrumentation-amqplib": "^0.46.1",
"@opentelemetry/instrumentation-connect": "0.43.1",
"@opentelemetry/instrumentation-dataloader": "0.16.1",
Expand All @@ -78,7 +78,7 @@
"@opentelemetry/instrumentation-generic-pool": "0.43.1",
"@opentelemetry/instrumentation-graphql": "0.47.1",
"@opentelemetry/instrumentation-hapi": "0.45.2",
"@opentelemetry/instrumentation-http": "0.57.2",
"@opentelemetry/instrumentation-http": "0.200.0-dev.0",
"@opentelemetry/instrumentation-ioredis": "0.47.1",
"@opentelemetry/instrumentation-kafkajs": "0.7.1",
"@opentelemetry/instrumentation-knex": "0.44.1",
Expand All @@ -92,8 +92,8 @@
"@opentelemetry/instrumentation-redis-4": "0.46.1",
"@opentelemetry/instrumentation-tedious": "0.18.1",
"@opentelemetry/instrumentation-undici": "0.10.1",
"@opentelemetry/resources": "^1.30.1",
"@opentelemetry/sdk-trace-base": "^1.30.1",
"@opentelemetry/resources": "^2.0.0-dev.0",
"@opentelemetry/sdk-trace-node": "^2.0.0-dev.0",
"@opentelemetry/semantic-conventions": "^1.30.0",
"@prisma/instrumentation": "6.4.1",
"@sentry/core": "9.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type * as http from 'node:http';
import type { IncomingMessage, RequestOptions } from 'node:http';
import type * as https from 'node:https';
import type { EventEmitter } from 'node:stream';
import { VERSION } from '@opentelemetry/core';
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
import type { AggregationCounts, Client, RequestEventData, SanitizedRequestData, Scope } from '@sentry/core';
Expand Down Expand Up @@ -81,7 +80,7 @@ const MAX_BODY_BYTE_LENGTH = 1024 * 1024;
*/
export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpInstrumentationOptions> {
public constructor(config: SentryHttpInstrumentationOptions = {}) {
super('@sentry/instrumentation-http', VERSION, config);
super('@sentry/instrumentation-http', '2.0.0-dev.0', config);
}

/** @inheritdoc */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { VERSION } from '@opentelemetry/core';
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
import { InstrumentationBase } from '@opentelemetry/instrumentation';
import type { SanitizedRequestData } from '@sentry/core';
Expand Down Expand Up @@ -56,7 +55,7 @@ export class SentryNodeFetchInstrumentation extends InstrumentationBase<SentryNo
private _propagationDecisionMap: LRUMap<string, boolean>;

public constructor(config: SentryNodeFetchInstrumentationOptions = {}) {
super('@sentry/instrumentation-node-fetch', VERSION, config);
super('@sentry/instrumentation-node-fetch', '2.0.0-dev.0', config);
this._channelSubs = [];
this._propagationDecisionMap = new LRUMap<string, boolean>(100);
}
Expand Down
9 changes: 4 additions & 5 deletions packages/node/src/sdk/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as os from 'node:os';
import type { Tracer } from '@opentelemetry/api';
import { trace } from '@opentelemetry/api';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import type { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
import type { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import type { DynamicSamplingContext, Scope, ServerRuntimeClientOptions, TraceContext } from '@sentry/core';
import { SDK_VERSION, ServerRuntimeClient, applySdkMetadata, logger } from '@sentry/core';
import { getTraceContextForScope } from '@sentry/opentelemetry';
Expand All @@ -14,7 +14,7 @@ const DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS = 60_000; // 60s was chosen arbitr

/** A client for using Sentry with Node & OpenTelemetry. */
export class NodeClient extends ServerRuntimeClient<NodeClientOptions> {
public traceProvider: BasicTracerProvider | undefined;
public traceProvider: NodeTracerProvider | undefined;
private _tracer: Tracer | undefined;
private _clientReportInterval: NodeJS.Timeout | undefined;
private _clientReportOnExitFlushListener: (() => void) | undefined;
Expand Down Expand Up @@ -60,10 +60,9 @@ export class NodeClient extends ServerRuntimeClient<NodeClientOptions> {
// eslint-disable-next-line jsdoc/require-jsdoc
public async flush(timeout?: number): Promise<boolean> {
const provider = this.traceProvider;
const spanProcessor = provider?.activeSpanProcessor;

if (spanProcessor) {
await spanProcessor.forceFlush();
if (provider) {
await provider.forceFlush();
}

if (this.getOptions().sendClientReports) {
Expand Down
12 changes: 6 additions & 6 deletions packages/node/src/sdk/initOtel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import moduleModule from 'module';
import { DiagLogLevel, diag } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import type { SpanProcessor } from '@opentelemetry/sdk-trace-base';
import { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
import { resourceFromAttributes } from '@opentelemetry/resources';
import type { SpanProcessor } from '@opentelemetry/sdk-trace-node';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import {
ATTR_SERVICE_NAME,
ATTR_SERVICE_VERSION,
Expand Down Expand Up @@ -108,11 +108,11 @@ function getPreloadMethods(integrationNames?: string[]): ((() => void) & { id: s
}

/** Just exported for tests. */
export function setupOtel(client: NodeClient, options: AdditionalOpenTelemetryOptions = {}): BasicTracerProvider {
export function setupOtel(client: NodeClient, options: AdditionalOpenTelemetryOptions = {}): NodeTracerProvider {
// Create and configure NodeTracerProvider
const provider = new BasicTracerProvider({
const provider = new NodeTracerProvider({
sampler: new SentrySampler(client),
resource: new Resource({
resource: resourceFromAttributes({
[ATTR_SERVICE_NAME]: 'node',
// eslint-disable-next-line deprecation/deprecation
[SEMRESATTRS_SERVICE_NAMESPACE]: 'sentry',
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/utils/ensureIsWrapped.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isWrapped } from '@opentelemetry/core';
import { isWrapped } from '@opentelemetry/instrumentation';
import { consoleSandbox, getClient, getGlobalScope, hasSpansEnabled, isEnabled } from '@sentry/core';
import type { NodeClient } from '../sdk/client';
import { isCjs } from './commonjs';
Expand Down
16 changes: 8 additions & 8 deletions packages/opentelemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@
},
"peerDependencies": {
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/context-async-hooks": "^1.30.1",
"@opentelemetry/core": "^1.30.1",
"@opentelemetry/instrumentation": "^0.57.1",
"@opentelemetry/sdk-trace-base": "^1.30.1",
"@opentelemetry/context-async-hooks": "^2.0.0-dev.0",
"@opentelemetry/core": "^2.0.0-dev.0",
"@opentelemetry/instrumentation": "^0.200.0-dev.0",
"@opentelemetry/sdk-trace-base": "^2.0.0-dev.0",
"@opentelemetry/semantic-conventions": "^1.28.0"
},
"devDependencies": {
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/context-async-hooks": "^1.30.1",
"@opentelemetry/core": "^1.30.1",
"@opentelemetry/instrumentation": "^0.57.2",
"@opentelemetry/sdk-trace-base": "^1.30.1",
"@opentelemetry/context-async-hooks": "^2.0.0-dev.0",
"@opentelemetry/core": "^2.0.0-dev.0",
"@opentelemetry/instrumentation": "^0.200.0-dev.0",
"@opentelemetry/sdk-trace-base": "^2.0.0-dev.0",
"@opentelemetry/semantic-conventions": "^1.30.0"
},
"scripts": {
Expand Down
7 changes: 3 additions & 4 deletions packages/opentelemetry/src/custom/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { OpenTelemetryClient as OpenTelemetryClientInterface } from '../typ
/* eslint-disable @typescript-eslint/no-explicit-any */

/**
* Wrap an Client class with things we need for OpenTelemetry support.
* Wrap a Client class with things we need for OpenTelemetry support.
* Make sure that the Client class passed in is non-abstract!
*
* Usage:
Expand Down Expand Up @@ -49,10 +49,9 @@ export function wrapClientClass<
*/
public async flush(timeout?: number): Promise<boolean> {
const provider = this.traceProvider;
const spanProcessor = provider?.activeSpanProcessor;

if (spanProcessor) {
await spanProcessor.forceFlush();
if (provider) {
await provider.forceFlush();
}

return super.flush(timeout);
Expand Down
7 changes: 4 additions & 3 deletions packages/opentelemetry/src/spanExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export function createTransactionForOtelSpan(span: ReadableSpan): TransactionEve
// even if `span.parentSpanId` is set
// this is the case when we are starting a new trace, where we have a virtual span based on the propagationContext
// We only want to continue the traceId in this case, but ignore the parent span
const parent_span_id = span.parentSpanId;
const parent_span_id = span.parentSpanContext?.spanId;

const status = mapStatus(span);

Expand Down Expand Up @@ -324,8 +324,9 @@ function createAndFinishSpanForOtelSpan(node: SpanNode, spans: SpanJSON[], sentS

const span_id = span.spanContext().spanId;
const trace_id = span.spanContext().traceId;
const parent_span_id = span.parentSpanContext?.spanId;

const { attributes, startTime, endTime, parentSpanId, links } = span;
const { attributes, startTime, endTime, links } = span;

const { op, description, data, origin = 'manual' } = getSpanData(span);
const allData = dropUndefinedKeys({
Expand All @@ -342,7 +343,7 @@ function createAndFinishSpanForOtelSpan(node: SpanNode, spans: SpanJSON[], sentS
trace_id,
data: allData,
description,
parent_span_id: parentSpanId,
parent_span_id,
start_timestamp: spanTimeInputToSeconds(startTime),
// This is [0,0] by default in OTEL, in which case we want to interpret this as no end time
timestamp: spanTimeInputToSeconds(endTime) || undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry/src/utils/groupSpansWithParents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function getLocalParentId(span: ReadableSpan): string | undefined {
const parentIsRemote = span.attributes[SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE] === true;
// If the parentId is the trace parent ID, we pretend it's undefined
// As this means the parent exists somewhere else
return !parentIsRemote ? span.parentSpanId : undefined;
return !parentIsRemote ? span.parentSpanContext?.spanId : undefined;
}

function createOrUpdateSpanNodeAndRefs(nodeMap: SpanMap, span: ReadableSpan): void {
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry/src/utils/spanTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SpanKind, SpanStatus } from '@opentelemetry/api';
import type {SpanContext, SpanKind, SpanStatus} from '@opentelemetry/api';
import type { ReadableSpan, TimedEvent } from '@opentelemetry/sdk-trace-base';

import type { AbstractSpan } from '../types';
Expand Down Expand Up @@ -54,9 +54,9 @@ export function spanHasName<SpanType extends AbstractSpan>(span: SpanType): span
*/
export function spanHasParentId<SpanType extends AbstractSpan>(
span: SpanType,
): span is SpanType & { parentSpanId: string } {
): span is SpanType & { spanContext?: SpanContext } {
const castSpan = span as ReadableSpan;
return !!castSpan.parentSpanId;
return !!castSpan.parentSpanContext?.spanId;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/opentelemetry/test/helpers/initOtel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DiagLogLevel, diag } from '@opentelemetry/api';
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
import { Resource } from '@opentelemetry/resources';
import { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
import { resourceFromAttributes } from '@opentelemetry/resources';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import {
ATTR_SERVICE_NAME,
ATTR_SERVICE_VERSION,
Expand Down Expand Up @@ -52,11 +52,11 @@ export function initOtel(): void {
}

/** Just exported for tests. */
export function setupOtel(client: TestClientInterface): BasicTracerProvider {
export function setupOtel(client: TestClientInterface): NodeTracerProvider {
// Create and configure NodeTracerProvider
const provider = new BasicTracerProvider({
const provider = new NodeTracerProvider({
sampler: new SentrySampler(client),
resource: new Resource({
resource: resourceFromAttributes({
[ATTR_SERVICE_NAME]: 'opentelemetry-test',
// eslint-disable-next-line deprecation/deprecation
[SEMRESATTRS_SERVICE_NAMESPACE]: 'sentry',
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry/test/trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1927,5 +1927,5 @@ function getSpanAttributes(span: AbstractSpan): Record<string, unknown> | undefi
}

function getSpanParentSpanId(span: AbstractSpan): string | undefined {
return (span as ReadableSpan).parentSpanId;
return (span as ReadableSpan).parentSpanContext?.spanId;
}
6 changes: 3 additions & 3 deletions packages/vercel-edge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
},
"devDependencies": {
"@edge-runtime/types": "3.0.1",
"@opentelemetry/core": "^1.30.1",
"@opentelemetry/resources": "^1.30.1",
"@opentelemetry/sdk-trace-base": "^1.30.1",
"@opentelemetry/core": "^2.0.0-dev.0",
"@opentelemetry/resources": "^2.0.0-dev.0",
"@opentelemetry/sdk-trace-node": "^2.0.0-dev.0",
"@opentelemetry/semantic-conventions": "^1.28.0",
"@sentry/opentelemetry": "9.2.0"
},
Expand Down
5 changes: 2 additions & 3 deletions packages/vercel-edge/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ export class VercelEdgeClient extends ServerRuntimeClient<VercelEdgeClientOption
// eslint-disable-next-line jsdoc/require-jsdoc
public async flush(timeout?: number): Promise<boolean> {
const provider = this.traceProvider;
const spanProcessor = provider?.activeSpanProcessor;

if (spanProcessor) {
await spanProcessor.forceFlush();
if (provider) {
await provider.forceFlush();
}

if (this.getOptions().sendClientReports) {
Expand Down
8 changes: 4 additions & 4 deletions packages/vercel-edge/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DiagLogLevel, diag } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
import { resourceFromAttributes } from '@opentelemetry/resources';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import {
ATTR_SERVICE_NAME,
ATTR_SERVICE_VERSION,
Expand Down Expand Up @@ -151,9 +151,9 @@ export function setupOtel(client: VercelEdgeClient): void {
}

// Create and configure NodeTracerProvider
const provider = new BasicTracerProvider({
const provider = new NodeTracerProvider({
sampler: new SentrySampler(client),
resource: new Resource({
resource: resourceFromAttributes({
[ATTR_SERVICE_NAME]: 'edge',
// eslint-disable-next-line deprecation/deprecation
[SEMRESATTRS_SERVICE_NAMESPACE]: 'sentry',
Expand Down
Loading
Loading