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

feat: opentelemetry integration #2235

Conversation

ShubhamPalriwala
Copy link
Member

What does this PR do?

Enables exporting app metrics to any OpenTelemetry supported Client given the NEXT_PUBLIC_OPENTELEMETRY_LISTENER_URL is passed

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

Copy link

vercel bot commented Mar 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Visit Preview Mar 14, 2024 2:10pm
formbricks-com ⬜️ Ignored (Inspect) Visit Preview Mar 14, 2024 2:10pm

Copy link
Contributor

github-actions bot commented Mar 14, 2024

Thank you for following the naming conventions for pull request titles! 🙏

Copy link
Contributor

apps/web/instrumentation.ts

It's a good practice to add error handling to the OpenTelemetry instrumentation setup. This will help in identifying any issues that might occur during the setup process and prevent the application from crashing due to unhandled exceptions.
Create Issue
See the diff
Checkout the fix

    try {
      startInstrumentationForNode(process.env.NEXT_PUBLIC_OPENTELEMETRY_LISTENER_URL);
    } catch (error) {
      console.error('Failed to start OpenTelemetry instrumentation:', error);
    }
git fetch origin && git checkout -b ReviewBot/Addin-tdr046h origin/ReviewBot/Addin-tdr046h

Comment on lines 2 to 6
if (process.env.NEXT_RUNTIME === "nodejs" && process.env.NEXT_PUBLIC_OPENTELEMETRY_LISTENER_URL) {
console.log("Configuring OpenTelemetry");
const { startInstrumentationForNode } = await import("./instrumentation.node");

startInstrumentationForNode(process.env.NEXT_PUBLIC_OPENTELEMETRY_LISTENER_URL);
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding error handling to the OpenTelemetry instrumentation setup to prevent the application from crashing due to unhandled exceptions.

Suggested change
if (process.env.NEXT_RUNTIME === "nodejs" && process.env.NEXT_PUBLIC_OPENTELEMETRY_LISTENER_URL) {
console.log("Configuring OpenTelemetry");
const { startInstrumentationForNode } = await import("./instrumentation.node");
startInstrumentationForNode(process.env.NEXT_PUBLIC_OPENTELEMETRY_LISTENER_URL);
if (process.env.NEXT_RUNTIME === "nodejs" && process.env.NEXT_PUBLIC_OPENTELEMETRY_LISTENER_URL) {
console.log("Configuring OpenTelemetry");
const { startInstrumentationForNode } = await import("./instrumentation.node");
try {
startInstrumentationForNode(process.env.NEXT_PUBLIC_OPENTELEMETRY_LISTENER_URL);
} catch (error) {
console.error('Failed to start OpenTelemetry instrumentation:', error);
}
}

@mattinannt mattinannt added this pull request to the merge queue Mar 14, 2024
Merged via the queue into main with commit e4078a3 Mar 14, 2024
10 of 14 checks passed
@mattinannt mattinannt deleted the shubham/for-2023-self-host-signoz-for-trying-out-their-monitoring branch March 14, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants