-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
chore: add telemetry realworld app #26896
Changes from 10 commits
24bc79a
cbfb1fa
a368bb3
b4fe691
de811f9
33323fc
bce60ad
f7a96ec
3ba96a4
5c4c674
648fa83
6a8a5bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,14 +33,18 @@ export class OTLPTraceExporter extends OTLPTraceExporterHttp { | |
enc: OTLPExporterNodeConfigBasePlusEncryption['encryption'] | undefined | ||
projectId?: string | ||
recordKey?: string | ||
requirementsToExport: 'met'| 'unmet' | 'unknown' | ||
sendWithHttp: typeof sendWithHttp | ||
constructor (config: OTLPExporterNodeConfigBasePlusEncryption = {}) { | ||
super(config) | ||
this.enc = config.encryption | ||
this.delayedItemsToExport = [] | ||
this.sendWithHttp = sendWithHttp | ||
if (this.enc) { | ||
this.requirementsToExport = 'unknown' | ||
this.headers['x-cypress-encrypted'] = '1' | ||
} else { | ||
this.requirementsToExport = 'met' | ||
} | ||
} | ||
|
||
|
@@ -50,6 +54,11 @@ export class OTLPTraceExporter extends OTLPTraceExporterHttp { | |
*/ | ||
attachProjectId (projectId: string | null | undefined): void { | ||
if (!projectId) { | ||
if (this.requirementsToExport === 'unknown') { | ||
this.requirementsToExport = 'unmet' | ||
Comment on lines
+59
to
+60
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. why do we need unknown and unmet? can we assume 'unmet' until met? 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. any reason this wasn't a bool? 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. when encryption is on, we can't assume unmet until we get a null project id or record key. The send function will behave differently. If unmet we error instantly, if unknown we will delay the request. 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. Otherwise we could incorrectly fail any spans sent prior to getting the project id/record key, since we capture spans prior to them being available. 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. makes sense, maybe we throw a comment in there about this? unless I missed it per the limited diff view 😅 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. sure |
||
this.abortDelayedItems() | ||
} | ||
|
||
return | ||
} | ||
|
||
|
@@ -65,6 +74,11 @@ export class OTLPTraceExporter extends OTLPTraceExporterHttp { | |
*/ | ||
attachRecordKey (recordKey: string | null | undefined): void { | ||
if (!recordKey) { | ||
if (this.requirementsToExport === 'unknown') { | ||
this.requirementsToExport = 'unmet' | ||
this.abortDelayedItems() | ||
} | ||
|
||
return | ||
} | ||
|
||
|
@@ -77,6 +91,7 @@ export class OTLPTraceExporter extends OTLPTraceExporterHttp { | |
*/ | ||
setAuthorizationHeader () { | ||
if (this.projectId && this.recordKey) { | ||
this.requirementsToExport = 'met' | ||
this.headers.Authorization = `Basic ${Buffer.from(`${this.projectId}:${this.recordKey}`).toString('base64')}` | ||
this.sendDelayedItems() | ||
} | ||
|
@@ -95,6 +110,14 @@ export class OTLPTraceExporter extends OTLPTraceExporterHttp { | |
} | ||
} | ||
|
||
abortDelayedItems () { | ||
this.delayedItemsToExport.forEach((item) => { | ||
item.onError(new Error('Spans cannot be sent, exporter has unmet requirements, either project id or record key are undefined.')) | ||
}) | ||
|
||
this.delayedItemsToExport = [] | ||
} | ||
|
||
/** | ||
* Overrides send if we need to encrypt the request. | ||
* @param objects | ||
|
@@ -113,6 +136,10 @@ export class OTLPTraceExporter extends OTLPTraceExporterHttp { | |
return | ||
} | ||
|
||
if (this.requirementsToExport === 'unmet') { | ||
onError(new Error('Spans cannot be sent, exporter has unmet requirements, either project id or record key are undefined.')) | ||
} | ||
|
||
let serviceRequest: string | ||
|
||
if (typeof objects !== 'string') { | ||
|
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.
was recording disabled to test this? or are you intentionally disabling?
Also not in this scope per-say, but do you know whats different between the
test-binary-against-rwa
andtest-binary-against-repo
jobs?test-binary-against-rwa
seems like a copy paste?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.
Recording was never enabled, but i needed to override the project ID and record key to send telemetry. I disabled recording to silence a warning thrown when record is not enabled.
I don't know the different between test-binary-against-repo, I didn't notice they were the same.
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.
ohh I see, passing
CYPRESS_PROJECT_ID
prob caused that errorThere 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.
Do we no longer need the double
--
since the command is executed withyarn
?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.
Yeah, yarn kept yelling at me about it.