<commit_before>import config from "config"
import { verbose as debug, error } from "./loggers"
import tracer from "dd-trace"
import { Tags } from "opentracing"

const { DD_TRACER_SERVICE_NAME, DD_TRACER_HOSTNAME, PRODUCTION_ENV } = config

export function init() {
  tracer.init({
    service: DD_TRACER_SERVICE_NAME,
    hostname: DD_TRACER_HOSTNAME,
    plugins: false,
    logger: { debug, error },
    debug: !PRODUCTION_ENV,
  })
  tracer.use("express", {
    service: `${DD_TRACER_SERVICE_NAME}.request`,
  })
  tracer.use("http", {
    service: `${DD_TRACER_SERVICE_NAME}.http-client`,
  })
  tracer.use("graphql", {
    service: `${DD_TRACER_SERVICE_NAME}.graphql`,
    filterVariables: variables => variables,
  } as any)
}

const createCommand = (command: string) => <T>(
  promise: Promise<T>
): Promise<T> => {
  const parentScope = tracer.scopeManager().active()
  const span = tracer.startSpan("memcached", {
    childOf: parentScope && parentScope.span(),
    tags: {
      [Tags.SPAN_KIND]: Tags.SPAN_KIND_RPC_CLIENT,
      [Tags.DB_TYPE]: "memcached",
      "service.name": `${DD_TRACER_SERVICE_NAME}.memcached`,
      "resource.name": command,
      "span.type": "memcached",
    },
  })

  return promise.then(
    result => {
      span.finish()
      return result<commit_msg>[tracer] Document that we capture all GraphQL variables atm.<commit_after>import config from "config"
import { verbose as debug, error } from "./loggers"
import tracer from "dd-trace"
import { Tags } from "opentracing"

const { DD_TRACER_SERVICE_NAME, DD_TRACER_HOSTNAME, PRODUCTION_ENV } = config

export function init() {
  tracer.init({
    service: DD_TRACER_SERVICE_NAME,
    hostname: DD_TRACER_HOSTNAME,
    plugins: false,
    logger: { debug, error },
    debug: !PRODUCTION_ENV,
  })
  tracer.use("express", {
    service: `${DD_TRACER_SERVICE_NAME}.request`,
  })
  tracer.use("http", {
    service: `${DD_TRACER_SERVICE_NAME}.http-client`,
  })
  tracer.use("graphql", {
    service: `${DD_TRACER_SERVICE_NAME}.graphql`,
    /**
     * NOTE: This means we capture _all_ variables. When/if needed, we can
     *       use this callback to redact sensitive variables.
     */
    filterVariables: variables => variables,
  } as any)
}

const createCommand = (command: string) => <T>(
  promise: Promise<T>
): Promise<T> => {
  const parentScope = tracer.scopeManager().active()
  const span = tracer.startSpan("memcached", {
    childOf: parentScope && parentScope.span(),
    tags: {
      [Tags.SPAN_KIND]: Tags.SPAN_KIND_RPC_CLIENT,
      [Tags.DB_TYPE]: "memcached",
      "service.name": `${DD_TRACER_SERVICE_NAME}.memcached`,
      "resource.name": command,
      "span.type": "memcached",
    },
  })

  return promise.then(
    result => {
      span.finish()
      return result
{'fraction_non_alphanumeric': 0.14137437365783823, 'fraction_numerical': 0.0, 'mean_word_length': 3.6895973154362416, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4580232', 'n_tokens_mistral': 953, 'n_tokens_neox': 956, 'n_words': 199}