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

allow configuring opentelementry callback via config file #4916

Merged

Conversation

evgeni
Copy link
Contributor

@evgeni evgeni commented Jul 1, 2022

SUMMARY

this is especially useful for the enable_from_environment option, as
this allows to set a default for the whole project, instead of relying
on everyone setting the environment variable

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

opentelementry callback

ADDITIONAL INFORMATION

@evgeni evgeni force-pushed the opentelemetry-ini-options branch from e29942f to bad4134 Compare July 1, 2022 08:11
@ansibullbot
Copy link
Collaborator

cc @v1v
click here for bot help

@ansibullbot ansibullbot added callback callback plugin feature This issue/PR relates to a feature request new_contributor Help guide this first time contributor plugins plugin (any type) labels Jul 1, 2022
@github-actions
Copy link

github-actions bot commented Jul 1, 2022

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

Copy link
Contributor

@v1v v1v left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the contribution!

I didn't know by adding the ini section in the DOCS will enable this feature, that's really awesome!

Do you think adding an entry in the EXAMPLES section could help to illustrate how to use the ini values?

@evgeni
Copy link
Contributor Author

evgeni commented Jul 1, 2022

@v1v yeah, I can add an example for enable_from_environment, which is the one that benefits most from this.

@evgeni evgeni force-pushed the opentelemetry-ini-options branch from bad4134 to 4c44a37 Compare July 1, 2022 09:32
@evgeni
Copy link
Contributor Author

evgeni commented Jul 1, 2022

like this? or should we split that in a separate entry so it's clear it's not required?

Copy link
Contributor

@v1v v1v left a comment

Choose a reason for hiding this comment

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

Pretty much, 💯

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-5 labels Jul 1, 2022
@briantist
Copy link
Contributor

@felixfontein do you know why the second docs build didn't include the diff output? I haven't seen that before.. when it's too long it should end up truncated but not gone completely (and I don't think it would be too long in this case anyway).

@evgeni evgeni force-pushed the opentelemetry-ini-options branch from 4c44a37 to 15ad222 Compare July 3, 2022 09:53
@evgeni
Copy link
Contributor Author

evgeni commented Jul 3, 2022

@felixfontein thanks, updated!

@felixfontein
Copy link
Collaborator

@briantist I guess it is related to the warnings

Build Ansible Docs / Build Ansible Docs
Skip output 'diff' since it may contain secret.

Build Ansible Docs / Build Ansible Docs
Skip output 'diff-rendered' since it may contain secret.

here: https://github.com/ansible-collections/community.general/actions/runs/2604656993. It's somewhat confusing since this used to work: #4880 (comment) (and a very recent one: #4912 (comment)). The funny thing is that you can easily look at the diff output in the build output itself, so this is not really protecting it anyway...

this is especially useful for the `enable_from_environment` option, as
this allows to set a default for the whole project, instead of relying
on everyone setting the environment variable
@evgeni evgeni force-pushed the opentelemetry-ini-options branch from 15ad222 to 38cae0d Compare July 3, 2022 11:48
@ansibullbot ansibullbot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jul 3, 2022
@ansibullbot ansibullbot removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jul 3, 2022
@briantist
Copy link
Contributor

@briantist I guess it is related to the warnings

Build Ansible Docs / Build Ansible Docs
Skip output 'diff' since it may contain secret.

Build Ansible Docs / Build Ansible Docs
Skip output 'diff-rendered' since it may contain secret.

here: https://github.com/ansible-collections/community.general/actions/runs/2604656993. It's somewhat confusing since this used to work: #4880 (comment) (and a very recent one: #4912 (comment)). The funny thing is that you can easily look at the diff output in the build output itself, so this is not really protecting it anyway...

thanks @felixfontein this was helpful... the only thing I can think of is that maybe you've got a secret set in your repository whose name or value is included in the diff output?

I did a diff of the diff outputs before and after triggering this behavior, to see if that helps you figure it out

diff of diffs
-index 0ad55df..f9536a9 100644
+index 0ad55df..bc567ed 100644
 --- a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/opentelemetry_callback.html
 +++ b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/opentelemetry_callback.html
-@@ -187,7 +187,13 @@ To check whether it is installed, run <code class="code docutils literal notrans
+@@ -187,7 +187,14 @@ To check whether it is installed, run <code class="code docutils literal notrans
  <p>This is handy when you use Configuration as Code and want to send distributed traces if running in the CI rather when running Ansible locally.</p>
  <p>For such, it evaluates the given <em>enable_from_environment</em> value as environment variable and if set to true this plugin will be enabled.</p>
  <p class="ansible-option-line"><span class="ansible-option-configuration">Configuration:</span></p>
@@ -13,11 +13,12 @@ index 0ad55df..f9536a9 100644
 +<span class="l l-Scalar l-Scalar-Plain">enable_from_environment = None</span><span class="w"></span>
 +</pre></div>
 +</div>
++<p><span class="ansible-option-versionadded">added in 5.3.0 of community.general</span></p>
 +</li>
  <li><p>Environment variable: ANSIBLE_OPENTELEMETRY_ENABLE_FROM_ENVIRONMENT</p></li>
  </ul>
  </div></td>
-@@ -203,7 +209,13 @@ To check whether it is installed, run <code class="code docutils literal notrans
+@@ -203,7 +210,14 @@ To check whether it is installed, run <code class="code docutils literal notrans
  <li><p><span class="ansible-option-choices-entry">yes</span></p></li>
  </ul>
  <p class="ansible-option-line"><span class="ansible-option-configuration">Configuration:</span></p>
@@ -28,11 +29,12 @@ index 0ad55df..f9536a9 100644
 +<span class="l l-Scalar l-Scalar-Plain">hide_task_arguments = no</span><span class="w"></span>
 +</pre></div>
 +</div>
++<p><span class="ansible-option-versionadded">added in 5.3.0 of community.general</span></p>
 +</li>
  <li><p>Environment variable: ANSIBLE_OPENTELEMETRY_HIDE_TASK_ARGUMENTS</p></li>
  </ul>
  </div></td>
-@@ -215,7 +227,13 @@ To check whether it is installed, run <code class="code docutils literal notrans
+@@ -215,7 +229,14 @@ To check whether it is installed, run <code class="code docutils literal notrans
  <td><div class="ansible-option-cell"><p>The service name resource attribute.</p>
  <p class="ansible-option-line"><span class="ansible-option-default-bold">Default:</span> <span class="ansible-option-default">“ansible”</span></p>
  <p class="ansible-option-line"><span class="ansible-option-configuration">Configuration:</span></p>
@@ -43,7 +45,22 @@ index 0ad55df..f9536a9 100644
 +<span class="l l-Scalar l-Scalar-Plain">otel_service_name = ansible</span><span class="w"></span>
 +</pre></div>
 +</div>
++<p><span class="ansible-option-versionadded">added in 5.3.0 of community.general</span></p>
 +</li>
  <li><p>Environment variable: OTEL_SERVICE_NAME</p></li>
  </ul>
  </div></td>
+@@ -241,11 +262,14 @@ To check whether it is installed, run <code class="code docutils literal notrans
+ <span class="w">  </span><span class="no">Enable the plugin in ansible.cfg:</span><span class="w"></span>
+ <span class="w">    </span><span class="no">[defaults]</span><span class="w"></span>
+ <span class="w">    </span><span class="no">callbacks_enabled = community.general.opentelemetry</span><span class="w"></span>
++<span class="w">    </span><span class="no">[callback_opentelemetry]</span><span class="w"></span>
++<span class="w">    </span><span class="no">enable_from_environment = ANSIBLE_OPENTELEMETRY_ENABLED</span><span class="w"></span>
+ <span class="w">  </span><span class="no">Set the environment variable:</span><span class="w"></span>
+ <span class="w">    </span><span class="no">export OTEL_EXPORTER_OTLP_ENDPOINT=&lt;your endpoint (OTLP/HTTP)&gt;</span><span class="w"></span>
+ <span class="w">    </span><span class="no">export OTEL_EXPORTER_OTLP_HEADERS=&quot;authorization=***;</span><span class="w"></span>
+ <span class="w">    </span><span class="no">export OTEL_SERVICE_NAME=your_service_name</span><span class="w"></span>
++<span class="w">    </span><span class="no">export ANSIBLE_OPENTELEMETRY_ENABLED=true</span><span class="w"></span>
+ </pre></div>
+ </div>
+ <section id="authors">

I had a terrible possible thought, which is that of a "secret" set in the repo with the value of true or some such common thing. It does show up in the diff output that triggered this, and not before. And with Ansible's docs typically using yes/no for booleans, it's conceivable we may not have run into it before (and it would have required a repo with a secret set to that value).

Probably a longshot...

The thing that makes me think maybe it's not value related, is that such a value should get masked in the output automatically, and it isn't.

So that makes me wonder if this precaution only kicks in when the name of a secret shows up in output. After all the language in the warning "may contain secret" is not definitive, and it's only affecting job outputs.

This seems to have kicked in when docs containing a bunch of uppercase environment variables showed up, and by convention secrets in GitHub are usually set that way too, so maybe this repo has an ANSIBLE_OPENTELEMETRY_ENABLED secret set for some reason?

Care to take a look?

evgeni added a commit to evgeni/forklift that referenced this pull request Jul 4, 2022
This was referenced Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
callback callback plugin feature This issue/PR relates to a feature request new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants