Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.
/ trace-context.js Public archive

JavaScript Parser / serializer for the formats defined in the W3C TraceContext specification

License

Notifications You must be signed in to change notification settings

instana/trace-context.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trace-context.js   Build Status

JavaScript Parser / serializer for the formats defined in the W3C TraceContext specification.


Installation

npm install --save trace-context

Usage

> const {TraceParent, http} = require('trace-context');
undefined
> TraceParent.random()
TraceParent {
  version: 0,
  traceId: '9d317f18d024465ab0f9697db8e1edcc',
  spanId: '0423d687565b49c4',
  options: 1 }
> TraceParent.random().isTracedFlagSet()
true
> http.parseTraceParent('00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01')
TraceParent {
  version: 0,
  traceId: '4bf92f3577b34da6a3ce929d0e0e4736',
  spanId: '00f067aa0ba902b7',
  options: 1 }
> const state = http.parseTraceState('congo=congosSecondPosition,rojo=rojosFirstPosition');
undefined
> state.get('congo')
'congosSecondPosition'
> state.set('in', http.serializeTraceParent(TraceParent.random()))
undefined
> http.serializeTraceState(state)
'in=00-2b6ad3c51c374a30a13c4af942d6a341-a5387d0485974ec9-01,congo=congosSecondPosition,rojo=rojosFirstPosition'

About

JavaScript Parser / serializer for the formats defined in the W3C TraceContext specification

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published