Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add scripts/gen-semconv-ts.js to help generate semconv.ts files for unstable semconv consts #2669

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

trentm
Copy link
Contributor

@trentm trentm commented Jan 18, 2025

Refs: https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv


Now that we've established how we want packages to use unstable semconv definitions, we are starting to get PRs adding a local copy of these: #2664, #2668

It is helpful to script this to: make it faster, encourage a common pattern for these local copies, avoid cut 'n paste errors.

An example run of this (for #2668) looks like this:

% ./scripts/gen-semconv-ts.js detectors/node/opentelemetry-resource-detector-aws
Found import of 31 unstable semconv definitions.
Generated "detectors/node/opentelemetry-resource-detector-aws/src/semconv.ts".
Running 'npx eslint --fix src/semconv.ts' to fix formatting.

It will also warn/error on attempts to put stable semconv exports in there. That looks like this:

% ../../../scripts/gen-semconv-ts.js
gen-semconv-ts warning: ./src/detectors/AwsBeanstalkDetectorSync.ts: 'ATTR_SERVICE_NAME' export is available on the stable "@opentelemetry/semantic-conventions" entry-point. This definition will not be included in the generated semconv.ts. Instead use:
    import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
gen-semconv-ts warning: ./src/detectors/AwsBeanstalkDetectorSync.ts: 'ATTR_SERVICE_VERSION' export is available on the stable "@opentelemetry/semantic-conventions" entry-point. This definition will not be included in the generated semconv.ts. Instead use:
    import { ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
Found import of 31 unstable semconv definitions.
Generated "src/semconv.ts".

@trentm trentm self-assigned this Jan 18, 2025
@trentm trentm requested a review from a team as a code owner January 18, 2025 00:54
trentm added a commit to garysassano/opentelemetry-js-contrib that referenced this pull request Jan 18, 2025
Copy link

codecov bot commented Jan 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.80%. Comparing base (4fb610d) to head (4dede11).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2669   +/-   ##
=======================================
  Coverage   90.80%   90.80%           
=======================================
  Files         170      170           
  Lines        8070     8070           
  Branches     1646     1646           
=======================================
  Hits         7328     7328           
  Misses        742      742           

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant