Skip to content

Instantly share code, notes, and snippets.

@ericmustin
ericmustin / README.md
Created April 5, 2020 20:54
msgpack_sample_request

msgpack sample

A brief demonstration of sending a messagepack encoded trace

requirements and testing notes

tested with Node v10.15.1 and NPM 6.4.1

setup

  • download repository
@ericmustin
ericmustin / example_express_hook.js
Last active March 31, 2020 15:01
example dd express hook
// npm install
const tracer = require('dd-trace').init({debug: false})
tracer.use('express', {
hooks: {
request: (span, req, res) => {
console.log('express hook invoked')
span.setTag('hook_tag_key', 'hook_tag_value')
}
@ericmustin
ericmustin / example_updated_script.js
Created March 24, 2020 16:42
example script tracing
#!/usr/bin/env node
const configObj = require('../config/config');
// "dd-trace": "^0.19.0"
const tracer = require('dd-trace').init({
logInjection: true,
analytics: true,
env: process.env.NODE_ENV,
service: 'Imports',
debug: true
@ericmustin
ericmustin / sample_datadog_processing_pipeline.rb
Created March 20, 2020 17:26
sample_datadog_processing_pipeline
require 'ddtrace'
Datadog.configure do |c|
c.use :rails, service_name: "custom_my_app"
c.use :rack, distributed_tracing: true, web_service_name: 'nginx-example-frontend', request_queuing: true
c.tracer tags: { 'env' => 'ruby-testing' }
end
Datadog::Pipeline.before_flush(
Datadog::Pipeline::SpanProcessor.new { |span|
@ericmustin
ericmustin / index.js
Created March 2, 2020 14:37
example node fetch distributed tracing
// cd into root of this directory
// npm install
// npm install -g http-echo-server
// new terminal window from run `http-echo-server`
// node index.js
// see output that server receives in output.txt
tracer = require('dd-trace').init()
const fetch = require('node-fetch');
@ericmustin
ericmustin / index.js
Created February 24, 2020 19:54
aws_test_app example
const tracer = require('dd-trace').init()
tracer.use('aws-sdk', {
hooks: {
request: (span, response) => {
if (response.data && response.data.Attributes && response.data.Attributes.Owner) {
span.addTags({'aws.sns.topic_owner': response.data.Attributes.Owner.toString()})
}
}
}
@ericmustin
ericmustin / README.md
Created January 28, 2020 15:52
example statsd callback in node

setup and usage

  • download folder
  • cd into root
  • npm install
  • node index.js

Sample Output

COMP10929:statsd_example eric.mustin$ node index.js
@ericmustin
ericmustin / debug_output.txt
Created January 8, 2020 16:34
example request-promise distributed header id injection
Example app listening on port 5000!
Inject into carrier: {"x-datadog-trace-id":"4975767728554009637","x-datadog-parent-id":"4633592010209712543","x-datadog-sampling-priority":"1"}
@ericmustin
ericmustin / test_concurrent_requests_script.js
Created December 28, 2019 12:23
concurrent requests test script
var http = require('http');
var results = [];
var j=0;
// Make 50 parallel requests:
for (i=0;i<50;i++) {
http.request({
host:'127.0.0.1',
port: 3000,

Demonstrate capturing hapi/BOOM 400 level errors

Setup

  • cd into the root of this directory
  • npm install
  • ensure datadog agent is installed running locally and listening for traces at port 8126, instructions here
  • node hapi_example.js
  • from a seperate terminal window from the root of this directory run a few times
  • node example_http_request.js