Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Commit 595e6b9

Browse files
fix: spanId fixes (#15)
* some testing things * get coverage data * release: bump to 0.0.8 * Update lib/utils.js Co-authored-by: Mitchell Borrego <mitchell@codecov.io> * Update lib/utils.js Co-authored-by: Mitchell Borrego <mitchell@codecov.io> Co-authored-by: Mitchell Borrego <mitchell@codecov.io>
1 parent 9aac5cc commit 595e6b9

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

lib/utils.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ class CoverageStorageManager {
5858
}
5959

6060
getCoverageFromFile(filename) {
61-
const rawdata = fs.readFileSync(path.join(covdir, filename));
61+
if (typeof filename !== "string") {
62+
return null
63+
}
64+
const rawdata = fs.readFileSync(path.join(covdir, filename), { encoding: "utf8" });
6265
const covdata = JSON.parse(rawdata);
6366
return parseCoverageObj(covdata);
6467
}
@@ -171,7 +174,7 @@ class CodecovExporter {
171174
for (const spanKey in spans) {
172175
const span = spans[spanKey];
173176
let coverageData = this.storageManager.popSpanCoverage(
174-
span.spanContext.spanId
177+
span.spanContext().spanId
175178
);
176179
if (coverageData) {
177180
let processedCoverageData =
@@ -197,6 +200,7 @@ class CodecovExporter {
197200
if (trackedSpans) {
198201
this.submitCoverageData(
199202
trackedSpans,
203+
this.code,
200204
(data) => {
201205
// Done on purpose to check that we are calling
202206
// this callback right
@@ -233,7 +237,7 @@ class CodecovExporter {
233237
req.end();
234238
}
235239

236-
submitCoverageData(trackedSpans, callback) {
240+
submitCoverageData(trackedSpans, code, callback) {
237241
const data = JSON.stringify({
238242
profiling: code,
239243
});
@@ -285,13 +289,10 @@ class CodecovSpanProcessor {
285289
}
286290

287291
_idFromSpan(span) {
288-
return span.spanContext.spanId;
292+
return span.spanContext().spanId;
289293
}
290294

291295
_shouldSampleSpan(span) {
292-
if (span.instrumentationLibrary.name !== "@opentelemetry/plugin-http") {
293-
return false;
294-
}
295296
if (this.filters) {
296297
if (
297298
this.filters.allowedSpanKinds &&
@@ -322,10 +323,10 @@ class CodecovSpanProcessor {
322323
// up after that since we're going to clear it onStart. Also relinquish
323324
// the lock so we can capture another
324325
onEnd(span) {
325-
if (span.spanContext.spanId == this.lock) {
326+
if (span.spanContext().spanId == this.lock) {
326327
if (this.tracked) {
327328
this.storageManager.stopCollectingAndSaveCoverage(
328-
span.spanContext.spanId
329+
span.spanContext().spanId
329330
);
330331
this.tracked = false;
331332
}
@@ -341,4 +342,4 @@ module.exports = {
341342
CoverageMappingManager,
342343
CodecovSpanProcessor,
343344
parseCoverageObj
344-
};
345+
};

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codecov/node-codecov-opentelemetry",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"license": "MIT",
55
"description": "",
66
"main": "lib/runtime-insights.js",

0 commit comments

Comments
 (0)