onValue()

in lib/apm-client/http-apm-client/truncate.js [52:138]


    onValue(value, key, path) {
      if (typeof value !== 'string') {
        return value;
      }

      let max = opts.truncateStringsAt;
      switch (path[0]) {
        case 'service':
          switch (path[1]) {
            case 'name':
            case 'version':
            case 'environment':
              max = opts.truncateKeywordsAt;
              break;

            case 'agent':
            case 'framework':
            case 'language':
            case 'runtime':
              switch (path[2]) {
                case 'name':
                case 'version':
                  max = opts.truncateKeywordsAt;
                  break;
              }
              break;
          }
          break;

        case 'process':
          if (path[1] === 'title') {
            max = opts.truncateKeywordsAt;
          }
          break;

        case 'system':
          switch (path[1]) {
            case 'architecture':
            case 'hostname':
            case 'platform':
              max = opts.truncateKeywordsAt;
              break;
          }
          break;
        case 'cloud':
          switch (path[1]) {
            case 'availability_zone':
            case 'provider':
            case 'region':
              max = opts.truncateKeywordsAt;
              break;
            case 'account':
              switch (path[2]) {
                case 'id':
                case 'name':
                  max = opts.truncateKeywordsAt;
                  break;
              }
              break;
            case 'instance':
              switch (path[2]) {
                case 'id':
                case 'name':
                  max = opts.truncateKeywordsAt;
                  break;
              }
              break;
            case 'machine':
              switch (path[2]) {
                case 'type':
                  max = opts.truncateKeywordsAt;
                  break;
              }
              break;
            case 'project':
              switch (path[2]) {
                case 'id':
                case 'name':
                  max = opts.truncateKeywordsAt;
                  break;
              }
          }
          break;
      }

      return unitrunc(value, max);
    },