How to use the opentracing.Tags.HTTP_URL 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 RisingStack / opentracing-metrics-tracer / src / reporters / PrometheusReporter.e2e.spec.js View on Github external
it('should have http_request_handler metrics', () => {
      const reporter = new PrometheusReporter({
        ignoreTags: {
          [Tags.HTTP_URL]: /bar/
        }
      })
      const tracer = new Tracer('my-service', [reporter])

      const span1 = tracer.startSpan('http_request')
      span1.setTag(Tags.HTTP_URL, 'http://127.0.0.1/foo')
      span1.setTag(Tags.HTTP_METHOD, 'GET')
      span1.setTag(Tags.HTTP_STATUS_CODE, 200)
      span1.setTag(Tags.SPAN_KIND, Tags.SPAN_KIND_RPC_SERVER)
      clock.tick(100)
      span1.finish()

      // will be ignored
      const span2 = tracer.startSpan('http_request')
      span2.setTag(Tags.HTTP_URL, 'http://127.0.0.1/bar')
      span2.setTag(Tags.HTTP_METHOD, 'GET')
github RisingStack / opentracing-metrics-tracer / src / reporters / PrometheusReporter.spec.js View on Github external
it('should skip operation metrics by tag value', function () {
      // init
      const prometheusReporter = new PrometheusReporter({
        ignoreTags: {
          [Tags.HTTP_URL]: /foo/
        }
      })
      const metricsOperationDurationSeconds = prometheusReporter._metricsOperationDurationSeconds()

      const metricsStub = {
        observe: this.sandbox.spy()
      }

      this.sandbox.stub(metricsOperationDurationSeconds, 'labels').callsFake(() => metricsStub)

      // generate data
      const tracer = new Tracer('service')

      const span = tracer.startSpan('my-operation')
      span.setTag(Tags.HTTP_URL, 'http://127.0.0.1/foo')
      clock.tick(100)
github RisingStack / opentracing-metrics-tracer / example / server.js View on Github external
const server = http.createServer((req, res) => {
  // Instrumentation
  const requestSpan = metricsTracer.startSpan('http_request', {
    childOf: metricsTracer.extract(FORMAT_HTTP_HEADERS, req.headers)
  })
  const headers = {}

  metricsTracer.inject(requestSpan, FORMAT_HTTP_HEADERS, headers)

  requestSpan.setTag(Tags.HTTP_URL, req.url)
  requestSpan.setTag(Tags.HTTP_METHOD, req.method || 'GET')
  requestSpan.setTag(Tags.HTTP_STATUS_CODE, 200)
  requestSpan.setTag(Tags.SPAN_KIND_RPC_CLIENT, true)

  // Dummy router: GET /metrics
  if (req.url === '/metrics') {
    requestSpan.finish()

    res.writeHead(200, {
      'Content-Type': MetricsTracer.PrometheusReporter.Prometheus.register.contentType
    })
    res.end(prometheusReporter.metrics())
    return
  }

  // My child operation like DB access
github zalando / tailor / tests / tailor.js View on Github external
.then(() => {
                    const { tags } = traceResults();
                    assert.deepEqual(tags[1], {
                        'span.kind': 'client',
                        [Tags.HTTP_URL]: 'https://fragment/1',
                        id: 'test',
                        fallback: false,
                        primary: false,
                        async: false,
                        public: false,
                        timeout: 200
                    });
                })
                .then(done, done);
github zalando / tailor / lib / fragment.js View on Github external
: this.attributes.url;

        const spanOptions = parentSpan ? { childOf: parentSpan } : {};
        const span = tracer.startSpan('fetch_fragment', spanOptions);

        const {
            id,
            primary,
            async: isAsync,
            public: isPublic,
            timeout
        } = this.attributes;

        span.addTags({
            [Tags.SPAN_KIND]: Tags.SPAN_KIND_RPC_CLIENT,
            [Tags.HTTP_URL]: url,
            fallback: isFallback,
            public: isPublic,
            async: isAsync,
            id: id || 'unnamed',
            primary,
            timeout
        });

        this.requestFragment(url, this.attributes, request, span).then(
            res => this.onResponse(res, isFallback, span),
            err => {
                if (!isFallback) {
                    if (this.attributes.fallbackUrl) {
                        this.emit('fallback', err);
                        this.fetch(request, true, span);
                    } else {
github RisingStack / opentracing-auto / src / instrumentation / restify.spec.js View on Github external
tracer.inject(parentSpan, headers)

      const server = restify.createServer()
      server.get('/', (req, res) => res.send('ok'))

      await request(server)
        .get('/')
        .headers(headers)
        .expect(200)
        .end()

      expect(cls.startRootSpan).to.be.calledWith(tracer, instrumentation.OPERATION_NAME, {
        childOf: parentSpan.context(),
        tags: {
          [Tags.SPAN_KIND]: Tags.SPAN_KIND_RPC_SERVER,
          [Tags.HTTP_URL]: '/',
          [Tags.HTTP_METHOD]: 'GET'
        }
      })
    })
github fapspirit / axios-opentracing / src / index.ts View on Github external
return function axiosOpentracingRequestInterceptor(config: IAxiosRequestConfig) {
     const modifiedConfig = config as IAxiosOpentracingRequestConfig;

     try {
       const span = Tracer.startSpan(`${config.method}: ${config.baseURL}${config.url}`, {
         childOf: rootSpan
       });

       span.setTag(Tags.HTTP_METHOD, config.method);
       span.setTag(Tags.HTTP_URL, config.url);
       span.setTag(Tags.SPAN_KIND, Tags.SPAN_KIND_RPC_CLIENT);
       Tracer.inject(span, FORMAT_HTTP_HEADERS, config.headers);

       modifiedConfig.span = span;
     } catch (e) {}

     return modifiedConfig;
   };
 }
github apigee / microgateway-core / lib / trace-helper.js View on Github external
initTracer: function(name, req, correlation_id) {
        if (process.env.EDGEMICRO_OPENTRACE) {
            try {
                if ( (initTracerMod !== undefined) && initTracerMod ) {
                    proxyTrace = initTracerMod(name);
                    //check if there is a parent id
                    if (checkUberParentId(req.headers)) {
                        debug("opentracing parentid found");
                        requestspan = proxyTrace.extract(FORMAT_HTTP_HEADERS, req.headers);
                    } else {
                        debug("opentracing parentid not found");
                        requestspan = proxyTrace.startSpan("request_start");
                    }
                    requestspan.setTag(Tags.HTTP_URL, req.url);
                    requestspan.setTag(Tags.HTTP_METHOD, req.method);
                    requestspan.setBaggageItem('correlation_id', correlation_id);
                    var traceheaders = {};
                    proxyTrace.inject(requestspan, FORMAT_HTTP_HEADERS, traceheaders);
                    for (var tracekey in traceheaders) {
                        if (!traceheaders.hasOwnProperty(tracekey)) {
                            continue;
                        } else {
                            req.headers[tracekey] = traceheaders[tracekey];
                        }
                    }
                    }
            } catch (err) {}
        }
        return req;
    },
github RisingStack / opentracing-auto / src / instrumentation / express.js View on Github external
const spans = parentSpanContexts.map((parentSpanContext, key) =>
        cls.startRootSpan(tracers[key], OPERATION_NAME, {
          childOf: parentSpanContext,
          tags: {
            [Tags.SPAN_KIND]: Tags.SPAN_KIND_RPC_SERVER,
            [Tags.HTTP_URL]: url,
            [Tags.HTTP_METHOD]: req.method
          }
        }))
      debug(`Operation started ${OPERATION_NAME}`, {
github RisingStack / opentracing-auto / src / instrumentation / httpClient.js View on Github external
const spans = tracers.map((tracer) => cls.startChildSpan(tracer, OPERATION_NAME, {
        tags: {
          [Tags.SPAN_KIND]: Tags.SPAN_KIND_RPC_CLIENT,
          [Tags.HTTP_URL]: uri,
          [Tags.HTTP_METHOD]: method
        }
      }))