Skip to content

implement span apis, tti log and update Capture#87

Closed
snowp wants to merge 14 commits intomainfrom
span-tti-update
Closed

implement span apis, tti log and update Capture#87
snowp wants to merge 14 commits intomainfrom
span-tti-update

Conversation

@snowp
Copy link
Copy Markdown
Contributor

@snowp snowp commented Apr 25, 2025

@jacksonhardaker I'll probably need your help to figure out how to a) get tests working and b) figure out how to share this JS-based span implementation between RN and Electron, since it seems like we should be able to use this in both places if we can abstract out the actual log call somehow and c) how to get tests working

package.json Outdated
"metro-config": "^0.80.12",
"metro-resolver": "^0.80.12"
"metro-resolver": "^0.80.12",
"uuid": "^11.1.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was going to say we could probably use crypto.randomUUID() instead, but I don't think react native supports that.

}

export function logAt(log_level: LogLevel, message: string, fields?: SerializableLogFields): void {
const level = { 'trace': 0, 'debug': 1, 'info': 2, 'warn': 3, 'error': 4 }[log_level];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Pull this out of the function scope as a const so it doesn't need to be initialized every time the function is called.

): Span {
let span_uuid = uuidv4();

let start_span_fields = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let start_span_fields = {
let startSpanFields = {

@jacksonhardaker
Copy link
Copy Markdown
Contributor

jacksonhardaker commented Apr 25, 2025

Regarding sharing between electron/react-native:

The "proper" way to do it would be to publish a new npm package. Honestly, @bitdrift/core would be a better name for this, but since that's taken maybe something dumb like @bitdrift/shared.

It goes against the nx philosophy, but there might be a way we can hack together having a shared lib in a distinct nx lib, and bundle it at build time with react-native/electron. I can play around with this if you like.

Regardless of which way we go about it, I'd have the "shared" library just expose functions using a factory pattern so that the log function can be abstracted i.e.

const buildStartSpan = (log: LogFunction) => ( 
  name: string,
  level: LogLevel,
  fields?: SerializableLogFields,
  startTimeInterval?: number,
  parentSpanID?: string,) => { ... }

@snowp snowp closed this May 9, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants