Skip to content
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

[ci-visibility] Link CI Visibility and RUM #1192

Merged
merged 15 commits into from
Jan 3, 2022

Conversation

juan-fernandez
Copy link
Contributor

@juan-fernandez juan-fernandez commented Dec 1, 2021

Motivation

Link RUM and CI Visibility through the cypress instrumentation.

This requires changes to the cypress instrumentation in dd-trace-js: DataDog/dd-trace-js#1706

Related event format update: DataDog/rum-events-format#49 and DataDog/rum-events-format#50

Changes

  • Read from window.Cypress, which is available under cypress tests, and pass info as context.

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@bits-bot
Copy link

bits-bot commented Dec 1, 2021

CLA assistant check
All committers have signed the CLA.

packages/rum-core/src/domain/assembly.ts Outdated Show resolved Hide resolved
packages/rum-core/src/domain/assembly.ts Outdated Show resolved Hide resolved
packages/rum-core/src/domain/assembly.ts Outdated Show resolved Hide resolved
@@ -96,9 +99,10 @@ export function startRumAssembly(
date: timeStampNow(),
service: configuration.service,
session: {
type: syntheticsContext ? SessionType.SYNTHETICS : SessionType.USER,
type: syntheticsContext ? SessionType.SYNTHETICS : ciContext ? SessionType.CITEST : SessionType.USER,
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to submit this new type in rum-event-format.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a test for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR in rum-event-format: DataDog/rum-events-format#49

packages/rum-core/src/domain/ciTestContext.ts Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2021

Codecov Report

Merging #1192 (d434d5e) into main (433202e) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1192      +/-   ##
==========================================
+ Coverage   89.01%   89.03%   +0.01%     
==========================================
  Files         101      102       +1     
  Lines        4324     4330       +6     
  Branches      988      990       +2     
==========================================
+ Hits         3849     3855       +6     
  Misses        475      475              
Impacted Files Coverage Δ
packages/rum-core/src/rawRumEvent.types.ts 100.00% <ø> (ø)
packages/rum-core/src/domain/assembly.ts 100.00% <100.00%> (ø)
packages/rum-core/src/domain/ciTestContext.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 433202e...d434d5e. Read the comment docs.

@juan-fernandez juan-fernandez force-pushed the juan-fernandez/civisibility-cypress-poc branch from 00546e0 to a3f4775 Compare December 9, 2021 10:43
@juan-fernandez juan-fernandez marked this pull request as ready for review December 9, 2021 10:46
@juan-fernandez juan-fernandez requested a review from a team as a code owner December 9, 2021 10:46
@juan-fernandez
Copy link
Contributor Author

this should be ready for another look @bcaudan

@juan-fernandez juan-fernandez changed the title [ci-visibility] CI Visibility - RUM PoC [ci-visibility] CI Visibility - RUM Dec 9, 2021
@juan-fernandez juan-fernandez changed the title [ci-visibility] CI Visibility - RUM [ci-visibility] Link CI Visibility and RUM Dec 9, 2021
@juan-fernandez
Copy link
Contributor Author

a couple of unit tests are failing, I'm on it

@juan-fernandez
Copy link
Contributor Author

a couple of unit tests are failing, I'm on it

they should be fixed

@@ -301,3 +302,19 @@ export function cleanupSyntheticsWorkerValues() {
deleteCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME)
deleteCookie(SYNTHETICS_INJECTS_RUM_COOKIE_NAME)
}

export function mockCiVisibilityWindowValues(traceId?: string | { [key: string]: string }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

regarding the way you use it in the tests, the intent seems to be:

Suggested change
export function mockCiVisibilityWindowValues(traceId?: string | { [key: string]: string }) {
export function mockCiVisibilityWindowValues(traceId?: unknown) {

no?

@@ -75,6 +77,7 @@ export function startRumAssembly(
}

const syntheticsContext = getSyntheticsContext()
const ciContext = getCiTestContext()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const ciContext = getCiTestContext()
const ciTestContext = getCiTestContext()

for naming consistency

@@ -678,7 +678,7 @@ export interface CommonProperties {
/**
* Type of the session
*/
readonly type: 'user' | 'synthetics'
readonly type: 'user' | 'synthetics' | 'ci_test'
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you run yarn rum-events-format:sync (cf file header)?
the rum-events-format ref should also be updated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch

Copy link
Contributor

@bcaudan bcaudan left a comment

Choose a reason for hiding this comment

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

Nice!

@juan-fernandez juan-fernandez merged commit ee1ea0f into main Jan 3, 2022
@juan-fernandez juan-fernandez deleted the juan-fernandez/civisibility-cypress-poc branch January 3, 2022 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants