logologo
시작
가이드
개발
플러그인
API
홈
English
简体中文
日本語
한국어
Español
Português
Deutsch
Français
Русский
Italiano
Türkçe
Українська
Tiếng Việt
Bahasa Indonesia
ไทย
Polski
Nederlands
Čeština
العربية
עברית
हिन्दी
Svenska
시작
가이드
개발
플러그인
API
홈
logologo

빠른 시작

플러그인 개발 개요
첫 플러그인 작성
프로젝트 디렉토리 구조

서버사이드 개발

개요
Plugin 플러그인
Collections 데이터 테이블
Database 데이터베이스 작업
DataSourceManager 데이터 소스 관리
ResourceManager 리소스 관리
ACL 권한 제어
Middleware 미들웨어
Cache 캐시
Event 이벤트
Context 요청 컨텍스트
Migration 업그레이드 스크립트
Logger 로그
I18n 국제화
Command 커맨드 라인
CronJobManager 예약 작업 관리
Test 테스트

클라이언트사이드 개발

개요
Plugin 플러그인
Context 컨텍스트
Router 라우터
ACL 권한 제어
DataSourceManager 데이터 소스 관리
Resource 리소스
Request 요청
Styles & Themes 스타일 & 테마
Logger 로그
I18n 국제화
Test 테스트

기타

플러그인 업그레이드 가이드
언어 목록
의존성 관리
빌드
Next Page플러그인 개발 개요
AI 번역 알림

이 문서는 AI에 의해 번역되었습니다. 정확한 정보는 영어 버전을 참조하세요.

#텔레메트리 (Telemetry)

실험적 기능

NocoBase의 텔레메트리(Telemetry) 모듈은 OpenTelemetry를 기반으로 캡슐화되었습니다. 이 문서는 텔레메트리 모듈을 사용하여 트레이스(Trace) 및 메트릭(Metric) 데이터를 수집하고 NocoBase 시스템의 관측 가능성(Observability)을 향상시키는 방법을 소개합니다.

#계측 (Instrumentation)

#메트릭 (Metrics)

const meter = app.telemetry.metric.getMeter();
const counter = meter.createCounter('event_counter', {});
counter.add(1);

참고:

  • https://opentelemetry.io/docs/instrumentation/js/manual/#acquiring-a-meter

#트레이스 (Traces)

const tracer = app.telemetry.trace.getTracer();
tracer.startActiveSpan();
tracer.startSpan();

참고:

  • https://opentelemetry.io/docs/instrumentation/js/manual/#acquiring-a-tracer

#라이브러리

import { Plugin } from '@nocobase/server';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';

class InstrumentationPlugin extends Plugin {
  afterAdd() {
    this.app.on('beforeLoad', (app) => {
      app.telemetry.addInstrumentation(getNodeAutoInstrumentations());
    });
  }
}
주의

NocoBase에서 텔레메트리 모듈의 초기화 위치는 app.beforeLoad입니다. 따라서 모든 계측 라이브러리가 NocoBase에 적합한 것은 아닙니다.
예를 들어: instrumentation-koa는 Koa가 인스턴스화되기 전에 도입되어야 합니다. NocoBase의 Application은 Koa를 기반으로 하지만, 텔레메트리 모듈은 Application이 인스턴스화된 후에 초기화되므로 적용할 수 없습니다.

참고:

  • https://opentelemetry.io/docs/instrumentation/js/libraries/

#수집 (Collection)

#메트릭 (Metrics)

import { Plugin } from '@nocobase/server';
import {
  PeriodicExportingMetricReader,
  ConsoleMetricExporter,
} from '@opentelemetry/sdk-metrics';

class MetricReaderPlugin extends Plugin {
  afterAdd() {
    this.app.on('beforeLoad', (app) => {
      app.telemetry.metric.registerReader(
        'console',
        () =>
          new PeriodicExportingMetricReader({
            exporter: new ConsoleMetricExporter(),
          }),
      );
    });
  }
}

#트레이스 (Traces)

import { Plugin } from '@nocobase/server';
import {
  BatchSpanProcessor,
  ConsoleSpanExporter,
} from '@opentelemetry/sdk-trace-base';

class TraceSpanProcessorPlugin extends Plugin {
  afterAdd() {
    this.app.on('beforeLoad', (app) => {
      app.telemetry.trace.registerProcessor(
        'console',
        () => new BatchSpanProcessor(new ConsoleSpanExporter()),
      );
    });
  }
}

참고:

  • https://opentelemetry.io/docs/instrumentation/js/exporters