From a8fb7fd813eef9ff6285c2592afed36f0c40f4bb Mon Sep 17 00:00:00 2001 From: Nev Wylie <54870357+MSNev@users.noreply.github.com> Date: Thu, 8 Feb 2024 13:58:03 -0800 Subject: [PATCH] Update generation to use createConstMap for enums where possible --- .../resource/SemanticResourceAttributes.ts | 132 +++++---- .../src/trace/SemanticAttributes.ts | 272 +++++++++--------- .../templates/SemanticAttributes.ts.j2 | 30 +- 3 files changed, 237 insertions(+), 197 deletions(-) diff --git a/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts b/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts index e5d4f6c882d..dab5ad44d68 100644 --- a/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts +++ b/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts @@ -1181,12 +1181,13 @@ export type CloudProviderValues = { * The constant map of values for CloudProviderValues. * @deprecated Use the CLOUDPROVIDERVALUES_XXXXX constants rather than the CloudProviderValues.XXXXX for bundle minification. */ -export const CloudProviderValues: CloudProviderValues = { - ALIBABA_CLOUD: TMP_CLOUDPROVIDERVALUES_ALIBABA_CLOUD, - AWS: TMP_CLOUDPROVIDERVALUES_AWS, - AZURE: TMP_CLOUDPROVIDERVALUES_AZURE, - GCP: TMP_CLOUDPROVIDERVALUES_GCP, -}; +export const CloudProviderValues: CloudProviderValues = + /*#__PURE__*/ createConstMap([ + TMP_CLOUDPROVIDERVALUES_ALIBABA_CLOUD, + TMP_CLOUDPROVIDERVALUES_AWS, + TMP_CLOUDPROVIDERVALUES_AZURE, + TMP_CLOUDPROVIDERVALUES_GCP, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for CloudPlatformValues enum definition @@ -1413,25 +1414,26 @@ export type CloudPlatformValues = { * The constant map of values for CloudPlatformValues. * @deprecated Use the CLOUDPLATFORMVALUES_XXXXX constants rather than the CloudPlatformValues.XXXXX for bundle minification. */ -export const CloudPlatformValues: CloudPlatformValues = { - ALIBABA_CLOUD_ECS: TMP_CLOUDPLATFORMVALUES_ALIBABA_CLOUD_ECS, - ALIBABA_CLOUD_FC: TMP_CLOUDPLATFORMVALUES_ALIBABA_CLOUD_FC, - AWS_EC2: TMP_CLOUDPLATFORMVALUES_AWS_EC2, - AWS_ECS: TMP_CLOUDPLATFORMVALUES_AWS_ECS, - AWS_EKS: TMP_CLOUDPLATFORMVALUES_AWS_EKS, - AWS_LAMBDA: TMP_CLOUDPLATFORMVALUES_AWS_LAMBDA, - AWS_ELASTIC_BEANSTALK: TMP_CLOUDPLATFORMVALUES_AWS_ELASTIC_BEANSTALK, - AZURE_VM: TMP_CLOUDPLATFORMVALUES_AZURE_VM, - AZURE_CONTAINER_INSTANCES: TMP_CLOUDPLATFORMVALUES_AZURE_CONTAINER_INSTANCES, - AZURE_AKS: TMP_CLOUDPLATFORMVALUES_AZURE_AKS, - AZURE_FUNCTIONS: TMP_CLOUDPLATFORMVALUES_AZURE_FUNCTIONS, - AZURE_APP_SERVICE: TMP_CLOUDPLATFORMVALUES_AZURE_APP_SERVICE, - GCP_COMPUTE_ENGINE: TMP_CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE, - GCP_CLOUD_RUN: TMP_CLOUDPLATFORMVALUES_GCP_CLOUD_RUN, - GCP_KUBERNETES_ENGINE: TMP_CLOUDPLATFORMVALUES_GCP_KUBERNETES_ENGINE, - GCP_CLOUD_FUNCTIONS: TMP_CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS, - GCP_APP_ENGINE: TMP_CLOUDPLATFORMVALUES_GCP_APP_ENGINE, -}; +export const CloudPlatformValues: CloudPlatformValues = + /*#__PURE__*/ createConstMap([ + TMP_CLOUDPLATFORMVALUES_ALIBABA_CLOUD_ECS, + TMP_CLOUDPLATFORMVALUES_ALIBABA_CLOUD_FC, + TMP_CLOUDPLATFORMVALUES_AWS_EC2, + TMP_CLOUDPLATFORMVALUES_AWS_ECS, + TMP_CLOUDPLATFORMVALUES_AWS_EKS, + TMP_CLOUDPLATFORMVALUES_AWS_LAMBDA, + TMP_CLOUDPLATFORMVALUES_AWS_ELASTIC_BEANSTALK, + TMP_CLOUDPLATFORMVALUES_AZURE_VM, + TMP_CLOUDPLATFORMVALUES_AZURE_CONTAINER_INSTANCES, + TMP_CLOUDPLATFORMVALUES_AZURE_AKS, + TMP_CLOUDPLATFORMVALUES_AZURE_FUNCTIONS, + TMP_CLOUDPLATFORMVALUES_AZURE_APP_SERVICE, + TMP_CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE, + TMP_CLOUDPLATFORMVALUES_GCP_CLOUD_RUN, + TMP_CLOUDPLATFORMVALUES_GCP_KUBERNETES_ENGINE, + TMP_CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS, + TMP_CLOUDPLATFORMVALUES_GCP_APP_ENGINE, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for AwsEcsLaunchtypeValues enum definition @@ -1473,10 +1475,11 @@ export type AwsEcsLaunchtypeValues = { * The constant map of values for AwsEcsLaunchtypeValues. * @deprecated Use the AWSECSLAUNCHTYPEVALUES_XXXXX constants rather than the AwsEcsLaunchtypeValues.XXXXX for bundle minification. */ -export const AwsEcsLaunchtypeValues: AwsEcsLaunchtypeValues = { - EC2: TMP_AWSECSLAUNCHTYPEVALUES_EC2, - FARGATE: TMP_AWSECSLAUNCHTYPEVALUES_FARGATE, -}; +export const AwsEcsLaunchtypeValues: AwsEcsLaunchtypeValues = + /*#__PURE__*/ createConstMap([ + TMP_AWSECSLAUNCHTYPEVALUES_EC2, + TMP_AWSECSLAUNCHTYPEVALUES_FARGATE, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for HostArchValues enum definition @@ -1562,15 +1565,16 @@ export type HostArchValues = { * The constant map of values for HostArchValues. * @deprecated Use the HOSTARCHVALUES_XXXXX constants rather than the HostArchValues.XXXXX for bundle minification. */ -export const HostArchValues: HostArchValues = { - AMD64: TMP_HOSTARCHVALUES_AMD64, - ARM32: TMP_HOSTARCHVALUES_ARM32, - ARM64: TMP_HOSTARCHVALUES_ARM64, - IA64: TMP_HOSTARCHVALUES_IA64, - PPC32: TMP_HOSTARCHVALUES_PPC32, - PPC64: TMP_HOSTARCHVALUES_PPC64, - X86: TMP_HOSTARCHVALUES_X86, -}; +export const HostArchValues: HostArchValues = + /*#__PURE__*/ createConstMap([ + TMP_HOSTARCHVALUES_AMD64, + TMP_HOSTARCHVALUES_ARM32, + TMP_HOSTARCHVALUES_ARM64, + TMP_HOSTARCHVALUES_IA64, + TMP_HOSTARCHVALUES_PPC32, + TMP_HOSTARCHVALUES_PPC64, + TMP_HOSTARCHVALUES_X86, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for OsTypeValues enum definition @@ -1692,19 +1696,20 @@ export type OsTypeValues = { * The constant map of values for OsTypeValues. * @deprecated Use the OSTYPEVALUES_XXXXX constants rather than the OsTypeValues.XXXXX for bundle minification. */ -export const OsTypeValues: OsTypeValues = { - WINDOWS: TMP_OSTYPEVALUES_WINDOWS, - LINUX: TMP_OSTYPEVALUES_LINUX, - DARWIN: TMP_OSTYPEVALUES_DARWIN, - FREEBSD: TMP_OSTYPEVALUES_FREEBSD, - NETBSD: TMP_OSTYPEVALUES_NETBSD, - OPENBSD: TMP_OSTYPEVALUES_OPENBSD, - DRAGONFLYBSD: TMP_OSTYPEVALUES_DRAGONFLYBSD, - HPUX: TMP_OSTYPEVALUES_HPUX, - AIX: TMP_OSTYPEVALUES_AIX, - SOLARIS: TMP_OSTYPEVALUES_SOLARIS, - Z_OS: TMP_OSTYPEVALUES_Z_OS, -}; +export const OsTypeValues: OsTypeValues = + /*#__PURE__*/ createConstMap([ + TMP_OSTYPEVALUES_WINDOWS, + TMP_OSTYPEVALUES_LINUX, + TMP_OSTYPEVALUES_DARWIN, + TMP_OSTYPEVALUES_FREEBSD, + TMP_OSTYPEVALUES_NETBSD, + TMP_OSTYPEVALUES_OPENBSD, + TMP_OSTYPEVALUES_DRAGONFLYBSD, + TMP_OSTYPEVALUES_HPUX, + TMP_OSTYPEVALUES_AIX, + TMP_OSTYPEVALUES_SOLARIS, + TMP_OSTYPEVALUES_Z_OS, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for TelemetrySdkLanguageValues enum definition @@ -1826,15 +1831,16 @@ export type TelemetrySdkLanguageValues = { * The constant map of values for TelemetrySdkLanguageValues. * @deprecated Use the TELEMETRYSDKLANGUAGEVALUES_XXXXX constants rather than the TelemetrySdkLanguageValues.XXXXX for bundle minification. */ -export const TelemetrySdkLanguageValues: TelemetrySdkLanguageValues = { - CPP: TMP_TELEMETRYSDKLANGUAGEVALUES_CPP, - DOTNET: TMP_TELEMETRYSDKLANGUAGEVALUES_DOTNET, - ERLANG: TMP_TELEMETRYSDKLANGUAGEVALUES_ERLANG, - GO: TMP_TELEMETRYSDKLANGUAGEVALUES_GO, - JAVA: TMP_TELEMETRYSDKLANGUAGEVALUES_JAVA, - NODEJS: TMP_TELEMETRYSDKLANGUAGEVALUES_NODEJS, - PHP: TMP_TELEMETRYSDKLANGUAGEVALUES_PHP, - PYTHON: TMP_TELEMETRYSDKLANGUAGEVALUES_PYTHON, - RUBY: TMP_TELEMETRYSDKLANGUAGEVALUES_RUBY, - WEBJS: TMP_TELEMETRYSDKLANGUAGEVALUES_WEBJS, -}; +export const TelemetrySdkLanguageValues: TelemetrySdkLanguageValues = + /*#__PURE__*/ createConstMap([ + TMP_TELEMETRYSDKLANGUAGEVALUES_CPP, + TMP_TELEMETRYSDKLANGUAGEVALUES_DOTNET, + TMP_TELEMETRYSDKLANGUAGEVALUES_ERLANG, + TMP_TELEMETRYSDKLANGUAGEVALUES_GO, + TMP_TELEMETRYSDKLANGUAGEVALUES_JAVA, + TMP_TELEMETRYSDKLANGUAGEVALUES_NODEJS, + TMP_TELEMETRYSDKLANGUAGEVALUES_PHP, + TMP_TELEMETRYSDKLANGUAGEVALUES_PYTHON, + TMP_TELEMETRYSDKLANGUAGEVALUES_RUBY, + TMP_TELEMETRYSDKLANGUAGEVALUES_WEBJS, + ]); diff --git a/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts b/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts index e696ffe49eb..cc87977a825 100644 --- a/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts +++ b/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts @@ -2197,55 +2197,56 @@ export type DbSystemValues = { * The constant map of values for DbSystemValues. * @deprecated Use the DBSYSTEMVALUES_XXXXX constants rather than the DbSystemValues.XXXXX for bundle minification. */ -export const DbSystemValues: DbSystemValues = { - OTHER_SQL: TMP_DBSYSTEMVALUES_OTHER_SQL, - MSSQL: TMP_DBSYSTEMVALUES_MSSQL, - MYSQL: TMP_DBSYSTEMVALUES_MYSQL, - ORACLE: TMP_DBSYSTEMVALUES_ORACLE, - DB2: TMP_DBSYSTEMVALUES_DB2, - POSTGRESQL: TMP_DBSYSTEMVALUES_POSTGRESQL, - REDSHIFT: TMP_DBSYSTEMVALUES_REDSHIFT, - HIVE: TMP_DBSYSTEMVALUES_HIVE, - CLOUDSCAPE: TMP_DBSYSTEMVALUES_CLOUDSCAPE, - HSQLDB: TMP_DBSYSTEMVALUES_HSQLDB, - PROGRESS: TMP_DBSYSTEMVALUES_PROGRESS, - MAXDB: TMP_DBSYSTEMVALUES_MAXDB, - HANADB: TMP_DBSYSTEMVALUES_HANADB, - INGRES: TMP_DBSYSTEMVALUES_INGRES, - FIRSTSQL: TMP_DBSYSTEMVALUES_FIRSTSQL, - EDB: TMP_DBSYSTEMVALUES_EDB, - CACHE: TMP_DBSYSTEMVALUES_CACHE, - ADABAS: TMP_DBSYSTEMVALUES_ADABAS, - FIREBIRD: TMP_DBSYSTEMVALUES_FIREBIRD, - DERBY: TMP_DBSYSTEMVALUES_DERBY, - FILEMAKER: TMP_DBSYSTEMVALUES_FILEMAKER, - INFORMIX: TMP_DBSYSTEMVALUES_INFORMIX, - INSTANTDB: TMP_DBSYSTEMVALUES_INSTANTDB, - INTERBASE: TMP_DBSYSTEMVALUES_INTERBASE, - MARIADB: TMP_DBSYSTEMVALUES_MARIADB, - NETEZZA: TMP_DBSYSTEMVALUES_NETEZZA, - PERVASIVE: TMP_DBSYSTEMVALUES_PERVASIVE, - POINTBASE: TMP_DBSYSTEMVALUES_POINTBASE, - SQLITE: TMP_DBSYSTEMVALUES_SQLITE, - SYBASE: TMP_DBSYSTEMVALUES_SYBASE, - TERADATA: TMP_DBSYSTEMVALUES_TERADATA, - VERTICA: TMP_DBSYSTEMVALUES_VERTICA, - H2: TMP_DBSYSTEMVALUES_H2, - COLDFUSION: TMP_DBSYSTEMVALUES_COLDFUSION, - CASSANDRA: TMP_DBSYSTEMVALUES_CASSANDRA, - HBASE: TMP_DBSYSTEMVALUES_HBASE, - MONGODB: TMP_DBSYSTEMVALUES_MONGODB, - REDIS: TMP_DBSYSTEMVALUES_REDIS, - COUCHBASE: TMP_DBSYSTEMVALUES_COUCHBASE, - COUCHDB: TMP_DBSYSTEMVALUES_COUCHDB, - COSMOSDB: TMP_DBSYSTEMVALUES_COSMOSDB, - DYNAMODB: TMP_DBSYSTEMVALUES_DYNAMODB, - NEO4J: TMP_DBSYSTEMVALUES_NEO4J, - GEODE: TMP_DBSYSTEMVALUES_GEODE, - ELASTICSEARCH: TMP_DBSYSTEMVALUES_ELASTICSEARCH, - MEMCACHED: TMP_DBSYSTEMVALUES_MEMCACHED, - COCKROACHDB: TMP_DBSYSTEMVALUES_COCKROACHDB, -}; +export const DbSystemValues: DbSystemValues = + /*#__PURE__*/ createConstMap([ + TMP_DBSYSTEMVALUES_OTHER_SQL, + TMP_DBSYSTEMVALUES_MSSQL, + TMP_DBSYSTEMVALUES_MYSQL, + TMP_DBSYSTEMVALUES_ORACLE, + TMP_DBSYSTEMVALUES_DB2, + TMP_DBSYSTEMVALUES_POSTGRESQL, + TMP_DBSYSTEMVALUES_REDSHIFT, + TMP_DBSYSTEMVALUES_HIVE, + TMP_DBSYSTEMVALUES_CLOUDSCAPE, + TMP_DBSYSTEMVALUES_HSQLDB, + TMP_DBSYSTEMVALUES_PROGRESS, + TMP_DBSYSTEMVALUES_MAXDB, + TMP_DBSYSTEMVALUES_HANADB, + TMP_DBSYSTEMVALUES_INGRES, + TMP_DBSYSTEMVALUES_FIRSTSQL, + TMP_DBSYSTEMVALUES_EDB, + TMP_DBSYSTEMVALUES_CACHE, + TMP_DBSYSTEMVALUES_ADABAS, + TMP_DBSYSTEMVALUES_FIREBIRD, + TMP_DBSYSTEMVALUES_DERBY, + TMP_DBSYSTEMVALUES_FILEMAKER, + TMP_DBSYSTEMVALUES_INFORMIX, + TMP_DBSYSTEMVALUES_INSTANTDB, + TMP_DBSYSTEMVALUES_INTERBASE, + TMP_DBSYSTEMVALUES_MARIADB, + TMP_DBSYSTEMVALUES_NETEZZA, + TMP_DBSYSTEMVALUES_PERVASIVE, + TMP_DBSYSTEMVALUES_POINTBASE, + TMP_DBSYSTEMVALUES_SQLITE, + TMP_DBSYSTEMVALUES_SYBASE, + TMP_DBSYSTEMVALUES_TERADATA, + TMP_DBSYSTEMVALUES_VERTICA, + TMP_DBSYSTEMVALUES_H2, + TMP_DBSYSTEMVALUES_COLDFUSION, + TMP_DBSYSTEMVALUES_CASSANDRA, + TMP_DBSYSTEMVALUES_HBASE, + TMP_DBSYSTEMVALUES_MONGODB, + TMP_DBSYSTEMVALUES_REDIS, + TMP_DBSYSTEMVALUES_COUCHBASE, + TMP_DBSYSTEMVALUES_COUCHDB, + TMP_DBSYSTEMVALUES_COSMOSDB, + TMP_DBSYSTEMVALUES_DYNAMODB, + TMP_DBSYSTEMVALUES_NEO4J, + TMP_DBSYSTEMVALUES_GEODE, + TMP_DBSYSTEMVALUES_ELASTICSEARCH, + TMP_DBSYSTEMVALUES_MEMCACHED, + TMP_DBSYSTEMVALUES_COCKROACHDB, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for DbCassandraConsistencyLevelValues enum definition @@ -2379,19 +2380,19 @@ export type DbCassandraConsistencyLevelValues = { * @deprecated Use the DBCASSANDRACONSISTENCYLEVELVALUES_XXXXX constants rather than the DbCassandraConsistencyLevelValues.XXXXX for bundle minification. */ export const DbCassandraConsistencyLevelValues: DbCassandraConsistencyLevelValues = - { - ALL: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_ALL, - EACH_QUORUM: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_EACH_QUORUM, - QUORUM: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_QUORUM, - LOCAL_QUORUM: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_LOCAL_QUORUM, - ONE: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_ONE, - TWO: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_TWO, - THREE: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_THREE, - LOCAL_ONE: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_LOCAL_ONE, - ANY: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_ANY, - SERIAL: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_SERIAL, - LOCAL_SERIAL: TMP_DBCASSANDRACONSISTENCYLEVELVALUES_LOCAL_SERIAL, - }; + /*#__PURE__*/ createConstMap([ + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_ALL, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_EACH_QUORUM, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_QUORUM, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_LOCAL_QUORUM, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_ONE, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_TWO, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_THREE, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_LOCAL_ONE, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_ANY, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_SERIAL, + TMP_DBCASSANDRACONSISTENCYLEVELVALUES_LOCAL_SERIAL, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for FaasTriggerValues enum definition @@ -2459,13 +2460,14 @@ export type FaasTriggerValues = { * The constant map of values for FaasTriggerValues. * @deprecated Use the FAASTRIGGERVALUES_XXXXX constants rather than the FaasTriggerValues.XXXXX for bundle minification. */ -export const FaasTriggerValues: FaasTriggerValues = { - DATASOURCE: TMP_FAASTRIGGERVALUES_DATASOURCE, - HTTP: TMP_FAASTRIGGERVALUES_HTTP, - PUBSUB: TMP_FAASTRIGGERVALUES_PUBSUB, - TIMER: TMP_FAASTRIGGERVALUES_TIMER, - OTHER: TMP_FAASTRIGGERVALUES_OTHER, -}; +export const FaasTriggerValues: FaasTriggerValues = + /*#__PURE__*/ createConstMap([ + TMP_FAASTRIGGERVALUES_DATASOURCE, + TMP_FAASTRIGGERVALUES_HTTP, + TMP_FAASTRIGGERVALUES_PUBSUB, + TMP_FAASTRIGGERVALUES_TIMER, + TMP_FAASTRIGGERVALUES_OTHER, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for FaasDocumentOperationValues enum definition @@ -2518,11 +2520,12 @@ export type FaasDocumentOperationValues = { * The constant map of values for FaasDocumentOperationValues. * @deprecated Use the FAASDOCUMENTOPERATIONVALUES_XXXXX constants rather than the FaasDocumentOperationValues.XXXXX for bundle minification. */ -export const FaasDocumentOperationValues: FaasDocumentOperationValues = { - INSERT: TMP_FAASDOCUMENTOPERATIONVALUES_INSERT, - EDIT: TMP_FAASDOCUMENTOPERATIONVALUES_EDIT, - DELETE: TMP_FAASDOCUMENTOPERATIONVALUES_DELETE, -}; +export const FaasDocumentOperationValues: FaasDocumentOperationValues = + /*#__PURE__*/ createConstMap([ + TMP_FAASDOCUMENTOPERATIONVALUES_INSERT, + TMP_FAASDOCUMENTOPERATIONVALUES_EDIT, + TMP_FAASDOCUMENTOPERATIONVALUES_DELETE, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for FaasInvokedProviderValues enum definition @@ -2595,12 +2598,13 @@ export type FaasInvokedProviderValues = { * The constant map of values for FaasInvokedProviderValues. * @deprecated Use the FAASINVOKEDPROVIDERVALUES_XXXXX constants rather than the FaasInvokedProviderValues.XXXXX for bundle minification. */ -export const FaasInvokedProviderValues: FaasInvokedProviderValues = { - ALIBABA_CLOUD: TMP_FAASINVOKEDPROVIDERVALUES_ALIBABA_CLOUD, - AWS: TMP_FAASINVOKEDPROVIDERVALUES_AWS, - AZURE: TMP_FAASINVOKEDPROVIDERVALUES_AZURE, - GCP: TMP_FAASINVOKEDPROVIDERVALUES_GCP, -}; +export const FaasInvokedProviderValues: FaasInvokedProviderValues = + /*#__PURE__*/ createConstMap([ + TMP_FAASINVOKEDPROVIDERVALUES_ALIBABA_CLOUD, + TMP_FAASINVOKEDPROVIDERVALUES_AWS, + TMP_FAASINVOKEDPROVIDERVALUES_AZURE, + TMP_FAASINVOKEDPROVIDERVALUES_GCP, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for NetTransportValues enum definition @@ -2686,15 +2690,16 @@ export type NetTransportValues = { * The constant map of values for NetTransportValues. * @deprecated Use the NETTRANSPORTVALUES_XXXXX constants rather than the NetTransportValues.XXXXX for bundle minification. */ -export const NetTransportValues: NetTransportValues = { - IP_TCP: TMP_NETTRANSPORTVALUES_IP_TCP, - IP_UDP: TMP_NETTRANSPORTVALUES_IP_UDP, - IP: TMP_NETTRANSPORTVALUES_IP, - UNIX: TMP_NETTRANSPORTVALUES_UNIX, - PIPE: TMP_NETTRANSPORTVALUES_PIPE, - INPROC: TMP_NETTRANSPORTVALUES_INPROC, - OTHER: TMP_NETTRANSPORTVALUES_OTHER, -}; +export const NetTransportValues: NetTransportValues = + /*#__PURE__*/ createConstMap([ + TMP_NETTRANSPORTVALUES_IP_TCP, + TMP_NETTRANSPORTVALUES_IP_UDP, + TMP_NETTRANSPORTVALUES_IP, + TMP_NETTRANSPORTVALUES_UNIX, + TMP_NETTRANSPORTVALUES_PIPE, + TMP_NETTRANSPORTVALUES_INPROC, + TMP_NETTRANSPORTVALUES_OTHER, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for NetHostConnectionTypeValues enum definition @@ -2767,13 +2772,14 @@ export type NetHostConnectionTypeValues = { * The constant map of values for NetHostConnectionTypeValues. * @deprecated Use the NETHOSTCONNECTIONTYPEVALUES_XXXXX constants rather than the NetHostConnectionTypeValues.XXXXX for bundle minification. */ -export const NetHostConnectionTypeValues: NetHostConnectionTypeValues = { - WIFI: TMP_NETHOSTCONNECTIONTYPEVALUES_WIFI, - WIRED: TMP_NETHOSTCONNECTIONTYPEVALUES_WIRED, - CELL: TMP_NETHOSTCONNECTIONTYPEVALUES_CELL, - UNAVAILABLE: TMP_NETHOSTCONNECTIONTYPEVALUES_UNAVAILABLE, - UNKNOWN: TMP_NETHOSTCONNECTIONTYPEVALUES_UNKNOWN, -}; +export const NetHostConnectionTypeValues: NetHostConnectionTypeValues = + /*#__PURE__*/ createConstMap([ + TMP_NETHOSTCONNECTIONTYPEVALUES_WIFI, + TMP_NETHOSTCONNECTIONTYPEVALUES_WIRED, + TMP_NETHOSTCONNECTIONTYPEVALUES_CELL, + TMP_NETHOSTCONNECTIONTYPEVALUES_UNAVAILABLE, + TMP_NETHOSTCONNECTIONTYPEVALUES_UNKNOWN, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for NetHostConnectionSubtypeValues enum definition @@ -3006,29 +3012,30 @@ export type NetHostConnectionSubtypeValues = { * The constant map of values for NetHostConnectionSubtypeValues. * @deprecated Use the NETHOSTCONNECTIONSUBTYPEVALUES_XXXXX constants rather than the NetHostConnectionSubtypeValues.XXXXX for bundle minification. */ -export const NetHostConnectionSubtypeValues: NetHostConnectionSubtypeValues = { - GPRS: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_GPRS, - EDGE: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EDGE, - UMTS: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_UMTS, - CDMA: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_CDMA, - EVDO_0: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EVDO_0, - EVDO_A: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EVDO_A, - CDMA2000_1XRTT: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_CDMA2000_1XRTT, - HSDPA: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_HSDPA, - HSUPA: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_HSUPA, - HSPA: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_HSPA, - IDEN: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_IDEN, - EVDO_B: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EVDO_B, - LTE: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_LTE, - EHRPD: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EHRPD, - HSPAP: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_HSPAP, - GSM: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_GSM, - TD_SCDMA: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_TD_SCDMA, - IWLAN: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_IWLAN, - NR: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_NR, - NRNSA: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_NRNSA, - LTE_CA: TMP_NETHOSTCONNECTIONSUBTYPEVALUES_LTE_CA, -}; +export const NetHostConnectionSubtypeValues: NetHostConnectionSubtypeValues = + /*#__PURE__*/ createConstMap([ + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_GPRS, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EDGE, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_UMTS, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_CDMA, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EVDO_0, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EVDO_A, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_CDMA2000_1XRTT, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_HSDPA, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_HSUPA, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_HSPA, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_IDEN, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EVDO_B, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_LTE, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_EHRPD, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_HSPAP, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_GSM, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_TD_SCDMA, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_IWLAN, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_NR, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_NRNSA, + TMP_NETHOSTCONNECTIONSUBTYPEVALUES_LTE_CA, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for HttpFlavorValues enum definition @@ -3159,10 +3166,11 @@ export type MessagingDestinationKindValues = { * The constant map of values for MessagingDestinationKindValues. * @deprecated Use the MESSAGINGDESTINATIONKINDVALUES_XXXXX constants rather than the MessagingDestinationKindValues.XXXXX for bundle minification. */ -export const MessagingDestinationKindValues: MessagingDestinationKindValues = { - QUEUE: TMP_MESSAGINGDESTINATIONKINDVALUES_QUEUE, - TOPIC: TMP_MESSAGINGDESTINATIONKINDVALUES_TOPIC, -}; +export const MessagingDestinationKindValues: MessagingDestinationKindValues = + /*#__PURE__*/ createConstMap([ + TMP_MESSAGINGDESTINATIONKINDVALUES_QUEUE, + TMP_MESSAGINGDESTINATIONKINDVALUES_TOPIC, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for MessagingOperationValues enum definition @@ -3205,10 +3213,11 @@ export type MessagingOperationValues = { * The constant map of values for MessagingOperationValues. * @deprecated Use the MESSAGINGOPERATIONVALUES_XXXXX constants rather than the MessagingOperationValues.XXXXX for bundle minification. */ -export const MessagingOperationValues: MessagingOperationValues = { - RECEIVE: TMP_MESSAGINGOPERATIONVALUES_RECEIVE, - PROCESS: TMP_MESSAGINGOPERATIONVALUES_PROCESS, -}; +export const MessagingOperationValues: MessagingOperationValues = + /*#__PURE__*/ createConstMap([ + TMP_MESSAGINGOPERATIONVALUES_RECEIVE, + TMP_MESSAGINGOPERATIONVALUES_PROCESS, + ]); /* ---------------------------------------------------------------------------------------------------------- * Constant values for RpcGrpcStatusCodeValues enum definition @@ -3459,7 +3468,8 @@ export type MessageTypeValues = { * The constant map of values for MessageTypeValues. * @deprecated Use the MESSAGETYPEVALUES_XXXXX constants rather than the MessageTypeValues.XXXXX for bundle minification. */ -export const MessageTypeValues: MessageTypeValues = { - SENT: TMP_MESSAGETYPEVALUES_SENT, - RECEIVED: TMP_MESSAGETYPEVALUES_RECEIVED, -}; +export const MessageTypeValues: MessageTypeValues = + /*#__PURE__*/ createConstMap([ + TMP_MESSAGETYPEVALUES_SENT, + TMP_MESSAGETYPEVALUES_RECEIVED, + ]); diff --git a/scripts/semconv/templates/SemanticAttributes.ts.j2 b/scripts/semconv/templates/SemanticAttributes.ts.j2 index 335eb850615..0bbb4ebf7ce 100644 --- a/scripts/semconv/templates/SemanticAttributes.ts.j2 +++ b/scripts/semconv/templates/SemanticAttributes.ts.j2 @@ -162,15 +162,39 @@ export type {{class_name}} = { {%- endfor %} } +{%- set enumMap = namespace(useCreateConst = false) %} +{%- if type == "string" %} + {%- set enumMap.useCreateConst = true %} + {%- for member in attribute.attr_type.members if attribute.is_local and not attribute.ref %} + {%- if (member.member_id | to_const_name) != ( member.value | to_const_name) %} + {%- set enumMap.useCreateConst = false %} + {%- endif %} + {%- endfor %} +{%- endif %} + /** * The constant map of values for {{class_name}}. * @deprecated Use the {{class_name | upper}}_XXXXX constants rather than the {{class_name}}.XXXXX for bundle minification. */ +{%- if enumMap.useCreateConst == true %} +export const {{class_name}}:{{class_name}} = /*#__PURE__*/createConstMap<{{class_name}}>([ +{%- for member in attribute.attr_type.members if attribute.is_local and not attribute.ref %} + {%- if (member.member_id | to_const_name) == ( member.value | to_const_name) %} + TMP_{{class_name|upper}}_{{ member.member_id | to_const_name }}, + {%- else %} + {#- Cause some invalid content to be generated to force a build error #} + !! Invalid mapping for {{class_name}}.{{ member.member_id }}:{{ member.value }}. The value is not a valid string. + {{ member.member_id | to_const_name }}: TMP_{{class_name|upper}}_{{ member.member_id | to_const_name }}, + {%- endif %} +{%- endfor %} +]); +{%- else %} export const {{class_name}}:{{class_name}} = { - {%- for member in attribute.attr_type.members if attribute.is_local and not attribute.ref %} +{%- for member in attribute.attr_type.members if attribute.is_local and not attribute.ref %} {{ member.member_id | to_const_name }}: TMP_{{class_name|upper}}_{{ member.member_id | to_const_name }}, - {%- endfor %} - }; +{%- endfor %} +}; +{%- endif %} {% endif %} {% endif %}