当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ts-optchain.oc函数代码示例

本文整理汇总了TypeScript中ts-optchain.oc函数的典型用法代码示例。如果您正苦于以下问题:TypeScript oc函数的具体用法?TypeScript oc怎么用?TypeScript oc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了oc函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: timeseriesTransformer

export function timeseriesTransformer({
  timeseriesResponse,
  bucketSize
}: {
  timeseriesResponse: ESResponse;
  bucketSize: number;
}): ApmTimeSeriesResponse {
  const aggs = timeseriesResponse.aggregations;
  const overallAvgDuration = oc(aggs).overall_avg_duration.value();

  const responseTimeBuckets = oc(aggs)
    .response_times.buckets([])
    .slice(1, -1);
  const { avg, p95, p99 } = getResponseTime(responseTimeBuckets);
  const transactionResultBuckets = oc(aggs).transaction_results.buckets([]);
  const tpmBuckets = getTpmBuckets(transactionResultBuckets, bucketSize);

  return {
    totalHits: timeseriesResponse.hits.total,
    responseTimes: {
      avg,
      p95,
      p99
    },
    tpmBuckets,
    overallAvgDuration
  };
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:28,代码来源:transform.ts

示例2: oc

 buckets: buckets.map(bucket => {
   return {
     ...bucket,
     lower: { value: oc(bucket).lower.value(null) },
     upper: { value: oc(bucket).upper.value(null) },
     anomaly_score: { value: oc(bucket).anomaly_score.value(null) }
   };
 })
开发者ID:gingerwizard,项目名称:kibana,代码行数:8,代码来源:transform.test.ts

示例3: oc

    .map(bucket => {
      const source = bucket.sample.hits.hits[0]._source;
      const message =
        oc(source).error.log.message() || oc(source).error.exception.message();

      return {
        message,
        occurrenceCount: bucket.doc_count,
        culprit: oc(source).error.culprit(),
        groupId: oc(source).error.grouping_key(),
        latestOccurrenceAt: source['@timestamp'],
        handled: oc(source).error.exception.handled()
      };
    });
开发者ID:gingerwizard,项目名称:kibana,代码行数:14,代码来源:get_error_groups.ts

示例4: oc

  const buckets = response.aggregations.distribution.buckets.map(bucket => {
    const sampleSource = oc(bucket).sample.hits.hits[0]._source();
    const isSampled = oc(sampleSource).transaction.sampled(false);
    const sample = {
      traceId: oc(sampleSource).trace.id(),
      transactionId: oc(sampleSource).transaction.id()
    };

    return {
      key: bucket.key,
      count: bucket.doc_count,
      sample: isSampled ? sample : undefined
    };
  });
开发者ID:gingerwizard,项目名称:kibana,代码行数:14,代码来源:transform.ts

示例5: anomalySeriesTransform

export function anomalySeriesTransform(
  response: ESResponse | undefined,
  mlBucketSize: number,
  bucketSize: number,
  timeSeriesDates: number[]
): AnomalyTimeSeriesResponse | undefined {
  if (!response) {
    return;
  }

  const buckets = oc(response)
    .aggregations.ml_avg_response_times.buckets([])
    .map(bucket => {
      return {
        x: bucket.key,
        anomalyScore: bucket.anomaly_score.value,
        lower: bucket.lower.value,
        upper: bucket.upper.value
      };
    });

  const bucketSizeInMillis = Math.max(bucketSize, mlBucketSize) * 1000;

  return {
    anomalyScore: getAnomalyScoreDataPoints(
      buckets,
      timeSeriesDates,
      bucketSizeInMillis
    ),
    anomalyBoundaries: getAnomalyBoundaryDataPoints(buckets, timeSeriesDates)
  };
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:32,代码来源:transform.ts

示例6: transactionGroupsTransformer

export function transactionGroupsTransformer({
  response,
  start,
  end
}: {
  response: ESResponse;
  start: number;
  end: number;
}): ITransactionGroup[] {
  const buckets = oc(response).aggregations.transactions.buckets([]);
  const duration = moment.duration(end - start);
  const minutes = duration.asMinutes();
  const results = buckets.map(bucket => {
    const averageResponseTime = bucket.avg.value;
    const transactionsPerMinute = bucket.doc_count / minutes;
    const impact = bucket.sum.value;
    const sample = bucket.sample.hits.hits[0]._source;

    return {
      name: bucket.key,
      sample,
      p95: bucket.p95.values['95.0'],
      averageResponseTime,
      transactionsPerMinute,
      impact
    };
  });

  return calculateRelativeImpacts(results);
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:30,代码来源:transform.ts

示例7: oc

  return serviceBuckets.map(bucket => {
    const eventTypes = bucket.events.buckets;
    const transactions = eventTypes.find(e => e.key === 'transaction');
    const totalTransactions = oc(transactions).doc_count(0);

    const errors = eventTypes.find(e => e.key === 'error');
    const totalErrors = oc(errors).doc_count(0);

    const deltaAsMinutes = (end - start) / 1000 / 60;
    const transactionsPerMinute = totalTransactions / deltaAsMinutes;
    const errorsPerMinute = totalErrors / deltaAsMinutes;

    return {
      serviceName: bucket.key,
      agentName: oc(bucket).agents.buckets[0].key(),
      transactionsPerMinute,
      errorsPerMinute,
      avgResponseTime: bucket.avg.value
    };
  });
开发者ID:gingerwizard,项目名称:kibana,代码行数:20,代码来源:get_services.ts

示例8: getMlBucketSize

export async function getMlBucketSize({
  serviceName,
  transactionType,
  setup
}: IOptions): Promise<number> {
  const { client, start, end } = setup;
  const params = {
    index: `.ml-anomalies-${serviceName}-${transactionType}-high_mean_response_time`.toLowerCase(),
    body: {
      _source: 'bucket_span',
      size: 1,
      query: {
        bool: {
          must: {
            exists: {
              field: 'bucket_span'
            }
          },
          filter: [
            {
              range: {
                timestamp: {
                  gte: start,
                  lte: end,
                  format: 'epoch_millis'
                }
              }
            }
          ]
        }
      }
    }
  };

  try {
    const resp = await client<ESResponse>('search', params);
    return oc(resp).hits.hits[0]._source.bucket_span(0);
  } catch (err) {
    const isHttpError = 'statusCode' in err;
    if (isHttpError) {
      return 0;
    }
    throw err;
  }
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:45,代码来源:get_ml_bucket_size.ts

示例9: getTransaction

export async function getTransaction(
  transactionId: string,
  traceId: string | undefined,
  setup: Setup
): Promise<TransactionAPIResponse> {
  const { start, end, esFilterQuery, client, config } = setup;

  const filter: ESFilter[] = [
    { term: { [PROCESSOR_EVENT]: 'transaction' } },
    { term: { [TRANSACTION_ID]: transactionId } },
    {
      range: {
        '@timestamp': {
          gte: start,
          lte: end,
          format: 'epoch_millis'
        }
      }
    }
  ];

  if (esFilterQuery) {
    filter.push(esFilterQuery);
  }

  if (traceId) {
    filter.push({ term: { [TRACE_ID]: traceId } });
  }

  const params = {
    index: config.get<string>('apm_oss.transactionIndices'),
    body: {
      size: 1,
      query: {
        bool: {
          filter
        }
      }
    }
  };

  const resp = await client<Transaction>('search', params);
  return oc(resp).hits.hits[0]._source();
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:44,代码来源:index.ts

示例10: getService

export async function getService(
  serviceName: string,
  setup: Setup
): Promise<ServiceAPIResponse> {
  const { start, end, esFilterQuery, client, config } = setup;

  const filter: ESFilter[] = [
    { term: { [SERVICE_NAME]: serviceName } },
    {
      range: {
        '@timestamp': {
          gte: start,
          lte: end,
          format: 'epoch_millis'
        }
      }
    }
  ];

  if (esFilterQuery) {
    filter.push(esFilterQuery);
  }

  const params = {
    index: [
      config.get<string>('apm_oss.errorIndices'),
      config.get<string>('apm_oss.transactionIndices')
    ],
    body: {
      size: 0,
      query: {
        bool: {
          filter
        }
      },
      aggs: {
        types: {
          terms: { field: TRANSACTION_TYPE, size: 100 }
        },
        agents: {
          terms: { field: SERVICE_AGENT_NAME, size: 1 }
        }
      }
    }
  };

  interface Aggs {
    types: {
      buckets: BucketAgg[];
    };
    agents: {
      buckets: BucketAgg[];
    };
  }

  const { aggregations } = await client<void, Aggs>('search', params);
  return {
    serviceName,
    types: oc(aggregations)
      .types.buckets([])
      .map(bucket => bucket.key),
    agentName: oc(aggregations).agents.buckets[0].key()
  };
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:64,代码来源:get_service.ts


注:本文中的ts-optchain.oc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。