Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions semantic-core/cue/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
all: fmt vet schemas check-jsonschema
.PHONY: all

schemas: schemas/agent-payload schemas/span
.PHONY: schemas

schemas/agent-payload:
@mkdir -p gen/schemas && cue export . -e AgentPayload -o gen/schemas/agent_payload.json -f
.PHONY: schemas/agent-payload

schemas/span:
@mkdir -p gen/schemas && cue export . -e Span -o gen/schemas/span.json -f
.PHONY: schemas/span

fmt:
@cue fmt ./...
.PHONY: fmt

vet:
@cue vet ./... -c
.PHONY: vet

check-jsonschema:
@check-jsonschema --check-metaschema ./gen/schemas/*.json
.PHONY: check-jsonschema

fields:
@mkdir -p gen && cue export . -e Fields -o gen/fields.json -f
.PHONY: fields
15 changes: 15 additions & 0 deletions semantic-core/cue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

## Install

```shell
brew install cue check-jsonschema
```


## Generate definitions

```shell
make
```

JSON Schema fields will be generated under gen/schemas
1 change: 1 addition & 0 deletions semantic-core/cue/cue.mod/module.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module: "github.com/DataDog/schema"
22 changes: 22 additions & 0 deletions semantic-core/cue/fields_common.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package schema

Fields: [string]: #Properties

Fields: Common: {
"_dd.hostname": {
title: "Hostname"
description: "Hostname of where the agent is running."
type: "string"
default: null
examples: [
"my-hostname",
]
minLength: 0
}
"span.kind": {
title: "Span Kind"
description: "Span Kind"
type: "string"
enum: ["client", "server", "producer", "consumer", "internal"]
}
}
85 changes: 85 additions & 0 deletions semantic-core/cue/fields_db.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package schema

Fields: DB: {
"db.system": {
"description": "An identifier for the database management system (DBMS) product being used."
"examples": [
"mysql",
"postgresql",
]
"type": "string"
// TODO: use enum feature instead of pattern.
"enum": ["adabas", "buntdb", "cache"]
// "pattern": "^(adabas|buntdb|cache|cassandra|cloudscape|cockroachdb|coldfusion|consul|cosmosdb|couchbase|couchdb|db2|derby|dynamodb|edb|elasticsearch|eloquent|filemaker|firebird|firstsql|geode|h2|hanadb|hbase|hive|hsqldb|informix|ingres|instantdb|interbase|leveldb|mariadb|maxdb|memcached|mongodb|mssql|mysql|neo4j|netezza|opensearch|oracle|other_sql|pervasive|pointbase|postgresql|presto|progress|redis|redshift|snowflake|sqlite|sybase|teradata|vertica)$"
"title": "DB System"
}
"db.connection_string": {
"default": null
"description": "The connection string used to connect to the database."
"examples": [
"Server=(localdb)\u000b11.0;Integrated Security=true;",
"postgresql://localhost:5432",
]
"is_sensitive": true
"title": "DB Connection String"
"type": "string"
}
"db.user": {
"default": null
"description": "Username for accessing the database."
"examples": [
"widget_user",
]
"title": "DB User"
"type": "string"
}
"db.name": {
"default": null
"description": "The name of the database being connected to."
"examples": [
"customers",
]
"title": "DB Name"
"type": "string"
}
"db.statement": {
"default": null
"description": "The database statement being executed."
"examples": [
"SELECT * FROM wuser_table', 'SET mykey \"WuValue",
]
"is_sensitive": true
"title": "DB Statement"
"type": "string"
}
"db.operation": {
"default": null
"description": "The name of the operation being executed, e.g. the MongoDB command name such as findAndModify, or the SQL keyword."
"examples": [
"findAndModify",
"HMSET",
"SELECT",
]
"title": "DB Operation"
"type": "string"
}
"db.sql.table": {
"default": null
"description": "The name of the primary table that the operation is acting upon, including the database name (if applicable)."
"examples": [
"customers",
]
"title": "DB SQL Table"
"type": "string"
}
"db.row_count": {
"default": null
"description": "\nThe number of rows/results from the query or operation. For caches and other datastores, i.e. Redis, this tag should only set for operations that retrieve stored data,\nsuch as GET operations and queries, excluding SET and other commands not returning data. "
"examples": [
"customers",
]
"minimum": 0
"title": "DB Row Count"
"type": "integer"
}
}
125 changes: 125 additions & 0 deletions semantic-core/cue/fields_http.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package schema

Fields: HTTP: {
"http.status_code": {
"description": "\nThe HTTP response status code.\nWhen span.kind: client the response status code received.\nWhen span.kind: server the response status code sent.\nNote: Although this is an integer, it must be sent as a string."
"examples": [
"200",
"404",
"500",
]
"pattern": "^[12345]\\d\\d$"
"title": "HTTP Status Code"
"type": "string"
}
"http.url": {
"description": "\nThe URL of the HTTP request, including the obfuscated query string."
"examples": [
"https://example.com:443/search?q=datadog",
]
"is_sensitive": true
"minLength": 1
"title": "HTTP URL"
"type": "string"
}
"http.method": {
"description": "\nThe HTTP method used for the connection. Required for both client and server spans."
"examples": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
]
"pattern": "^(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH)$"
"title": "HTTP Method"
"type": "string"
}
"http.version": {
"description": "\nThe version of HTTP used for the request."
"examples": [
"1.0",
"1.1",
"2.0",
]
"pattern": "^1\\.[01]$|^2\\.0$"
"title": "HTTP Version"
"type": "string"
}
"http.route": {
"default": null
"description": "\nThe matched route (path template).\nOnly when span.kind: server."
"examples": [
"/users/:userID",
]
"minLength": 1
"title": "HTTP Route"
"type": "string"
}
"http.client_ip": {
"default": null
"description": "\nThe IP address of the original client behind all proxies, if known (discovered from headers such as X-Forwarded-For)."
"examples": [
"192.168.123.132",
]
"is_sensitive": true
"pattern": "^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}|(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$"
"title": "HTTP Client IP"
"type": "string"
}
"http.useragent": {
"default": null
"description": "\nThe user agent header received with the request.\nOnly when span.kind: server."
"examples": [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
]
"is_sensitive": true
"minLength": 1
"title": "HTTP User Agent"
"type": "string"
}
"http.request.content_length": {
"default": null
"description": "\nThe size of the request body.\nThe size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the Content-Length header.\nFor requests using transport encoding, this should be compressed size."
"examples": [
1234,
]
"exclusiveMinimum": 0
"is_sensitive": true
"title": "HTTP Request Content Length"
"type": "integer"
}
"http.response.content_length": {
"default": null
"description": "\nThe size of the response payload body in bytes.\nThe size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the Content-Length header.\nFor requests using transport encoding, this should be compressed size."
"examples": [
1234,
]
"exclusiveMinimum": 0
"is_sensitive": true
"title": "HTTP Response Content Length"
"type": "integer"
}
"http.request.content_length_uncompressed": {
"default": null
"description": "\nThe size of the request payload body after transport decoding. Not set if transport encoding not used."
"examples": [
1234,
]
"exclusiveMinimum": 0
"is_sensitive": true
"title": "HTTP Request Content Length Uncompressed"
"type": "integer"
}
"http.response.content_length_uncompressed": {
"default": null
"description": "\nThe size of the response payload body after transport decoding. Not set if transport encoding not used."
"examples": [
1234,
]
"exclusiveMinimum": 0
"is_sensitive": true
"title": "HTTP Response Content Length Uncompressed"
"type": "integer"
}
}
Loading