MongoDB 클라이언트 연산 시맨틱 컨벤션
Status: Development
출처: 문서
본문
-
스팬(Spans)
-
예시(Example)
-
메트릭(Metrics)
MongoDB 시맨틱 컨벤션은 데이터베이스 시맨틱 컨벤션(Database Semantic Conventions)을 확장하고 덮어써요(override).
스팬(Spans)
Status:
MongoDB 호출을 나타내는 스팬은 일반 데이터베이스 클라이언트 스팬 시맨틱 컨벤션(General Semantic Conventions for Database Client Spans)을 따르지요.
db.system.name은 반드시 "mongodb"로 설정해야 하고(MUST), 스팬 생성 시점에 제공해야 해요(SHOULD).
스팬 이름은 일반 데이터베이스 스팬 이름 규칙을 따라야 해요(SHOULD).
스팬 kind는 CLIENT여야 해요(SHOULD).
스팬 상태는 Recording Errors 문서를 따라야 해요(SHOULD).
속성(Attributes):
| | Key | Stability | Requirement Level | Value Type | Description | Example Values
| db.collection.name | | Required | string | The MongoDB collection being accessed within the database stated in db.namespace. [1] | public.users; customers
| db.operation.name | | Required | string | The name of the MongoDB command being executed. | findAndModify; getMore; insertMany; bulkWrite
| db.namespace | | Conditionally Required If available. | string | The MongoDB database name. | customers; test.users
| db.response.status_code | | Conditionally Required [2] | string | MongoDB error code represented as a string. [3] | 36; 11602
| error.type | | Conditionally Required If and only if the operation failed. | string | Describes a class of error the operation ended with. [4] | timeout; java.net.UnknownHostException; server_certificate_invalid; 500
| server.port | | Conditionally Required [5] | int | Server port number. [6] | 80; 8080; 443
| db.operation.batch.size | | Recommended | int | The number of database operations included in a batch operation. [7] | 2; 3; 4
| server.address | | Recommended | string | Name of the database host. [8] | example.com; 10.1.2.80; /tmp/my.sock
[1] db.collection.name: 애플리케이션이 제공하는 값을 그대로 캡처하는 것을 권장해요(RECOMMENDED). 대소문자 정규화(case normalization)를 시도하지 마세요.
배치(batch) 연산의 경우, 개별 연산들이 같은 컬렉션 이름을 사용한다는 것을 안다면 그 컬렉션 이름을 사용해야 해요(SHOULD).
[2] db.response.status_code: 연산이 실패했고 오류 코드를 사용할 수 있다면 설정해요.
[3] db.response.status_code: 모든 MongoDB 오류 코드는 오류로 간주해야 해요(SHOULD).
[4] error.type: error.type은 데이터베이스나 클라이언트 라이브러리가 반환한 db.response.status_code 또는 발생한 예외의 표준 이름과 일치해야 해요(SHOULD). 표준 예외 타입 이름을 사용할 때, 인스트루멘테이션은 가장 관련성 높은 타입을 보고하기 위해 최선을 다해야 해요(SHOULD). 예를 들어 원래 예외가 제네릭 예외로 감싸져 있다면 원래 예외를 우선해야 해요(SHOULD).
인스트루멘테이션은 error.type이 어떻게 채워지는지 문서화해야 해요(SHOULD).
[5] server.port: 이 DBMS의 기본 포트가 아닌 다른 포트를 사용하고 있고 server.address가 설정돼 있다면 설정해요.
[6] server.port: 클라이언트 쪽에서 관찰할 때, 중간자를 통해 통신하는 경우 server.port는 프록시 같은 중간자 뒤에 있는 서버 포트를 나타내야 해요(SHOULD)(가능하다면).
[7] db.operation.batch.size: 아래에서 설명하는 빈 배치 요청을 제외하면, 배치 연산은 단일 클라이언트 호출·프로토콜 메시지·데이터베이스 명령으로 별개의 연산으로 명시적으로 제출된 두 개 이상의 데이터베이스 연산을 포함해요.
단 하나의 연산만 포함하는 배치 API 요청은 배치 연산이 아닌 단일 연산으로 모델링해야 해요(SHOULD).
하나의 연산이 키·행·문서·포인트 같은 여러 피연산자(여러 키를 받는 Redis MGET 포함)를 받는다는 이유만으로 데이터베이스 호출이 배치 연산인 것은 아니에요.
같은 파라미터화된 연산을 파라미터 집합으로 실행하는 배치 API에서는 각 파라미터 집합이 요청이 배치 연산인지 판단할 때 하나의 데이터베이스 연산을 나타내요. 파라미터 집합이 하나뿐인 요청은 배치 연산이 아닌 단일 연산으로 모델링해야 해요(SHOULD).
db.operation.batch.size는 배치 내 연산 수로 설정해야 해요(SHOULD). 비배치 연산에는 설정하지 않아야 해요(SHOULD NOT).
연산이 없는 배치 연산을 실행하는 요청도 배치 연산으로 취급해야 하며, db.operation.batch.size는 0으로 설정해야 해요(SHOULD).
[8] server.address: 클라이언트 쪽에서 관찰할 때, 중간자를 통해 통신하는 경우 server.address는 프록시 같은 중간자 뒤에 있는 서버 주소를 나타내야 해요(SHOULD)(가능하다면).
샘플링 결정을 내리는 데 중요할 수 있는 다음 속성들은 (제공된다면) 스팬 생성 시점에 제공해야 해요(SHOULD):
db.collection.namedb.namespacedb.operation.nameserver.addressserver.port
error.type에는 다음과 같은 잘 알려진 값 목록이 있어요. 그중 하나가 적용된다면 해당 값을 반드시 사용해야 하고(MUST), 그렇지 않으면 커스텀 값을 사용할 수 있어요(MAY).
| | Value | Description | Stability
| _OTHER | A fallback error value to be used when the instrumentation doesn’t define a custom value. |
예시(Example)
| | Key | Value
| Span name | "findAndModify products"
| db.system.name | "mongodb"
| server.address | "mongodb0.example.com"
| server.port | 27017
| db.collection.name | "products"
| db.namespace | "shopDb"
| db.query.text | not set
| db.operation.name | "findAndModify"
메트릭(Metrics)
MongoDB 클라이언트 인스트루멘테이션은 일반 데이터베이스 클라이언트 메트릭 시맨틱 컨벤션(General Semantic Conventions for Database Client Metrics)에 따라 메트릭을 수집해야 해요(SHOULD).
db.system.name은 반드시 "mongodb"로 설정해야 해요(MUST).