-
Notifications
You must be signed in to change notification settings - Fork 0
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
EMB-3907 Android side for tracer provider #36
base: feature-react-native-tracer-provider
Are you sure you want to change the base?
Changes from 1 commit
24583da
ed35345
da9e062
a867da7
4d616d5
1ae3190
6f12ff8
3b1a088
3f6ba0e
b9acad8
48d2569
eb883b8
d747459
5c02c5b
d1112ad
ff273ef
fbe0dc8
812c675
550c79e
3ef8ceb
7bc73a7
1175f53
fea24ae
be45048
4cbb2c8
0c5258b
e26e52f
efd4e59
1e109a0
d67d409
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* 'use strict'; */ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { | ||
context, | ||
SpanKind, | ||
SpanStatusCode, | ||
trace, | ||
Tracer, | ||
} from "@opentelemetry/api"; | ||
|
||
export function generateTestSpans(tracer: Tracer) { | ||
const span1 = tracer.startSpan("test-1"); | ||
const span2 = tracer.startSpan("test-2", { kind: SpanKind.CLIENT }); | ||
const span3 = tracer.startSpan("test-3"); | ||
// Not ended so shouldn't be part of the output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This creates an implicit dependency where generateTestSpans needs to be called before generateNestedSpans right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they should be independent the idea would be to call generateTestSpans followed by ending the session so the payload can be verified then separately in a following test we'll call generateNestedSpans and end that session so the payload shouldn't include data from the previous run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah OK. That makes sense. Is that documented or implicit anywhere that I missed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me add some comments to this file, I wasn't sure if I was going to stick with this approach as there were 2 options:
|
||
tracer.startSpan("test-4"); | ||
|
||
// Set some attributes | ||
span1.setAttributes({ | ||
"string-attr": "my-attr", | ||
"number-attr": 22, | ||
}); | ||
span1.setAttribute("bool-attr", true); | ||
|
||
// Misc updates | ||
span1.setStatus({ code: SpanStatusCode.OK, message: "ok span" }); | ||
span1.updateName("test-1-updated"); | ||
|
||
// Make sure isRecording reports correctly | ||
if (span1.isRecording()) { | ||
span1.end(); | ||
} | ||
if (span1.isRecording()) { | ||
span1.setAttribute("after-recording", "should not exist"); | ||
} | ||
|
||
// Add some span events | ||
span2.addEvent("test-2-event-1"); | ||
span2.addEvent("test-2-event-2", 1700001002000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these constant values have specific meanings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, just arbitrary values that can we can assert got added later in the test |
||
span2.addEvent( | ||
"test-2-event-3", | ||
{ "test-2-event-attr": "my-event-attr" }, | ||
1700009002000 | ||
); | ||
span2.end(new Date("2099-01-01T00:00:00Z")); | ||
|
||
// Add some links | ||
span3.addLink({ context: span1.spanContext() }); | ||
span3.addLinks([ | ||
{ | ||
context: span2.spanContext(), | ||
attributes: { "test-3-link-attr": "my-link-attr" }, | ||
}, | ||
]); | ||
span3.recordException({ message: "span exception" }); | ||
span3.end(); | ||
} | ||
|
||
export function generateNestedSpans(tracer: Tracer) { | ||
const span1 = tracer.startSpan("test-1"); | ||
const span1Context = trace.setSpan(context.active(), span1); | ||
const span2 = tracer.startSpan( | ||
"test-2", | ||
{ attributes: { "test-2-attr": "my-attr" } }, | ||
span1Context | ||
); | ||
const span3 = tracer.startSpan( | ||
"test-3", | ||
{ attributes: { "test-3-attr": "my-attr" }, root: true }, | ||
span1Context | ||
); | ||
|
||
tracer.startActiveSpan("test-4", (span4) => { | ||
const span5 = tracer.startSpan("test-5"); | ||
span5.end(); | ||
|
||
span4.end(); | ||
}); | ||
span1.end(); | ||
span2.end(); | ||
span3.end(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { driver } from '@wdio/globals'; | ||
import { driver } from "@wdio/globals"; | ||
|
||
import { getSessionPayloads } from '../helpers/embrace_server'; | ||
import { getSessionMessages } from "../helpers/embrace_server"; | ||
|
||
describe('Sessions', () => { | ||
it('should be recorded as foreground', async () => { | ||
const endSession = await driver.$('~END SESSION'); | ||
describe("Sessions", () => { | ||
it("should be recorded as foreground", async () => { | ||
const endSession = await driver.$("~END SESSION"); | ||
await endSession.click(); | ||
|
||
const sessionPayloads = await getSessionPayloads(); | ||
const sessionPayloads = await getSessionMessages(); | ||
|
||
expect(sessionPayloads).toHaveLength(1); | ||
if (sessionPayloads.length > 0) { | ||
expect(sessionPayloads[0].as).toBe('foreground'); | ||
expect(sessionPayloads[0].s.as).toBe("foreground"); | ||
} | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random thought: is it possible to construct a span where the end-time is before the start-time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good point I can add an example of that to see how it's handled, I believe the interface allows that so it would be up to our implementation how it would treat that case