> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-parallel-read-in-order-multi-part.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 用于 ClickStack 的 Deno SDK - ClickHouse 可观测性栈

# Deno

export const ClickStackIntegrates = ({signals = []}) => {
  const list = Array.isArray(signals) ? signals : String(signals).split(",");
  const supported = list.map(s => String(s).trim().toLowerCase());
  const pillStyle = {
    display: "inline-flex",
    alignItems: "center",
    padding: "0.125rem 0.625rem",
    borderRadius: "9999px",
    fontSize: "0.8125rem",
    fontWeight: 500,
    lineHeight: 1.6,
    color: "#161517",
    backgroundColor: "#faff69",
    border: "1px solid rgba(0, 0, 0, .1)",
    marginRight: "0.5rem"
  };
  return <div style={{
    margin: "0 0 1.25rem"
  }}>
      <span style={{
    marginRight: "0.5rem"
  }}>本指南集成了：</span>
      {supported.includes("logs") && <span style={pillStyle}>日志</span>}
      {supported.includes("metrics") && <span style={pillStyle}>指标</span>}
      {supported.includes("traces") && <span style={pillStyle}>链路追踪</span>}
    </div>;
};

<ClickStackIntegrates signals={['logs']} />

<Note>
  当前仅支持 OpenTelemetry 日志。如需链路追踪支持，[请参阅以下指南](https://dev.to/grunet/leveraging-opentelemetry-in-deno-45bj#a-minimal-interesting-example)。
</Note>

<h2 id="logging">
  日志
</h2>

可通过为 `std/log` 模块导出自定义日志记录器来启用日志功能。

**示例用法：**

```typescript theme={null}
import * as log from 'https://deno.land/std@0.203.0/log/mod.ts';
import { OpenTelemetryHandler } from 'npm:@hyperdx/deno';

log.setup({
  handlers: {
    otel: new OpenTelemetryHandler('DEBUG'),
  },

  loggers: {
    'my-otel-logger': {
      level: 'DEBUG',
      handlers: ['otel'],
    },
  },
});

log.getLogger('my-otel-logger').info('Hello from Deno!');
```

<h3 id="run-the-application">
  运行应用程序
</h3>

<Tabs>
  <Tab title="托管 ClickStack">
    ```shell theme={null}
    OTEL_EXPORTER_OTLP_ENDPOINT=<YOUR_OTEL_COLLECTOR_HTTP_ENDPOINT> \
    OTEL_SERVICE_NAME="<YOUR_SERVICE_NAME>" \
    deno run --allow-net --allow-env --allow-read --allow-sys --allow-run app.ts
    ```
  </Tab>

  <Tab title="ClickStack 开源版">
    ```shell theme={null}
    OTEL_EXPORTER_OTLP_HEADERS="authorization=<YOUR_INGESTION_API_KEY>" \
    OTEL_EXPORTER_OTLP_ENDPOINT=<YOUR_OTEL_COLLECTOR_HTTP_ENDPOINT> \
    OTEL_SERVICE_NAME="<YOUR_SERVICE_NAME>" \
    deno run --allow-net --allow-env --allow-read --allow-sys --allow-run app.ts
    ```
  </Tab>
</Tabs>
