implement span apis, tti log and update Capture#87
Conversation
package.json
Outdated
| "metro-config": "^0.80.12", | ||
| "metro-resolver": "^0.80.12" | ||
| "metro-resolver": "^0.80.12", | ||
| "uuid": "^11.1.0" |
There was a problem hiding this comment.
Was going to say we could probably use crypto.randomUUID() instead, but I don't think react native supports that.
packages/react-native/src/index.tsx
Outdated
| } | ||
|
|
||
| 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]; |
There was a problem hiding this comment.
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.
packages/react-native/src/span.ts
Outdated
| ): Span { | ||
| let span_uuid = uuidv4(); | ||
|
|
||
| let start_span_fields = { |
There was a problem hiding this comment.
| let start_span_fields = { | |
| let startSpanFields = { |
|
Regarding sharing between electron/react-native: The "proper" way to do it would be to publish a new npm package. Honestly, It goes against the 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,) => { ... } |
Co-authored-by: Jackson Hardaker <7596320+jacksonhardaker@users.noreply.github.com> Signed-off-by: Snow Pettersen <snow.pettersen@gmail.com>
…into span-tti-update
@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