New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

datadog-tracer

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datadog-tracer - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

example/index.js

16

example/README.md
# Datadog Tracer Example
To run the example, first you need a local Datadog agent. The easiest way to get one is using the official Docker image:
**Note: Don't forget to replace <Your API Key> with your actual API key from Datadog.**
```sh
docker run -d --name dd-agent -v /var/run/docker.sock:/var/run/docker.sock:ro -v /proc/:/host/proc/:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e API_KEY=<Your API Key> -e SD_BACKEND=docker -e DD_APM_ENABLED=true -p 8126:8126 datadog/docker-dd-agent:latest
```
Once the container is running, you can run the example server:
```sh
node ./example
```
This will start the server on port `31337`. You can then make requests on the server to generate traces:
```sh
curl http://localhost:31337/hello/world
```

3

package.json
{
"name": "datadog-tracer",
"version": "0.2.2",
"version": "0.3.0",
"description": "OpenTracing Tracer implementation for Datadog in JavaScript",

@@ -29,2 +29,3 @@ "main": "src/index.js",

"dependencies": {
"@protobufjs/eventemitter": "^1.1.0",
"json-bignum": "^0.0.3",

@@ -31,0 +32,0 @@ "long": "^3.2.0",

@@ -7,2 +7,3 @@ # Datadog Tracer

[![Code Climate](https://codeclimate.com/github/rochdev/datadog-tracer-js/badges/gpa.svg)](https://codeclimate.com/github/rochdev/datadog-tracer-js)
[![Greenkeeper badge](https://badges.greenkeeper.io/rochdev/datadog-tracer-js.svg)](https://greenkeeper.io/)
[![bitHound Dependencies](https://www.bithound.io/github/rochdev/datadog-tracer-js/badges/dependencies.svg)](https://www.bithound.io/github/rochdev/datadog-tracer-js/master/dependencies/npm)

@@ -9,0 +10,0 @@

@@ -15,5 +15,7 @@ 'use strict'

const state = TracerState.create(spanContext)
const message = TracerState.create(spanContext)
carrier.buffer = TracerState.encode(state).finish()
copy(message.baggageItems, spanContext.baggageItems, JSON.stringify)
carrier.buffer = TracerState.encode(message).finish()
}

@@ -27,2 +29,5 @@

state = TracerState.toObject(message)
copy(state.baggageItems, state.baggageItems, JSON.parse)
return new SpanContext(state)

@@ -35,2 +40,8 @@ } catch (e) {

function copy (dest, src, customizer) {
Object.keys(src).forEach(key => {
dest[key] = customizer(src[key])
})
}
module.exports = BinaryPropagator

@@ -15,3 +15,3 @@ 'use strict'

spanContext.baggageItems && Object.keys(spanContext.baggageItems).forEach(key => {
carrier[`dd-baggage-${key}`] = spanContext.baggageItems[key]
carrier[`dd-baggage-${key}`] = JSON.stringify(spanContext.baggageItems[key])
})

@@ -23,15 +23,15 @@ }

Object.keys(carrier).forEach(key => {
const match = key.match(/^dd-baggage-(.+)$/)
try {
Object.keys(carrier).forEach(key => {
const match = key.match(/^dd-baggage-(.+)$/)
if (match) {
baggageItems[match[1]] = carrier[key]
}
})
if (match) {
baggageItems[match[1]] = JSON.parse(carrier[key])
}
})
try {
return new DatadogSpanContext({
traceId: Long.fromString(carrier['dd-tracer-traceid'], true),
spanId: Long.fromString(carrier['dd-tracer-spanid'], true),
sampled: carrier['dd-tracer-sampled'] === 'true',
sampled: JSON.parse(carrier['dd-tracer-sampled']),
baggageItems

@@ -38,0 +38,0 @@ })

@@ -72,3 +72,3 @@ 'use strict'

Object.keys(keyValuePairs).forEach(key => {
this._tags[key] = keyValuePairs[key]
this._tags[key] = String(keyValuePairs[key])
})

@@ -75,0 +75,0 @@ }

@@ -8,3 +8,2 @@ 'use strict'

const TextMapPropagator = require('./propagation/text_map')
const HttpHeadersPropagator = require('./propagation/http_headers')
const BinaryPropagator = require('./propagation/binary')

@@ -51,4 +50,2 @@

case opentracing.FORMAT_HTTP_HEADERS:
propagator = new HttpHeadersPropagator()
break
case opentracing.FORMAT_TEXT_MAP:

@@ -55,0 +52,0 @@ propagator = new TextMapPropagator()

@@ -33,3 +33,7 @@ 'use strict'

expect(state).to.deep.equal(spanContext)
expect(state).to.deep.equal(Object.assign({}, spanContext, {
baggageItems: {
foo: '"bar"'
}
}))
})

@@ -46,3 +50,7 @@

}
const state = TracerState.create(spanContext)
const state = TracerState.create(Object.assign({}, spanContext, {
baggageItems: {
foo: '"bar"'
}
}))
const carrier = {

@@ -49,0 +57,0 @@ buffer: TracerState.encode(state).finish()

@@ -30,3 +30,3 @@ 'use strict'

'dd-tracer-sampled': 'true',
'dd-baggage-foo': 'bar'
'dd-baggage-foo': '"bar"'
})

@@ -40,3 +40,3 @@ })

'dd-tracer-sampled': 'true',
'dd-baggage-foo': 'bar'
'dd-baggage-foo': '"bar"'
}

@@ -43,0 +43,0 @@

@@ -66,2 +66,9 @@ 'use strict'

it('should ensure tags are strings', () => {
span = new Span(tracer, { operationName: 'operation' })
span.addTags({ foo: 123 })
expect(span._tags).to.have.property('foo', '123')
})
it('should record on finish', () => {

@@ -68,0 +75,0 @@ recorder.record.returns(Promise.resolve())

@@ -16,3 +16,2 @@ 'use strict'

let TextMapPropagator
let HttpHeadersPropagator
let BinaryPropagator

@@ -31,3 +30,2 @@ let propagator

TextMapPropagator = sinon.stub()
HttpHeadersPropagator = sinon.stub()
BinaryPropagator = sinon.stub()

@@ -42,3 +40,2 @@ propagator = {

'./propagation/text_map': TextMapPropagator,
'./propagation/http_headers': HttpHeadersPropagator,
'./propagation/binary': BinaryPropagator

@@ -166,3 +163,3 @@ })

it('should support inject of http headers format', () => {
HttpHeadersPropagator.returns(propagator)
TextMapPropagator.returns(propagator)

@@ -192,3 +189,3 @@ tracer.inject(spanContext, opentracing.FORMAT_HTTP_HEADERS, carrier)

it('should support extract of http headers format', () => {
HttpHeadersPropagator.returns(propagator)
TextMapPropagator.returns(propagator)
propagator.extract.withArgs(carrier).returns('spanContext')

@@ -195,0 +192,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc