@bonniernews/datadawg
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

Datadawg - Simplify Your Datadog Integration

Datadawg is a user-friendly library that simplifies the integration of Datadog (dd-trace library) with your application. We've built an easy-to-use configuration wrapper and exported some of the functions we use, making it simple for developers to add custom tracking to their applications, monitor tasks, and report errors with different spans.

Features

  • Easy-to-use configuration wrapper for Datadog integration
  • Custom tracking of application logs
  • Task monitoring
  • Error reporting with different spans
  • United configuration for use across multiple repositories

Getting Started

To get started with Datadawg, simply install the package via npm:

npm install @bonniernews/datadawg

Next, require datadawg in your application:

const datadawg = require('@bonniernews/datadawg').init({
    repositoryUrl: 'github repository url',
    sourceVersion: 'github hash'
})

From there, you can begin using Datadawg's various features to track your application's metrics, monitor tasks, and report errors.

Examples

Here are a few examples of how to use Datadawg in your application:

Tracking Application Logs

According to Datadogs documentation here.

const datadawg = require('@bonniernews/datadawg')

datadawg.trace('Trace name', {resource: 'resource name'}, async () => { 
    // Your code
})

Notify error

const datadawg = require('@bonniernews/datadawg')

const error = new Error('something went wrong');

datadawg.noticeError(error)

// notice error with custom attributes
datadawg.noticeError(error, { customAttribute: 'test' })

Add trace attribute

Adding attributes to a span with addSpan makes it viewable in the Datadog UI, however, it is not searchable if your Datadog instance it not setup to index all spans which it rarely is. To add custom attributes which are searchable, use the addRootSpan function. This will add attributes to the root span which is more likely to be indexed and is therefore searchable.

To add custom attributes to the current span, use the addSpan function.

const datadawg = require('@bonniernews/datadawg')

datadawg.addSpan({ customAttribute: 'test' })

To add custom attributes to the root span, use the addRootSpan function.

const datadawg = require('@bonniernews/datadawg')

datadawg.addRootSpan({ customAttribute: 'test' })

License

This library is licensed under the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i @bonniernews/datadawg

Weekly Downloads

593

Version

3.1.0

License

MIT

Unpacked Size

9.27 kB

Total Files

5

Last publish

Collaborators

  • daghall
  • andreas.samuelsson
  • norla
  • mattiasobn
  • chrissode
  • jzachrisson
  • hilleso
  • adam.hakansson
  • amundsentb
  • jonaek
  • drgeobn
  • mikael.mattsson
  • morre
  • takolander
  • vitryssen
  • herbola
  • nifo
  • johark
  • aliceboberg
  • varneynz
  • gusliden
  • mxtr
  • karlbergc
  • martindanielson
  • joelekman
  • chavah
  • matsrorbecker
  • axeljohanssonbonniernews
  • markusn
  • linuss
  • joelabrahamsson
  • jonaswalden
  • indeedshouts
  • marcusgronblad