Giter Site home page Giter Site logo

prisma-axiom's Introduction

prisma-axiom: The official Prisma integration for Axiom prisma-axiom: The official Prisma integration for Axiom

Workflow Latest Release License

Axiom unlocks observability at any scale.

  • Ingest with ease, store without limits: Axiom’s next-generation datastore enables ingesting petabytes of data with ultimate efficiency. Ship logs from Kubernetes, AWS, Azure, Google Cloud, DigitalOcean, Nomad, and others.
  • Query everything, all the time: Whether DevOps, SecOps, or EverythingOps, query all your data no matter its age. No provisioning, no moving data from cold/archive to “hot”, and no worrying about slow queries. All your data, all. the. time.
  • Powerful dashboards, for continuous observability: Build dashboards to collect related queries and present information that’s quick and easy to digest for you and your team. Dashboards can be kept private or shared with others, and are the perfect way to bring together data from different sources

For more information check out the official documentation.

Usage

Install prisma-axiom

npm install --save prisma-axiom

If you use the Axiom CLI, run eval $(axiom config export -f) to configure your environment variables.

Otherwise create a personal token in the Axiom settings and export it as AXIOM_TOKEN. Set AXIOM_ORG_ID to the organization ID from the settings page of the organization you want to access.

Wrap your main functions in withAxiom to automatically set up telemetry and flush traces before exit:

import withAxiom from 'prisma-axiom';
const prisma = new PrismaClient();

async function main() {
  // do something with prisma
}

withAxiom(main)() // wrap function 

Enable the prisma tracing preview feature in schema.prisma like this:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["tracing"]
}

For further examples, head over to the examples directory.

License

Distributed under the MIT License.

prisma-axiom's People

Contributors

bahlo avatar damaredayo avatar lukasmalkmus avatar schehata avatar seiflotfy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

prisma-axiom's Issues

ensure deliverability of logs before server ends by utilizing a flush method & prisma beforeExit hook

Currently, prisma-axiom doesn't ensure deliverability of logs. for example if server or request ends before logs are sent to axiom, logs might be lost. A mechanism has to be put in-place to ensure the logs are delivered.

We can utilize something like:

function withAxiom<T>(optionsArg ?: Prisma.Subset<T, Prisma.PrismaClientOptions>) {
  const prisma = new PrismaClient(optionsArg);
  const { middleware, flush } = logWithAxiom();
  prisma.$use(middleware);
  prisma.$on('beforeExit', flush);
  return prisma;
}

Usage with Next.js functions / serverless setups

Hello there !

The README and examples only describe usage of prisma-axiom where a main function makes sense.

With a serverless based setup like Next.js 13 on Vercel, it's not clear where to setup the withAxiom call.

For example - how would you handle Next.js 13 Route Handlers that call a prisma client ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.