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

Incorrect span timestamp for node version 8.11.4 to 8.10.0 #2834

Closed
svetlanabrennan opened this issue Mar 15, 2022 · 4 comments
Closed

Incorrect span timestamp for node version 8.11.4 to 8.10.0 #2834

svetlanabrennan opened this issue Mar 15, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@svetlanabrennan
Copy link
Contributor

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

    "@opentelemetry/api": "^1.0.4",
    "@opentelemetry/auto-instrumentations-node": "^0.27.4",
    "@opentelemetry/exporter-trace-otlp-proto": "^0.27.0",
    "@opentelemetry/resources": "^1.0.1",
    "@opentelemetry/sdk-node": "^0.27.0",
    "@opentelemetry/semantic-conventions": "^1.0.1",

What version of Node are you using?

v8.11.4 but this issue exists for versions 8.11.4 to 8.10.0

Please provide the code you used to setup the OpenTelemetry SDK

// tracing.js file

const { v4: uuidv4 } = require("uuid");
const process = require("process");
const opentelemetry = require("@opentelemetry/sdk-node");
const { getNodeAutoInstrumentations } = require("@opentelemetry/auto-instrumentations-node");
const { Resource } = require("@opentelemetry/resources");
const { SemanticResourceAttributes } = require("@opentelemetry/semantic-conventions");
const { OTLPTraceExporter } = require("@opentelemetry/exporter-trace-otlp-proto");
const api = require("@opentelemetry/api");

api.diag.setLogger(
  new api.DiagConsoleLogger(),
  api.DiagLogLevel.DEBUG,
);

const resource = new Resource({
  [SemanticResourceAttributes.SERVICE_NAME]: "OpenTelemetry-Node.JS-Example",
  [SemanticResourceAttributes.SERVICE_INSTANCE_ID]: uuidv4(),
});

const instrumentations = [getNodeAutoInstrumentations()];

const traceExporter = new OTLPTraceExporter();

const sdk = new opentelemetry.NodeSDK({
  resource,
  traceExporter,
  instrumentations,
});

sdk
  .start()
  .then(() => console.log("Tracing initialized"))
  .catch((error) => console.log("Error initializing tracing", error));
  
  process.on("SIGTERM", () => {
  sdk
    .shutdown()
    .then(() => console.log("Tracing terminated"))
    .catch((error) => console.log("Error terminating tracing", error))
    .finally(() => process.exit(0));
});

What did you do?

Use node v8.11.4. Start the tracing file. Generate some spans. You'll notice that the startTime and endTime are incorrect.

What did you expect to see?

Spans with the correct timestamp.

startTime: [ 1647035771, 978362903 ]
endTime: [ 1647035771, 980129598 ]

What did you see instead?

Spans with incorrect timestamps.

startTime: [ 188136, 198357939 ]
endTime: [ 188136, 198527012 ]

Additional context

Span timestamps (start and end times) between the two versions:

// 8.11.4 generated span timestamp:
startTime: [ 188136, 198357939 ]
endTime: [ 188136, 198527012 ]

// node v16.14.0 generated span timestamp:
startTime: [ 1647035771, 978362903 ]
endTime: [ 1647035771, 980129598 ],
@svetlanabrennan svetlanabrennan added the bug Something isn't working label Mar 15, 2022
@svetlanabrennan
Copy link
Contributor Author

It looks like the startTime and endTime are set here which is using perf_hooks that calls performance.timeOrigin.

There was an node issue opened about performance.timeOrigin which was brought up in another otel-js issue by @Flarna that a fix for this issue was backported to Node 8.12.0

So if performance.timeOrigin is only correct for v8.12.0 and above, should we update the supported runtimes in the otel-js readme to say 8.12.0 instead of 8.5.0?

@dyladan
Copy link
Member

dyladan commented Mar 17, 2022

So if performance.timeOrigin is only correct for v8.12.0 and above, should we update the supported runtimes in the otel-js readme to say 8.12.0 instead of 8.5.0?

Probably. I know at least @rauno56 was in support of dropping node 8 support completely anyway.

@rauno56
Copy link
Member

rauno56 commented Mar 23, 2022

Discussed this in SIG meeting - the docs need to be updated to state support from node 8.12 and up.

@rauno56
Copy link
Member

rauno56 commented Mar 30, 2022

Fixed in #2860

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants