npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@kubiks/otel-better-auth

v2.0.2

Published

OpenTelemetry instrumentation for Better Auth - Add distributed tracing to your authentication flows with a single line of code

Readme

@kubiks/otel-better-auth

OpenTelemetry instrumentation for Better Auth. One-line setup for complete auth observability across all auth flows.

Better Auth Trace Visualization

Visualize your authentication flows with detailed span information including operation type, user IDs, session IDs, auth methods, and success/failure status.

Installation

npm install @kubiks/otel-better-auth
# or
pnpm add @kubiks/otel-better-auth

Peer Dependencies: @opentelemetry/api >= 1.9.0, better-auth >= 1.0.0

Usage

Quick Start

import { betterAuth } from "better-auth";
import { instrumentBetterAuth } from "@kubiks/otel-better-auth";

export const auth = instrumentBetterAuth(
  betterAuth({
    database: db,
    // ... your Better Auth config
  }),
);

Instrumenting Better Auth is just a single call—wrap the instance you already create and every API method invocation is traced automatically. Keep the rest of your configuration unchanged.

What Gets Traced

Authentication:

  • auth.http.oauth.callback.{provider} - OAuth callback with user ID
  • auth.http.signin.email - Email signin with user ID
  • auth.http.signup.email - Email signup with user ID
  • auth.http.oauth.initiate.{provider} - OAuth initiation
  • auth.http.signout - User signout
  • auth.http.get_session - Get session

Account & Password:

  • auth.http.verify_email - Email verification
  • auth.http.forgot_password - Password reset request
  • auth.http.reset_password - Password reset

Session Management:

  • auth.api.get_session - Get current session with user ID and session ID
  • auth.api.list_sessions - List all sessions
  • auth.api.revoke_session - Revoke a session
  • auth.api.revoke_sessions - Revoke multiple sessions
  • auth.api.revoke_other_sessions - Revoke all other sessions

Account Management:

  • auth.api.link_social_account - Link social account
  • auth.api.unlink_account - Unlink account
  • auth.api.list_user_accounts - List user accounts
  • auth.api.update_user - Update user profile
  • auth.api.delete_user - Delete user account

Password Management:

  • auth.api.change_password - Change password
  • auth.api.set_password - Set password
  • auth.api.forget_password - Forgot password request
  • auth.api.reset_password - Reset password

Email Management:

  • auth.api.change_email - Change email
  • auth.api.verify_email - Verify email with user ID
  • auth.api.send_verification_email - Send verification email

Span Attributes

Each span includes:

| Attribute | Description | Example | | ---------------- | -------------------------------- | -------------------------------------------- | | auth.operation | Type of operation | signin, signup, get_session, signout | | auth.method | Auth method | email, oauth | | auth.provider | OAuth provider (when applicable) | google, github | | auth.success | Operation success | true, false | | auth.error | Error message (when failed) | Invalid credentials | | user.id | User ID (when available) | user_123456 | | user.email | User email (when available) | [email protected] | | session.id | Session ID (when available) | session_abcdef |

Configuration

instrumentBetterAuth(authClient, {
  tracerName: "my-app", // Custom tracer name
  tracer: customTracer, // Custom tracer instance
});

Examples

// lib/auth.ts
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { instrumentBetterAuth } from "@kubiks/otel-better-auth";
import { db } from "./db";

export const auth = instrumentBetterAuth(
  betterAuth({
    baseURL: process.env.BETTER_AUTH_URL,
    database: drizzleAdapter(db, { provider: "pg" }),
    socialProviders: {
      github: {
        clientId: process.env.GITHUB_CLIENT_ID,
        clientSecret: process.env.GITHUB_CLIENT_SECRET,
      },
    },
  }),
);

// app/api/auth/[...all]/route.ts
import { auth } from "@/lib/auth";
export { GET, POST } = auth.handler;

License

MIT