How to use the opentracing.FORMAT_BINARY function in opentracing

To help you get started, we’ve selected a few opentracing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jaegertracing / jaeger-client-node / src / tracer.js View on Github external
urlEncoding: false,
      metrics: this._metrics,
    };

    let textCodec = new TextMapCodec(codecOptions);
    this.registerInjector(opentracing.FORMAT_TEXT_MAP, textCodec);
    this.registerExtractor(opentracing.FORMAT_TEXT_MAP, textCodec);

    codecOptions.urlEncoding = true;

    let httpCodec = new TextMapCodec(codecOptions);
    this.registerInjector(opentracing.FORMAT_HTTP_HEADERS, httpCodec);
    this.registerExtractor(opentracing.FORMAT_HTTP_HEADERS, httpCodec);

    let binaryCodec = new BinaryCodec();
    this.registerInjector(opentracing.FORMAT_BINARY, binaryCodec);
    this.registerExtractor(opentracing.FORMAT_BINARY, binaryCodec);

    const uuid = uuidv4();
    this._tags[constants.TRACER_CLIENT_ID_TAG_KEY] = uuid;
    this._process = {
      serviceName: serviceName,
      tags: Utils.convertObjectToTags(this._tags),
      uuid: uuid,
    };
    this._debugThrottler.setProcess(this._process);
    // TODO update reporter to implement ProcessSetter
    this._reporter.setProcess(this._process.serviceName, this._process.tags);

    this._traceId128bit = options.traceId128bit;
    this._shareRpcSpan = options.shareRpcSpan;
  }
github getsentry / sentry-javascript / packages / opentracing / src / tracer.ts View on Github external
switch (format) {
      case opentracing.FORMAT_TEXT_MAP:
      case opentracing.FORMAT_HTTP_HEADERS:
        const headerName = 'traceparent';
        const headerValue: string = `00-${context.traceId}-${context.spanId}-00`;

        if (typeof carrier.setRequestHeader === 'function') {
          carrier.setRequestHeader(headerName, headerValue);
        } else if (carrier.headers && typeof carrier.headers.append === 'function') {
          carrier.headers.append(headerName, headerValue);
        } else {
          carrier[headerName] = headerValue;
        }

        break;
      case opentracing.FORMAT_BINARY:
        break;
      default:
      // We do nothing
    }
    // tslint:enable: no-unsafe-any
  }
github open-telemetry / opentelemetry-js / packages / opentelemetry-shim-opentracing / src / shim.ts View on Github external
_inject(
    spanContext: opentracing.SpanContext,
    format: string,
    carrier: unknown
  ): void {
    const opentelemSpanContext: types.SpanContext = (spanContext as SpanContextShim).getSpanContext();
    switch (format) {
      // tslint:disable-next-line:no-switch-case-fall-through
      case opentracing.FORMAT_HTTP_HEADERS:
      case opentracing.FORMAT_TEXT_MAP:
        this._tracer
          .getHttpTextFormat()
          .inject(opentelemSpanContext, format, carrier);
        return;
      case opentracing.FORMAT_BINARY:
        this._logger.warn(
          'OpentracingShim.inject() does not support FORMAT_BINARY'
        );
        // @todo: Implement binary format
        return;
      default:
    }
  }
github jaegertracing / jaeger-client-node / src / tracer.js View on Github external
metrics: this._metrics,
    };

    let textCodec = new TextMapCodec(codecOptions);
    this.registerInjector(opentracing.FORMAT_TEXT_MAP, textCodec);
    this.registerExtractor(opentracing.FORMAT_TEXT_MAP, textCodec);

    codecOptions.urlEncoding = true;

    let httpCodec = new TextMapCodec(codecOptions);
    this.registerInjector(opentracing.FORMAT_HTTP_HEADERS, httpCodec);
    this.registerExtractor(opentracing.FORMAT_HTTP_HEADERS, httpCodec);

    let binaryCodec = new BinaryCodec();
    this.registerInjector(opentracing.FORMAT_BINARY, binaryCodec);
    this.registerExtractor(opentracing.FORMAT_BINARY, binaryCodec);

    const uuid = uuidv4();
    this._tags[constants.TRACER_CLIENT_ID_TAG_KEY] = uuid;
    this._process = {
      serviceName: serviceName,
      tags: Utils.convertObjectToTags(this._tags),
      uuid: uuid,
    };
    this._debugThrottler.setProcess(this._process);
    // TODO update reporter to implement ProcessSetter
    this._reporter.setProcess(this._process.serviceName, this._process.tags);

    this._traceId128bit = options.traceId128bit;
    this._shareRpcSpan = options.shareRpcSpan;
  }
github rochdev / datadog-tracer-js / test / tracer.spec.js View on Github external
it('should support extract of binary format', () => {
    BinaryPropagator.returns(propagator)
    propagator.extract.withArgs(carrier).returns('spanContext')

    tracer = new Tracer({ service: 'service' })
    const spanContext = tracer.extract(opentracing.FORMAT_BINARY, carrier)

    expect(spanContext).to.equal('spanContext')
  })
})
github rochdev / datadog-tracer-js / test / tracer.spec.js View on Github external
it('should support inject of binary format', () => {
    BinaryPropagator.returns(propagator)

    tracer = new Tracer({ service: 'service' })
    tracer.inject(spanContext, opentracing.FORMAT_BINARY, carrier)

    expect(propagator.inject).to.have.been.calledWith(spanContext, carrier)
  })
github elastic / apm-agent-js-core / test / opentracing / api_compatibility.js View on Github external
expect(function () {
              tracer.extract(ot.FORMAT_BINARY, binCarrier)
            }).not.toThrow(Error)
            expect(function () {
github elastic / apm-agent-js-core / test / opentracing / api_compatibility.js View on Github external
expect(function () {
              tracer.inject(spanContext, ot.FORMAT_BINARY, binCarrier)
            }).not.toThrow(Error)
            expect(function () {
github rochdev / datadog-tracer-js / src / tracer.js View on Github external
constructor (config) {
    super()
    EventEmitter.call(this)

    const service = config.service
    const endpoint = config.endpoint
    const hostname = config.hostname || 'localhost'
    const port = config.port || 8126
    const protocol = config.protocol || 'http'

    this._service = service
    this._endpoint = new Endpoint(endpoint || `${protocol}://${hostname}:${port}`)
    this._propagators = {
      [opentracing.FORMAT_TEXT_MAP]: new TextMapPropagator(),
      [opentracing.FORMAT_HTTP_HEADERS]: new TextMapPropagator(),
      [opentracing.FORMAT_BINARY]: new BinaryPropagator()
    }
  }