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

chore: adding info to debug whenever headers are being skipped due to cors policy #2061

Merged
merged 4 commits into from
Apr 9, 2021

Conversation

obecny
Copy link
Member

@obecny obecny commented Mar 30, 2021

Which problem is this PR solving?

Short description of the changes

  • It will debug information whenever adding headers was prevented because origin didn't match the config property propagateTraceHeaderCorsUrls

@codecov
Copy link

codecov bot commented Mar 30, 2021

Codecov Report

Merging #2061 (657fe53) into main (a51bbbd) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 657fe53 differs from pull request most recent head b7cd485. Consider uploading reports for the commit b7cd485 to get more accurate results

@@           Coverage Diff           @@
##             main    #2061   +/-   ##
=======================================
  Coverage   93.07%   93.08%           
=======================================
  Files         154      154           
  Lines        5991     5999    +8     
  Branches     1256     1258    +2     
=======================================
+ Hits         5576     5584    +8     
  Misses        415      415           
Impacted Files Coverage Δ
...s/opentelemetry-instrumentation-fetch/src/fetch.ts 99.27% <100.00%> (+0.02%) ⬆️
...emetry-instrumentation-xml-http-request/src/xhr.ts 96.89% <100.00%> (+0.06%) ⬆️

const headers: Partial<Record<string, unknown>> = {};
api.propagation.inject(api.context.active(), headers);
if (Object.keys(headers).length > 0) {
api.diag.debug('headers inject skipped due to CORS policy');
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor suggestion on the actual error content headers not injected vs headers inject skipped

And as a general diagnostic error logging (I know we have previously talked about adding a scope using a standard mechanism), but in the mean-time do we want to manually add the scope to make it easier for us and users to understand where this log cam from?

eg. (Using OT-Fetch as an example -- it probably needs a larger general discussion to define a general convention)
api.diag.debug('OT-Fetch: headers not injected due to CORS policy");

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is yet to be decided how the namespace should be constructed but not in this PR, please move the discussion to separate issue. With regards to copy it is how it was suggested in the raised issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve diagnostic logging for header injection from client instrumentations
4 participants