googleapis / googleapis/google-cloud-node

Incorrect `nanos` in fetched log entry timestamps

Open
#7,581 1 comment 0 reactions 0 assignees View on GitHub
api: logging priority: p2 type: bug
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

`timestamp.nanos` is incorrect in the entries fetched using `getEntries`. The prevents me from generating a direct link to a pinned log entry for Logs Explorer. Taking the example of this entry from Logs Explorer:

Image

`getEntries` will return an entry with `timestamp.nanos = 565000057` instead of `565396000`. Accessing the raw response (available as the 3rd item in the result array) yields the correct nanos.

#### Steps to reproduce

1. Load log entries with:

```typescript
const [result, , res] = await logging.getEntries({ filter: `myfilter` })
```

2. Log the entries in `result` and `res`

### Structured json

```typescript
console.log(result[0].toStructuredJSON())

{
timestamp: { seconds: 1738936802, nanos: 565000057 }
}
```

### JSON

```typescript
console.log(result[0].toJSON())

{
timestamp: { seconds: 1738936802, nanos: 565000057 }
}
```

### Printing timestamp itself

```typescript
console.log(result[0].metadata.timestamp)

"2025-02-07T14:00:02.565Z"
```

### Raw response (correct)

```typescript
console.log(res.entries[0].timestamp)

{ "seconds":"1738936802", "nanos":565396000 }
```

### Actual timestamp in Logs Explorer

```
2025-02-07T14:00:02.565396Z
```

#### Environment details

- OS: macOS Sequoia 15.3 (24D60)
- Node.js version: v22.13.1
- npm version: 10.9.2
- `@google-cloud/logging` version: 11.2.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.