How to use the @opentelemetry/core.AlwaysOnSampler function in @opentelemetry/core

To help you get started, we’ve selected a few @opentelemetry/core 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 GoogleCloudPlatform / esp-v2 / tests / endpoints / bookstore / http_bookstore.js View on Github external

'use strict';

const opentelemetry = require('@opentelemetry/api');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { BatchSpanProcessor } = require('@opentelemetry/tracing');
const { TraceExporter } = require('@google-cloud/opentelemetry-cloud-trace-exporter');
const { AlwaysOnSampler, AlwaysOffSampler, ParentOrElseSampler } = require("@opentelemetry/core");
const { HttpTraceContext } = require("@opentelemetry/core");

// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings
const provider = new NodeTracerProvider({
  // TODO(nareddyt): Only sample when the incoming request creates a new span.
  // Otherwise don't make new spans, but propagate the context.
  // sampler: new ParentOrElseSampler(new AlwaysOffSampler()),
  sampler: new AlwaysOnSampler(),
  plugins: {
    express: {
      enabled: true,
      path: '@opentelemetry/plugin-express',
      ignoreLayersType: [
          "middleware",
          "request_handler",
      ],
    },
    http: {
      enabled: true,
      path: '@opentelemetry/plugin-http',
    }
  }
});
const exporter = new TraceExporter();