Home / File/ tracing.ts — drizzle-orm Source File

tracing.ts — drizzle-orm Source File

Architecture documentation for tracing.ts, a typescript file in the drizzle-orm codebase. 3 imports, 0 dependents.

File typescript DrizzleORM RelationalQuery 3 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  a27cf306_5b4a_0674_7a24_49e8096627e8["tracing.ts"]
  b2601924_ce0c_fcc0_f146_dee6a07b5964["api"]
  a27cf306_5b4a_0674_7a24_49e8096627e8 --> b2601924_ce0c_fcc0_f146_dee6a07b5964
  60baeebf_dfcb_74c0_06dd_4c46c78668fe["tracing-utils.ts"]
  a27cf306_5b4a_0674_7a24_49e8096627e8 --> 60baeebf_dfcb_74c0_06dd_4c46c78668fe
  55b8862d_43ed_5f90_f168_b7cf3a56bf2d["version.ts"]
  a27cf306_5b4a_0674_7a24_49e8096627e8 --> 55b8862d_43ed_5f90_f168_b7cf3a56bf2d
  style a27cf306_5b4a_0674_7a24_49e8096627e8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { Span, Tracer } from '@opentelemetry/api';
import { iife } from '~/tracing-utils.ts';
import { npmVersion } from '~/version.ts';

let otel: typeof import('@opentelemetry/api') | undefined;
let rawTracer: Tracer | undefined;
// try {
// 	otel = await import('@opentelemetry/api');
// } catch (err: any) {
// 	if (err.code !== 'MODULE_NOT_FOUND' && err.code !== 'ERR_MODULE_NOT_FOUND') {
// 		throw err;
// 	}
// }

type SpanName =
	| 'drizzle.operation'
	| 'drizzle.prepareQuery'
	| 'drizzle.buildSQL'
	| 'drizzle.execute'
	| 'drizzle.driver.execute'
	| 'drizzle.mapResponse';

/** @internal */
export const tracer = {
	startActiveSpan<F extends (span?: Span) => unknown>(name: SpanName, fn: F): ReturnType<F> {
		if (!otel) {
			return fn() as ReturnType<F>;
		}

		if (!rawTracer) {
			rawTracer = otel.trace.getTracer('drizzle-orm', npmVersion);
		}

		return iife(
			(otel, rawTracer) =>
				rawTracer.startActiveSpan(
					name,
					((span: Span) => {
						try {
							return fn(span);
						} catch (e) {
							span.setStatus({
								code: otel.SpanStatusCode.ERROR,
								message: e instanceof Error ? e.message : 'Unknown error', // eslint-disable-line no-instanceof/no-instanceof
							});
							throw e;
						} finally {
							span.end();
						}
					}) as F,
				),
			otel,
			rawTracer,
		);
	},
};

Domain

Subdomains

Types

Dependencies

  • api
  • tracing-utils.ts
  • version.ts

Frequently Asked Questions

What does tracing.ts do?
tracing.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, RelationalQuery subdomain.
What functions are defined in tracing.ts?
tracing.ts defines 1 function(s): tracer.startActiveSpan.
What does tracing.ts depend on?
tracing.ts imports 3 module(s): api, tracing-utils.ts, version.ts.
Where is tracing.ts in the architecture?
tracing.ts is located at drizzle-orm/src/tracing.ts (domain: DrizzleORM, subdomain: RelationalQuery, directory: drizzle-orm/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free