GoogleCloudPlatform / opentelemetry-operations-js

This repository is home to Google Cloud Exporters (Trace and Monitoring) for OpenTelemetry Node.js Project (https://github.com/open-telemetry/opentelemetry-js)
Apache License 2.0
67 stars 63 forks source link

fix(trace-exporter): include protos.json in the npm pack tarball #769

Closed aabmass closed 1 week ago

aabmass commented 1 week ago

This fixes the issue of https://github.com/GoogleCloudPlatform/opentelemetry-operations-js/issues/768 but I will leave it open until I make a new patch release

NPM pack now includes the protos.json in the tarball:

$ npm pack
npm notice
npm notice 📦  @google-cloud/opentelemetry-cloud-trace-exporter@2.4.0
npm notice === Tarball Contents ===
npm notice 11.4kB  LICENSE
npm notice 4.3kB   README.md
npm notice 117.9kB build/protos/protos.json
npm notice 1.5kB   build/src/external-types.d.ts
npm notice 707B    build/src/external-types.js
npm notice 59B     build/src/index.d.ts
npm notice 1.5kB   build/src/index.js
npm notice 1.2kB   build/src/trace.d.ts
npm notice 6.0kB   build/src/trace.js
npm notice 268B    build/src/transform.d.ts
npm notice 8.6kB   build/src/transform.js
npm notice 3.1kB   build/src/types.d.ts
npm notice 3.1kB   build/src/types.js
npm notice 40B     build/src/version.d.ts
npm notice 842B    build/src/version.js
npm notice 2.1kB   package.json
npm notice === Tarball Details ===
npm notice name:          @google-cloud/opentelemetry-cloud-trace-exporter
npm notice version:       2.4.0
npm notice filename:      google-cloud-opentelemetry-cloud-trace-exporter-2.4.0.tgz
npm notice package size:  20.7 kB
npm notice unpacked size: 162.4 kB
npm notice shasum:        e2015c681dc29168ae44b86a8a75f9507fa7a75f
npm notice integrity:     sha512-8AvliiVQ80xIc[...]TbipPBJsLM4cA==
npm notice total files:   16
npm notice
google-cloud-opentelemetry-cloud-trace-exporter-2.4.0.tgz

Testing it

I also verified by installing this tarball and requiring the package now works:

$ npm init -y
Wrote to /path/package.json:

{
  "name": "testnpm",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

aaronabbott@aaronabbott2:~/tmp/testnpm$ npm install ~/repo/opentelemetry-operations-js/packages/opentelemetry-cloud-trace-exporter/google-cloud-opentelemetry-cloud-trace-exporter-2.4.0.tgz

added 64 packages, and audited 65 packages in 2s

7 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
aaronabbott@aaronabbott2:~/tmp/testnpm$ node
Welcome to Node.js v22.6.0.
Type ".help" for more information.
> let {TraceExporter} = require('@google-cloud/opentelemetry-cloud-trace-exporter');
undefined
> new TraceExporter;
TraceExporter {
  ...
}
codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.72%. Comparing base (7f1ee19) to head (39b9457). Report is 50 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #769 +/- ## ======================================= Coverage 97.72% 97.72% ======================================= Files 18 18 Lines 703 704 +1 Branches 136 136 ======================================= + Hits 687 688 +1 Misses 16 16 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

dashpole commented 1 week ago

Curious how you caught this. Did you get an automated alert? Or did we get lucky and you just happened to check?

aabmass commented 1 week ago

When I was running the release steps, the npm pack output shows and I realized we may have forgotten to include it in the tarball. I took a closer look and it was indeed missing.

In terms of automated check for this, we could add a smoke test that uses the real tarballs instead of npm workspaces symlinks–unfortunately npm workspaces don't respect the files option.