From 6ad27961af6c81aea98de4fd080fe4c49b474ad8 Mon Sep 17 00:00:00 2001 From: echoontheway <1152760298@qq.com> Date: Tue, 12 Oct 2021 17:01:33 +0800 Subject: [PATCH 1/2] feat(@opentelemetry/semantic-conventions): change enum to object literals --- .../resource/SemanticResourceAttributes.ts | 116 ++++--- .../src/trace/SemanticAttributes.ts | 290 +++++++++--------- .../templates/SemanticAttributes.ts.j2 | 5 +- 3 files changed, 203 insertions(+), 208 deletions(-) diff --git a/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts b/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts index 382e315a24..64657c6b63 100644 --- a/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts +++ b/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts @@ -476,141 +476,139 @@ As an alternative, consider setting `faas.id` as a span attribute instead. WEBENGINE_DESCRIPTION: 'webengine.description', } -// Enum definitions - -export enum CloudProviderValues { +export const CloudProviderValues = { /** Alibaba Cloud. */ - ALIBABA_CLOUD = 'alibaba_cloud', + ALIBABA_CLOUD: 'alibaba_cloud', /** Amazon Web Services. */ - AWS = 'aws', + AWS: 'aws', /** Microsoft Azure. */ - AZURE = 'azure', + AZURE: 'azure', /** Google Cloud Platform. */ - GCP = 'gcp', + GCP: 'gcp', } -export enum CloudPlatformValues { +export const CloudPlatformValues = { /** Alibaba Cloud Elastic Compute Service. */ - ALIBABA_CLOUD_ECS = 'alibaba_cloud_ecs', + ALIBABA_CLOUD_ECS: 'alibaba_cloud_ecs', /** Alibaba Cloud Function Compute. */ - ALIBABA_CLOUD_FC = 'alibaba_cloud_fc', + ALIBABA_CLOUD_FC: 'alibaba_cloud_fc', /** AWS Elastic Compute Cloud. */ - AWS_EC2 = 'aws_ec2', + AWS_EC2: 'aws_ec2', /** AWS Elastic Container Service. */ - AWS_ECS = 'aws_ecs', + AWS_ECS: 'aws_ecs', /** AWS Elastic Kubernetes Service. */ - AWS_EKS = 'aws_eks', + AWS_EKS: 'aws_eks', /** AWS Lambda. */ - AWS_LAMBDA = 'aws_lambda', + AWS_LAMBDA: 'aws_lambda', /** AWS Elastic Beanstalk. */ - AWS_ELASTIC_BEANSTALK = 'aws_elastic_beanstalk', + AWS_ELASTIC_BEANSTALK: 'aws_elastic_beanstalk', /** Azure Virtual Machines. */ - AZURE_VM = 'azure_vm', + AZURE_VM: 'azure_vm', /** Azure Container Instances. */ - AZURE_CONTAINER_INSTANCES = 'azure_container_instances', + AZURE_CONTAINER_INSTANCES: 'azure_container_instances', /** Azure Kubernetes Service. */ - AZURE_AKS = 'azure_aks', + AZURE_AKS: 'azure_aks', /** Azure Functions. */ - AZURE_FUNCTIONS = 'azure_functions', + AZURE_FUNCTIONS: 'azure_functions', /** Azure App Service. */ - AZURE_APP_SERVICE = 'azure_app_service', + AZURE_APP_SERVICE: 'azure_app_service', /** Google Cloud Compute Engine (GCE). */ - GCP_COMPUTE_ENGINE = 'gcp_compute_engine', + GCP_COMPUTE_ENGINE: 'gcp_compute_engine', /** Google Cloud Run. */ - GCP_CLOUD_RUN = 'gcp_cloud_run', + GCP_CLOUD_RUN: 'gcp_cloud_run', /** Google Cloud Kubernetes Engine (GKE). */ - GCP_KUBERNETES_ENGINE = 'gcp_kubernetes_engine', + GCP_KUBERNETES_ENGINE: 'gcp_kubernetes_engine', /** Google Cloud Functions (GCF). */ - GCP_CLOUD_FUNCTIONS = 'gcp_cloud_functions', + GCP_CLOUD_FUNCTIONS: 'gcp_cloud_functions', /** Google Cloud App Engine (GAE). */ - GCP_APP_ENGINE = 'gcp_app_engine', + GCP_APP_ENGINE: 'gcp_app_engine', } -export enum AwsEcsLaunchtypeValues { +export const AwsEcsLaunchtypeValues = { /** ec2. */ - EC2 = 'ec2', + EC2: 'ec2', /** fargate. */ - FARGATE = 'fargate', + FARGATE: 'fargate', } -export enum HostArchValues { +export const HostArchValues = { /** AMD64. */ - AMD64 = 'amd64', + AMD64: 'amd64', /** ARM32. */ - ARM32 = 'arm32', + ARM32: 'arm32', /** ARM64. */ - ARM64 = 'arm64', + ARM64: 'arm64', /** Itanium. */ - IA64 = 'ia64', + IA64: 'ia64', /** 32-bit PowerPC. */ - PPC32 = 'ppc32', + PPC32: 'ppc32', /** 64-bit PowerPC. */ - PPC64 = 'ppc64', + PPC64: 'ppc64', /** 32-bit x86. */ - X86 = 'x86', + X86: 'x86', } -export enum OsTypeValues { +export const OsTypeValues = { /** Microsoft Windows. */ - WINDOWS = 'windows', + WINDOWS: 'windows', /** Linux. */ - LINUX = 'linux', + LINUX: 'linux', /** Apple Darwin. */ - DARWIN = 'darwin', + DARWIN: 'darwin', /** FreeBSD. */ - FREEBSD = 'freebsd', + FREEBSD: 'freebsd', /** NetBSD. */ - NETBSD = 'netbsd', + NETBSD: 'netbsd', /** OpenBSD. */ - OPENBSD = 'openbsd', + OPENBSD: 'openbsd', /** DragonFly BSD. */ - DRAGONFLYBSD = 'dragonflybsd', + DRAGONFLYBSD: 'dragonflybsd', /** HP-UX (Hewlett Packard Unix). */ - HPUX = 'hpux', + HPUX: 'hpux', /** AIX (Advanced Interactive eXecutive). */ - AIX = 'aix', + AIX: 'aix', /** Oracle Solaris. */ - SOLARIS = 'solaris', + SOLARIS: 'solaris', /** IBM z/OS. */ - Z_OS = 'z_os', + Z_OS: 'z_os', } -export enum TelemetrySdkLanguageValues { +export const TelemetrySdkLanguageValues = { /** cpp. */ - CPP = 'cpp', + CPP: 'cpp', /** dotnet. */ - DOTNET = 'dotnet', + DOTNET: 'dotnet', /** erlang. */ - ERLANG = 'erlang', + ERLANG: 'erlang', /** go. */ - GO = 'go', + GO: 'go', /** java. */ - JAVA = 'java', + JAVA: 'java', /** nodejs. */ - NODEJS = 'nodejs', + NODEJS: 'nodejs', /** php. */ - PHP = 'php', + PHP: 'php', /** python. */ - PYTHON = 'python', + PYTHON: 'python', /** ruby. */ - RUBY = 'ruby', + RUBY: 'ruby', /** webjs. */ - WEBJS = 'webjs', + WEBJS: 'webjs', } diff --git a/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts b/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts index 48fecf29be..63ce16e009 100644 --- a/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts +++ b/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts @@ -723,343 +723,341 @@ the closest proxy. MESSAGE_UNCOMPRESSED_SIZE: 'message.uncompressed_size', } -// Enum definitions - -export enum DbSystemValues { +export const DbSystemValues = { /** Some other SQL database. Fallback only. See notes. */ - OTHER_SQL = 'other_sql', + OTHER_SQL: 'other_sql', /** Microsoft SQL Server. */ - MSSQL = 'mssql', + MSSQL: 'mssql', /** MySQL. */ - MYSQL = 'mysql', + MYSQL: 'mysql', /** Oracle Database. */ - ORACLE = 'oracle', + ORACLE: 'oracle', /** IBM Db2. */ - DB2 = 'db2', + DB2: 'db2', /** PostgreSQL. */ - POSTGRESQL = 'postgresql', + POSTGRESQL: 'postgresql', /** Amazon Redshift. */ - REDSHIFT = 'redshift', + REDSHIFT: 'redshift', /** Apache Hive. */ - HIVE = 'hive', + HIVE: 'hive', /** Cloudscape. */ - CLOUDSCAPE = 'cloudscape', + CLOUDSCAPE: 'cloudscape', /** HyperSQL DataBase. */ - HSQLDB = 'hsqldb', + HSQLDB: 'hsqldb', /** Progress Database. */ - PROGRESS = 'progress', + PROGRESS: 'progress', /** SAP MaxDB. */ - MAXDB = 'maxdb', + MAXDB: 'maxdb', /** SAP HANA. */ - HANADB = 'hanadb', + HANADB: 'hanadb', /** Ingres. */ - INGRES = 'ingres', + INGRES: 'ingres', /** FirstSQL. */ - FIRSTSQL = 'firstsql', + FIRSTSQL: 'firstsql', /** EnterpriseDB. */ - EDB = 'edb', + EDB: 'edb', /** InterSystems Caché. */ - CACHE = 'cache', + CACHE: 'cache', /** Adabas (Adaptable Database System). */ - ADABAS = 'adabas', + ADABAS: 'adabas', /** Firebird. */ - FIREBIRD = 'firebird', + FIREBIRD: 'firebird', /** Apache Derby. */ - DERBY = 'derby', + DERBY: 'derby', /** FileMaker. */ - FILEMAKER = 'filemaker', + FILEMAKER: 'filemaker', /** Informix. */ - INFORMIX = 'informix', + INFORMIX: 'informix', /** InstantDB. */ - INSTANTDB = 'instantdb', + INSTANTDB: 'instantdb', /** InterBase. */ - INTERBASE = 'interbase', + INTERBASE: 'interbase', /** MariaDB. */ - MARIADB = 'mariadb', + MARIADB: 'mariadb', /** Netezza. */ - NETEZZA = 'netezza', + NETEZZA: 'netezza', /** Pervasive PSQL. */ - PERVASIVE = 'pervasive', + PERVASIVE: 'pervasive', /** PointBase. */ - POINTBASE = 'pointbase', + POINTBASE: 'pointbase', /** SQLite. */ - SQLITE = 'sqlite', + SQLITE: 'sqlite', /** Sybase. */ - SYBASE = 'sybase', + SYBASE: 'sybase', /** Teradata. */ - TERADATA = 'teradata', + TERADATA: 'teradata', /** Vertica. */ - VERTICA = 'vertica', + VERTICA: 'vertica', /** H2. */ - H2 = 'h2', + H2: 'h2', /** ColdFusion IMQ. */ - COLDFUSION = 'coldfusion', + COLDFUSION: 'coldfusion', /** Apache Cassandra. */ - CASSANDRA = 'cassandra', + CASSANDRA: 'cassandra', /** Apache HBase. */ - HBASE = 'hbase', + HBASE: 'hbase', /** MongoDB. */ - MONGODB = 'mongodb', + MONGODB: 'mongodb', /** Redis. */ - REDIS = 'redis', + REDIS: 'redis', /** Couchbase. */ - COUCHBASE = 'couchbase', + COUCHBASE: 'couchbase', /** CouchDB. */ - COUCHDB = 'couchdb', + COUCHDB: 'couchdb', /** Microsoft Azure Cosmos DB. */ - COSMOSDB = 'cosmosdb', + COSMOSDB: 'cosmosdb', /** Amazon DynamoDB. */ - DYNAMODB = 'dynamodb', + DYNAMODB: 'dynamodb', /** Neo4j. */ - NEO4J = 'neo4j', + NEO4J: 'neo4j', /** Apache Geode. */ - GEODE = 'geode', + GEODE: 'geode', /** Elasticsearch. */ - ELASTICSEARCH = 'elasticsearch', + ELASTICSEARCH: 'elasticsearch', /** Memcached. */ - MEMCACHED = 'memcached', + MEMCACHED: 'memcached', /** CockroachDB. */ - COCKROACHDB = 'cockroachdb', + COCKROACHDB: 'cockroachdb', } -export enum DbCassandraConsistencyLevelValues { +export const DbCassandraConsistencyLevelValues = { /** all. */ - ALL = 'all', + ALL: 'all', /** each_quorum. */ - EACH_QUORUM = 'each_quorum', + EACH_QUORUM: 'each_quorum', /** quorum. */ - QUORUM = 'quorum', + QUORUM: 'quorum', /** local_quorum. */ - LOCAL_QUORUM = 'local_quorum', + LOCAL_QUORUM: 'local_quorum', /** one. */ - ONE = 'one', + ONE: 'one', /** two. */ - TWO = 'two', + TWO: 'two', /** three. */ - THREE = 'three', + THREE: 'three', /** local_one. */ - LOCAL_ONE = 'local_one', + LOCAL_ONE: 'local_one', /** any. */ - ANY = 'any', + ANY: 'any', /** serial. */ - SERIAL = 'serial', + SERIAL: 'serial', /** local_serial. */ - LOCAL_SERIAL = 'local_serial', + LOCAL_SERIAL: 'local_serial', } -export enum FaasTriggerValues { +export const FaasTriggerValues = { /** A response to some data source operation such as a database or filesystem read/write. */ - DATASOURCE = 'datasource', + DATASOURCE: 'datasource', /** To provide an answer to an inbound HTTP request. */ - HTTP = 'http', + HTTP: 'http', /** A function is set to be executed when messages are sent to a messaging system. */ - PUBSUB = 'pubsub', + PUBSUB: 'pubsub', /** A function is scheduled to be executed regularly. */ - TIMER = 'timer', + TIMER: 'timer', /** If none of the others apply. */ - OTHER = 'other', + OTHER: 'other', } -export enum FaasDocumentOperationValues { +export const FaasDocumentOperationValues = { /** When a new object is created. */ - INSERT = 'insert', + INSERT: 'insert', /** When an object is modified. */ - EDIT = 'edit', + EDIT: 'edit', /** When an object is deleted. */ - DELETE = 'delete', + DELETE: 'delete', } -export enum FaasInvokedProviderValues { +export const FaasInvokedProviderValues = { /** Alibaba Cloud. */ - ALIBABA_CLOUD = 'alibaba_cloud', + ALIBABA_CLOUD: 'alibaba_cloud', /** Amazon Web Services. */ - AWS = 'aws', + AWS: 'aws', /** Microsoft Azure. */ - AZURE = 'azure', + AZURE: 'azure', /** Google Cloud Platform. */ - GCP = 'gcp', + GCP: 'gcp', } -export enum NetTransportValues { +export const NetTransportValues = { /** ip_tcp. */ - IP_TCP = 'ip_tcp', + IP_TCP: 'ip_tcp', /** ip_udp. */ - IP_UDP = 'ip_udp', + IP_UDP: 'ip_udp', /** Another IP-based protocol. */ - IP = 'ip', + IP: 'ip', /** Unix Domain socket. See below. */ - UNIX = 'unix', + UNIX: 'unix', /** Named or anonymous pipe. See note below. */ - PIPE = 'pipe', + PIPE: 'pipe', /** In-process communication. */ - INPROC = 'inproc', + INPROC: 'inproc', /** Something else (non IP-based). */ - OTHER = 'other', + OTHER: 'other', } -export enum NetHostConnectionTypeValues { +export const NetHostConnectionTypeValues = { /** wifi. */ - WIFI = 'wifi', + WIFI: 'wifi', /** wired. */ - WIRED = 'wired', + WIRED: 'wired', /** cell. */ - CELL = 'cell', + CELL: 'cell', /** unavailable. */ - UNAVAILABLE = 'unavailable', + UNAVAILABLE: 'unavailable', /** unknown. */ - UNKNOWN = 'unknown', + UNKNOWN: 'unknown', } -export enum NetHostConnectionSubtypeValues { +export const NetHostConnectionSubtypeValues = { /** GPRS. */ - GPRS = 'gprs', + GPRS: 'gprs', /** EDGE. */ - EDGE = 'edge', + EDGE: 'edge', /** UMTS. */ - UMTS = 'umts', + UMTS: 'umts', /** CDMA. */ - CDMA = 'cdma', + CDMA: 'cdma', /** EVDO Rel. 0. */ - EVDO_0 = 'evdo_0', + EVDO_0: 'evdo_0', /** EVDO Rev. A. */ - EVDO_A = 'evdo_a', + EVDO_A: 'evdo_a', /** CDMA2000 1XRTT. */ - CDMA2000_1XRTT = 'cdma2000_1xrtt', + CDMA2000_1XRTT: 'cdma2000_1xrtt', /** HSDPA. */ - HSDPA = 'hsdpa', + HSDPA: 'hsdpa', /** HSUPA. */ - HSUPA = 'hsupa', + HSUPA: 'hsupa', /** HSPA. */ - HSPA = 'hspa', + HSPA: 'hspa', /** IDEN. */ - IDEN = 'iden', + IDEN: 'iden', /** EVDO Rev. B. */ - EVDO_B = 'evdo_b', + EVDO_B: 'evdo_b', /** LTE. */ - LTE = 'lte', + LTE: 'lte', /** EHRPD. */ - EHRPD = 'ehrpd', + EHRPD: 'ehrpd', /** HSPAP. */ - HSPAP = 'hspap', + HSPAP: 'hspap', /** GSM. */ - GSM = 'gsm', + GSM: 'gsm', /** TD-SCDMA. */ - TD_SCDMA = 'td_scdma', + TD_SCDMA: 'td_scdma', /** IWLAN. */ - IWLAN = 'iwlan', + IWLAN: 'iwlan', /** 5G NR (New Radio). */ - NR = 'nr', + NR: 'nr', /** 5G NRNSA (New Radio Non-Standalone). */ - NRNSA = 'nrnsa', + NRNSA: 'nrnsa', /** LTE CA. */ - LTE_CA = 'lte_ca', + LTE_CA: 'lte_ca', } -export enum HttpFlavorValues { +export const HttpFlavorValues = { /** HTTP 1.0. */ - HTTP_1_0 = '1.0', + HTTP_1_0: '1.0', /** HTTP 1.1. */ - HTTP_1_1 = '1.1', + HTTP_1_1: '1.1', /** HTTP 2. */ - HTTP_2_0 = '2.0', + HTTP_2_0: '2.0', /** SPDY protocol. */ - SPDY = 'SPDY', + SPDY: 'SPDY', /** QUIC protocol. */ - QUIC = 'QUIC', + QUIC: 'QUIC', } -export enum MessagingDestinationKindValues { +export const MessagingDestinationKindValues = { /** A message sent to a queue. */ - QUEUE = 'queue', + QUEUE: 'queue', /** A message sent to a topic. */ - TOPIC = 'topic', + TOPIC: 'topic', } -export enum MessagingOperationValues { +export const MessagingOperationValues = { /** receive. */ - RECEIVE = 'receive', + RECEIVE: 'receive', /** process. */ - PROCESS = 'process', + PROCESS: 'process', } -export enum RpcGrpcStatusCodeValues { +export const RpcGrpcStatusCodeValues = { /** OK. */ - OK = 0, + OK: 0, /** CANCELLED. */ - CANCELLED = 1, + CANCELLED: 1, /** UNKNOWN. */ - UNKNOWN = 2, + UNKNOWN: 2, /** INVALID_ARGUMENT. */ - INVALID_ARGUMENT = 3, + INVALID_ARGUMENT: 3, /** DEADLINE_EXCEEDED. */ - DEADLINE_EXCEEDED = 4, + DEADLINE_EXCEEDED: 4, /** NOT_FOUND. */ - NOT_FOUND = 5, + NOT_FOUND: 5, /** ALREADY_EXISTS. */ - ALREADY_EXISTS = 6, + ALREADY_EXISTS: 6, /** PERMISSION_DENIED. */ - PERMISSION_DENIED = 7, + PERMISSION_DENIED: 7, /** RESOURCE_EXHAUSTED. */ - RESOURCE_EXHAUSTED = 8, + RESOURCE_EXHAUSTED: 8, /** FAILED_PRECONDITION. */ - FAILED_PRECONDITION = 9, + FAILED_PRECONDITION: 9, /** ABORTED. */ - ABORTED = 10, + ABORTED: 10, /** OUT_OF_RANGE. */ - OUT_OF_RANGE = 11, + OUT_OF_RANGE: 11, /** UNIMPLEMENTED. */ - UNIMPLEMENTED = 12, + UNIMPLEMENTED: 12, /** INTERNAL. */ - INTERNAL = 13, + INTERNAL: 13, /** UNAVAILABLE. */ - UNAVAILABLE = 14, + UNAVAILABLE: 14, /** DATA_LOSS. */ - DATA_LOSS = 15, + DATA_LOSS: 15, /** UNAUTHENTICATED. */ - UNAUTHENTICATED = 16, + UNAUTHENTICATED: 16, } -export enum MessageTypeValues { +export const MessageTypeValues = { /** sent. */ - SENT = 'SENT', + SENT: 'SENT', /** received. */ - RECEIVED = 'RECEIVED', + RECEIVED: 'RECEIVED', } diff --git a/scripts/semconv/templates/SemanticAttributes.ts.j2 b/scripts/semconv/templates/SemanticAttributes.ts.j2 index 18004561d9..161967d1af 100644 --- a/scripts/semconv/templates/SemanticAttributes.ts.j2 +++ b/scripts/semconv/templates/SemanticAttributes.ts.j2 @@ -44,17 +44,16 @@ export const {{class}} = { {%- endfor %} } -// Enum definitions {%- for attribute in attributes if attribute.is_local and not attribute.ref %} {%- if attribute.is_enum %} {%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" %} {%- set type = attribute.attr_type.enum_type %} {% if attribute.attr_type.members is defined and attribute.attr_type.members|length > 0 %} -export enum {{class_name}} { +export const {{class_name}} = { {%- for member in attribute.attr_type.members if attribute.is_local and not attribute.ref %} /** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */ - {{ member.member_id | to_const_name }} = {{ print_value(type, member.value) }}, + {{ member.member_id | to_const_name }}: {{ print_value(type, member.value) }}, {%- endfor %} } {% endif %} From 8ae581c21bed96aa323d0c1f3a7867e9f6669efa Mon Sep 17 00:00:00 2001 From: echoontheway <1152760298@qq.com> Date: Thu, 14 Oct 2021 19:19:53 +0800 Subject: [PATCH 2/2] feat: add 'as const' for object to keep the type checking ability of enmu --- .../resource/SemanticResourceAttributes.ts | 18 ++++++--- .../src/trace/SemanticAttributes.ts | 39 ++++++++++++------- .../templates/SemanticAttributes.ts.j2 | 3 +- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts b/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts index 64657c6b63..9e3a9d02ae 100644 --- a/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts +++ b/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts @@ -486,7 +486,8 @@ export const CloudProviderValues = { AZURE: 'azure', /** Google Cloud Platform. */ GCP: 'gcp', -} +} as const +export type CloudProviderValues = typeof CloudProviderValues[keyof typeof CloudProviderValues] @@ -526,7 +527,8 @@ export const CloudPlatformValues = { GCP_CLOUD_FUNCTIONS: 'gcp_cloud_functions', /** Google Cloud App Engine (GAE). */ GCP_APP_ENGINE: 'gcp_app_engine', -} +} as const +export type CloudPlatformValues = typeof CloudPlatformValues[keyof typeof CloudPlatformValues] @@ -536,7 +538,8 @@ export const AwsEcsLaunchtypeValues = { EC2: 'ec2', /** fargate. */ FARGATE: 'fargate', -} +} as const +export type AwsEcsLaunchtypeValues = typeof AwsEcsLaunchtypeValues[keyof typeof AwsEcsLaunchtypeValues] @@ -556,7 +559,8 @@ export const HostArchValues = { PPC64: 'ppc64', /** 32-bit x86. */ X86: 'x86', -} +} as const +export type HostArchValues = typeof HostArchValues[keyof typeof HostArchValues] @@ -584,7 +588,8 @@ export const OsTypeValues = { SOLARIS: 'solaris', /** IBM z/OS. */ Z_OS: 'z_os', -} +} as const +export type OsTypeValues = typeof OsTypeValues[keyof typeof OsTypeValues] @@ -610,5 +615,6 @@ export const TelemetrySdkLanguageValues = { RUBY: 'ruby', /** webjs. */ WEBJS: 'webjs', -} +} as const +export type TelemetrySdkLanguageValues = typeof TelemetrySdkLanguageValues[keyof typeof TelemetrySdkLanguageValues] diff --git a/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts b/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts index 63ce16e009..052d36e4c0 100644 --- a/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts +++ b/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts @@ -819,7 +819,8 @@ export const DbSystemValues = { MEMCACHED: 'memcached', /** CockroachDB. */ COCKROACHDB: 'cockroachdb', -} +} as const +export type DbSystemValues = typeof DbSystemValues[keyof typeof DbSystemValues] @@ -847,7 +848,8 @@ export const DbCassandraConsistencyLevelValues = { SERIAL: 'serial', /** local_serial. */ LOCAL_SERIAL: 'local_serial', -} +} as const +export type DbCassandraConsistencyLevelValues = typeof DbCassandraConsistencyLevelValues[keyof typeof DbCassandraConsistencyLevelValues] @@ -863,7 +865,8 @@ export const FaasTriggerValues = { TIMER: 'timer', /** If none of the others apply. */ OTHER: 'other', -} +} as const +export type FaasTriggerValues = typeof FaasTriggerValues[keyof typeof FaasTriggerValues] @@ -875,7 +878,8 @@ export const FaasDocumentOperationValues = { EDIT: 'edit', /** When an object is deleted. */ DELETE: 'delete', -} +} as const +export type FaasDocumentOperationValues = typeof FaasDocumentOperationValues[keyof typeof FaasDocumentOperationValues] @@ -889,7 +893,8 @@ export const FaasInvokedProviderValues = { AZURE: 'azure', /** Google Cloud Platform. */ GCP: 'gcp', -} +} as const +export type FaasInvokedProviderValues = typeof FaasInvokedProviderValues[keyof typeof FaasInvokedProviderValues] @@ -909,7 +914,8 @@ export const NetTransportValues = { INPROC: 'inproc', /** Something else (non IP-based). */ OTHER: 'other', -} +} as const +export type NetTransportValues = typeof NetTransportValues[keyof typeof NetTransportValues] @@ -925,7 +931,8 @@ export const NetHostConnectionTypeValues = { UNAVAILABLE: 'unavailable', /** unknown. */ UNKNOWN: 'unknown', -} +} as const +export type NetHostConnectionTypeValues = typeof NetHostConnectionTypeValues[keyof typeof NetHostConnectionTypeValues] @@ -973,7 +980,8 @@ export const NetHostConnectionSubtypeValues = { NRNSA: 'nrnsa', /** LTE CA. */ LTE_CA: 'lte_ca', -} +} as const +export type NetHostConnectionSubtypeValues = typeof NetHostConnectionSubtypeValues[keyof typeof NetHostConnectionSubtypeValues] @@ -989,7 +997,8 @@ export const HttpFlavorValues = { SPDY: 'SPDY', /** QUIC protocol. */ QUIC: 'QUIC', -} +} as const +export type HttpFlavorValues = typeof HttpFlavorValues[keyof typeof HttpFlavorValues] @@ -999,7 +1008,8 @@ export const MessagingDestinationKindValues = { QUEUE: 'queue', /** A message sent to a topic. */ TOPIC: 'topic', -} +} as const +export type MessagingDestinationKindValues = typeof MessagingDestinationKindValues[keyof typeof MessagingDestinationKindValues] @@ -1009,7 +1019,8 @@ export const MessagingOperationValues = { RECEIVE: 'receive', /** process. */ PROCESS: 'process', -} +} as const +export type MessagingOperationValues = typeof MessagingOperationValues[keyof typeof MessagingOperationValues] @@ -1049,7 +1060,8 @@ export const RpcGrpcStatusCodeValues = { DATA_LOSS: 15, /** UNAUTHENTICATED. */ UNAUTHENTICATED: 16, -} +} as const +export type RpcGrpcStatusCodeValues = typeof RpcGrpcStatusCodeValues[keyof typeof RpcGrpcStatusCodeValues] @@ -1059,5 +1071,6 @@ export const MessageTypeValues = { SENT: 'SENT', /** received. */ RECEIVED: 'RECEIVED', -} +} as const +export type MessageTypeValues = typeof MessageTypeValues[keyof typeof MessageTypeValues] diff --git a/scripts/semconv/templates/SemanticAttributes.ts.j2 b/scripts/semconv/templates/SemanticAttributes.ts.j2 index 161967d1af..eb144b93b2 100644 --- a/scripts/semconv/templates/SemanticAttributes.ts.j2 +++ b/scripts/semconv/templates/SemanticAttributes.ts.j2 @@ -55,7 +55,8 @@ export const {{class_name}} = { /** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */ {{ member.member_id | to_const_name }}: {{ print_value(type, member.value) }}, {%- endfor %} -} +} as const +export type {{class_name}} = typeof {{class_name}}[keyof typeof {{class_name}}] {% endif %} {% endif %}