-
Notifications
You must be signed in to change notification settings - Fork 856
Update Datadog guide to get it working #7132
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
Conversation
WalkthroughThe 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
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.
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 |
Dangerous URL checkNo absolute URLs to prisma.io/docs found. |
|
Redirect checkThis PR probably requires the following redirects to be added to static/_redirects:
|
There was a problem hiding this 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 inithas no--output.Use
prisma init(optionally--db) and then setgenerator.outputinschema.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--outputhere 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 usesprisma.rawQuery. Pick one key.- In the
$allOperationsextension you setprisma.rawQuery: query, butquerythere 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$allOperationsspan to prevent duplicate spans when@prisma/instrumentationis 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_HOSTorDD_TRACE_AGENT_URL. Add a one‑liner showing how to run withDD_TRACE_OTEL_ENABLEDand 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
📒 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/instrumentationwill double count.Choose one:
- Simpler: rely on
@prisma/instrumentationvia 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.
Summary by CodeRabbit