{"record":{"id":"7780aaf7a7d35e26","repo":"pinpoint-apm/pinpoint","slug":"span-event-start-time-is-not-set","errorCode":null,"errorMessage":"span event start time is not set","messagePattern":"span event start time is not set","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanEventBo.java","lineNumber":153,"sourceCode":"            throw new IllegalArgumentException(\"absolute start/end time is only supported for TRACE_V3 span events\");\n        }\n        if (endTime < startTime) {\n            throw new IllegalArgumentException(\"span event end time must be greater than or equal to start time\");\n        }\n\n        this.startTime = startTime;\n        this.endTime = endTime;\n        this.startElapsed = startElapsedMillis;\n        this.endElapsed = (int) TimeUnit.NANOSECONDS.toMillis(endTime - startTime);\n    }\n\n    public boolean hasStartTime() {\n        return Byte.toUnsignedInt(version) == SpanVersion.TRACE_V3 && startTime != DEFAULT_START_TIME;\n    }\n\n    public long getStartTimeNanos() {\n        if (!hasStartTime()) {\n            throw new IllegalStateException(\"span event start time is not set\");\n        }\n        return startTime;\n    }\n\n    public boolean hasEndTime() {\n        return Byte.toUnsignedInt(version) == SpanVersion.TRACE_V3 && endTime != DEFAULT_END_TIME;\n    }\n\n    public long getEndTimeNanos() {\n        if (!hasEndTime()) {\n            throw new IllegalStateException(\"span event end time is not set\");\n        }\n        return endTime;\n    }\n\n    public int getServiceType() {\n        return serviceType;\n    }","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanEventBo.java#L135-L171","documentation":"getStartTimeNanos returns the absolute start time in nanos, which only exists for TRACE_V3 span events whose startTime was explicitly set (not the DEFAULT_START_TIME sentinel). If either condition fails, the start time is not available and the method throws IllegalStateException instead of returning a meaningless value.","triggerScenarios":"Calling getStartTimeNanos on a span event that is not TRACE_V3, or a V3 event built via the relative-elapsed overload where startTime was never set (still DEFAULT_START_TIME).","commonSituations":"Rendering/serialization code (e.g. startTime in the Web UI DTO mapper) running over V2 events; callers skipping the hasStartTime() check; partially initialized V3 events after the relative-time decode path.","solutions":["Call hasStartTime() before getStartTimeNanos() and fall back to computed time (parent start + startElapsed) when false","Ensure TRACE_V3 events are always built via the absolute-time setTraceTime overload","Check the event's trace version and route V2 events through the elapsed-millis code path"],"exampleFix":"// before\nlong start = spanEventBo.getStartTimeNanos();\n// after\nlong start = spanEventBo.hasStartTime()\n    ? spanEventBo.getStartTimeNanos()\n    : parentStartTime + TimeUnit.MILLISECONDS.toNanos(spanEventBo.getStartElapsed());","handlingStrategy":"type-guard","validationCode":"long start = spanEventBo.hasStartTime()\n    ? spanEventBo.getStartTimeNanos()\n    : fallbackStartTime(spanEventBo);","typeGuard":"boolean canReadStartTime(SpanEventBo e) {\n    return e.hasStartTime();\n}","tryCatchPattern":"try {\n    return spanEventBo.getStartTimeNanos();\n} catch (IllegalStateException e) {\n    return parentStartTime + TimeUnit.MILLISECONDS.toNanos(spanEventBo.getStartElapsed());\n}","preventionTips":["Check hasStartTime()/hasEndTime() before reading absolute nanos","Build V3 events via the absolute-time setTraceTime overload so fields are always populated","Route non-V3 events through elapsed-millis logic instead"],"tags":["java","illegal-state","trace-versioning"],"backgroundTag":"invalid-state-transition","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}