Skip to content

Conversation

@nurul3101
Copy link
Member

@nurul3101 nurul3101 commented Sep 16, 2025

Summary by CodeRabbit

  • New Features
    • Enables built-in profiling, log injection, and runtime metrics for Datadog tracing.
  • Refactor
    • Simplifies tracing setup with a direct initialization and a separate bootstrap for Prisma instrumentation.
    • Aligns startup flow with the new instrumentation approach.
  • Documentation
    • Updates instructions and examples to reflect the new tracing initialization and run command.
  • Chores
    • Removes unused acceleration extension to streamline setup.

@nurul3101 nurul3101 self-assigned this Sep 16, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 16, 2025

Walkthrough

The tracing setup shifts to direct dd-trace initialization in tracer.ts, with OpenTelemetry provider logic removed there. Prisma instrumentation is bootstrapped separately in src/index.ts via a provider and registerInstrumentations. The Prisma acceleration extension import is removed from src/client.ts. Documentation updates reflect tracer.init and the new bootstrap.

Changes

Cohort / File(s) Summary of Changes
Runtime tracing & instrumentation
src/tracer.ts, src/index.ts
src/tracer.ts: Replace provider-based setup with direct tracer.init({ profiling, logInjection, runtimeMetrics, dbmPropagationMode, env, sampleRate, service, version }); remove TracerProvider, registerInstrumentations, and PrismaInstrumentation usage. src/index.ts: Introduce instrumentation bootstrap: import tracer, create new tracer.TracerProvider(), call registerInstrumentations({ instrumentations: [new PrismaInstrumentation()], tracerProvider }), then provider.register().
Prisma client configuration
src/client.ts
Remove @prisma/extension-accelerate import and associated extension wiring.
Documentation
content/800-guides/190-data-dog.mdx
Update text to reference tracer.init and the new initialization semantics; adjust run instructions to npx tsx src/index.ts; remove notes tied to the previous OpenTelemetry/provider setup.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App Startup
  participant DD as dd-trace (tracer)
  participant Prov as TracerProvider (bootstrap)
  participant PI as PrismaInstrumentation
  participant PC as Prisma Client
  participant DB as Database

  App->>DD: tracer.init({ profiling, logInjection, runtimeMetrics, dbmPropagationMode, env, sampleRate, ... })
  App->>Prov: new TracerProvider()
  App->>PI: new PrismaInstrumentation()
  App->>Prov: registerInstrumentations({ instrumentations: [PI], tracerProvider: Prov })
  App->>Prov: provider.register()

  App->>PC: Execute queries
  PI-->>PC: Instrument Prisma operations
  PC->>DB: Query
  DB-->>PC: Result
  PC-->>DD: Spans/metrics emitted
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Update Datadog guide to get it working" succinctly and accurately reflects the PR's primary purpose—updating the Datadog guide and related example code (tracer initialization and instrumentation) so tracing works correctly; it is concise, specific to the guide, and informative for reviewers.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/update-datadog-guide

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

Dangerous URL check

No absolute URLs to prisma.io/docs found.
No local URLs found.

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

Redirect check

This PR probably requires the following redirects to be added to static/_redirects:

  • This PR does not change any pages in a way that would require a redirect.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
content/800-guides/190-data-dog.mdx (3)

96-99: Fix invalid Prisma CLI flag: prisma init has no --output.

Use prisma init (optionally --db) and then set generator.output in schema.prisma (as you already show later). The current command will fail.

Apply this diff:

-npx prisma init --db --output ../src/generated/prisma
+npx prisma init --db
+# The client output directory is configured in schema.prisma's generator block.

108-110: Remove unsupported --output here as well.

Same issue as above.

-npx prisma init --output ../src/generated/prisma
+npx prisma init

271-273: Inconsistent and incorrect raw SQL tagging; avoid PII leakage.

  • First tab uses prisma.rawquery (lowercase q), second uses prisma.rawQuery. Pick one key.
  • In the $allOperations extension you set prisma.rawQuery: query, but query there is a function, not SQL.
  • Emitting raw SQL and full args may leak secrets/PII.
-      tags: {
-        "prisma.rawquery": e.query,
-      },
+      tags: {
+        "prisma.raw_sql": e.query, // consider redaction before sending
+      },
@@
-            tags: {
+            tags: {
               "prisma.operation": operation,
               "prisma.model": model,
-              "prisma.args": JSON.stringify(args),
-              "prisma.rawQuery": query,
+              // Optional and risky: redact or omit args to avoid PII/secrets
+              // "prisma.args": redactArgs(args),

Consider removing either the $on("query") span or the $allOperations span to prevent duplicate spans when @prisma/instrumentation is also enabled.

Also applies to: 336-340

🧹 Nitpick comments (1)
content/800-guides/190-data-dog.mdx (1)

547-555: Operational note: mention Agent connectivity env vars.

Readers often miss setting DD_AGENT_HOST or DD_TRACE_AGENT_URL. Add a one‑liner showing how to run with DD_TRACE_OTEL_ENABLED and Agent host.

 Then, confirm the traces in Datadog:
+For local Docker Agent:
+```bash
+DD_TRACE_OTEL_ENABLED=true DD_AGENT_HOST=127.0.0.1 npx tsx src/index.ts
+```
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06393a5 and 65ea74c.

📒 Files selected for processing (1)
  • content/800-guides/190-data-dog.mdx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: runner / linkspector
  • GitHub Check: Check internal links
  • GitHub Check: Lost Pixel
🔇 Additional comments (2)
content/800-guides/190-data-dog.mdx (2)

365-370: Duplication risk: manual spans + @prisma/instrumentation will double count.

Choose one:

  • Simpler: rely on @prisma/instrumentation via the dd‑trace OTel bridge (remove manual spans).
  • Custom: keep manual spans and drop @prisma/instrumentation.

Do you want this guide to show the automatic path (bridge) or the fully manual path? I can adjust the examples accordingly.


229-240: Tracer init: validate options and agent config; initialize as early as possible.

File: content/800-guides/190-data-dog.mdx Lines: 229-240

  • tracer.init() must run before any Prisma import — you import ./tracer first (OK).
  • dbmPropagationMode: "full" is supported by dd-trace; valid values are "disabled", "service", "full".
  • Document Agent connectivity to avoid "No Agent" drops: prefer DD_TRACE_AGENT_URL (or DD_TRACE_AGENT_HOSTNAME + DD_TRACE_AGENT_PORT); also call out DD_ENV, DD_SERVICE, DD_VERSION, DD_DBM_PROPAGATION_MODE (service|full), DD_LOGS_INJECTION, and DD_TAGS. Agent-level vars (e.g., DD_APM_ENABLED / DD_APM_RECEIVER_PORT) apply to Agent configuration.

@nurul3101 nurul3101 merged commit 9f1adf3 into main Sep 16, 2025
9 of 11 checks passed
@nurul3101 nurul3101 deleted the feat/update-datadog-guide branch September 16, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants