Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.1.0
to 5.2.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/setup-go/releases">actions/setup-go's
releases</a>.</em></p>
<blockquote>
<h2>v5.2.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Leveraging the raw API to retrieve the version-manifest, as it does
not impose a rate limit and hence facilitates unrestricted consumption
without the need for a token for Github Enterprise Servers by <a
href="https://github.com/Shegox"><code>@Shegox</code></a> in <a
href="https://redirect.github.com/actions/setup-go/pull/496">actions/setup-go#496</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/Shegox"><code>@Shegox</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/setup-go/pull/496">actions/setup-go#496</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/setup-go/compare/v5...v5.2.0">https://github.com/actions/setup-go/compare/v5...v5.2.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="3041bf56c9"><code>3041bf5</code></a>
feat: fallback to "raw" endpoint for manifest when rate limit
is reached (<a
href="https://redirect.github.com/actions/setup-go/issues/496">#496</a>)</li>
<li>See full diff in <a
href="41dfa10bad...3041bf56c9">compare
view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Without the slogtest change, with the newly added test:
```
go test ./slogtest/ -v
=== RUN TestSlogTest
slogtest.go:20: time=2024-02-12T16:50:56.437-05:00 level=INFO msg="hello world" foo=bar
--- PASS: TestSlogTest (0.00s)
PASS
ok github.com/chainguard-dev/clog/slogtest 0.116s
```
With this change:
```
go test ./slogtest -v
=== RUN TestSlogTest
slogtest.go:31: level=INFO source=/Users/jason/git/clog/slogtest/slogtest_test.go:13 msg="hello world" foo=bar
slogtest.go:31: level=INFO source=/Users/jason/git/clog/slogtest/slogtest_test.go:14 msg="me again" bar=baz
slogtest.go:31: level=INFO source=/Users/jason/git/clog/slogtest/slogtest_test.go:15 msg="okay last one" baz=true
```
---------
Signed-off-by: Jason Hall <jason@chainguard.dev>
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.1
to 5.0.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/setup-go/releases">actions/setup-go's
releases</a>.</em></p>
<blockquote>
<h2>v5.0.2</h2>
<h2>What's Changed</h2>
<h3>Bug fixes:</h3>
<ul>
<li>Fix versions check failure by <a
href="https://github.com/HarithaVattikuti"><code>@HarithaVattikuti</code></a>
in <a
href="https://redirect.github.com/actions/setup-go/pull/479">actions/setup-go#479</a></li>
</ul>
<h3>Dependency updates:</h3>
<ul>
<li>Bump braces from 3.0.2 to 3.0.3 and undici from 5.28.3 to 5.28.4 by
<a href="https://github.com/dependabot"><code>@dependabot</code></a> in
<a
href="https://redirect.github.com/actions/setup-go/pull/487">actions/setup-go#487</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/HarithaVattikuti"><code>@HarithaVattikuti</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/setup-go/pull/479">actions/setup-go#479</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/setup-go/compare/v5...v5.0.2">https://github.com/actions/setup-go/compare/v5...v5.0.2</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="0a12ed9d6a"><code>0a12ed9</code></a>
Bump braces from 3.0.2 to 3.0.3 (<a
href="https://redirect.github.com/actions/setup-go/issues/487">#487</a>)</li>
<li><a
href="4ab57d7ea2"><code>4ab57d7</code></a>
Fix versions check failure (<a
href="https://redirect.github.com/actions/setup-go/issues/479">#479</a>)</li>
<li>See full diff in <a
href="cdcb360436...0a12ed9d6a">compare
view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
According to
https://cloud.google.com/trace/docs/trace-context#http-requests,
`X-Cloud-Trace-Context` is a legacy header that precedes the W3C
standard `traceparent` header. Google Cloud services that support trace
context propagation typically support both the `traceparent` and the
legacy `X-Cloud-Trace-Context` header.
Switching to use this so that we don't have to use the legacy header
`X-Cloud-Trace-Context` when restoring trace context header for pubsub
eventing, but only using `traceparent` every where.
Currently `With()` will reset context back to `context.Background()`,
causing the `wrap/wrapf` calls to lose the original context.
This affects the `clog/gcp` handler who relies on a value keyed with
`"trace"` being set on the context
([see](https://github.com/chainguard-dev/clog/blob/main/gcp/trace.go#L110-L116))
(we should use a typed value though, but that's in a different PR).
---------
Signed-off-by: Nghia Tran <tcnghia@gmail.com>
If `WithCloudTraceContext` is called from tests where GCE metadata isn't
available, it hangs indefinitely, which is not a great experience.
Some improvements in this PR:
- project ID lookup will only be performed once, instead of each time
`WithCloudTraceContext` is called
- if we detect we're being called in tests, the project ID won't be
looked up and we won't log with trace context
- add a standard short timeout to metadata requests, consistent with the
official client
Also add a test that shows that the `trace` context value is set when
the project ID env var is set; because this logging must go to stderr,
we can't easily test what actually gets logged, but we can show it
working in the verbose output:
```
go test ./gcp -v -count=1
=== RUN TestTrace
=== RUN TestTrace/no_env_set
{"time":"2024-02-12T20:22:14.059143-05:00","severity":"DEBUG","logging.googleapis.com/sourceLocation":{"function":"github.com/chainguard-dev/clog/gcp.insideTest","file":"/Users/jason/git/clog/gcp/trace.go","line":33},"message":"WithCloudTraceContext: inside test","function":"testing.tRunner","file":"/opt/homebrew/Cellar/go/1.21.5/libexec/src/testing/testing.go","line":1595}
{"time":"2024-02-12T20:22:14.059343-05:00","severity":"DEBUG","logging.googleapis.com/sourceLocation":{"function":"github.com/chainguard-dev/clog/gcp.WithCloudTraceContext.func1","file":"/Users/jason/git/clog/gcp/trace.go","line":56},"message":"WithCloudTraceContext: inside test, not looking up project ID"}
{"time":"2024-02-12T20:22:14.060156-05:00","severity":"INFO","logging.googleapis.com/sourceLocation":{"function":"github.com/chainguard-dev/clog/gcp.TestTrace.func2.1","file":"/Users/jason/git/clog/gcp/trace_test.go","line":37},"message":"hello world"}
=== RUN TestTrace/env_set
{"time":"2024-02-12T20:22:14.060678-05:00","severity":"INFO","logging.googleapis.com/sourceLocation":{"function":"github.com/chainguard-dev/clog/gcp.TestTrace.func2.1","file":"/Users/jason/git/clog/gcp/trace_test.go","line":37},"message":"hello world","logging.googleapis.com/trace":"projects/my-project/traces/trace"}
--- PASS: TestTrace (0.00s)
--- PASS: TestTrace/no_env_set (0.00s)
--- PASS: TestTrace/env_set (0.00s)
PASS
ok github.com/chainguard-dev/clog/gcp 0.166s
```
The test also attempts to check that GCE metadata isn't requested.
Through this work I've found that `clog.FromContext(ctx).Info("hello")`
doesn't carry the `trace` context value, possibly related to
https://github.com/chainguard-dev/clog/pull/11
Signed-off-by: Jason Hall <jason@chainguard.dev>
Modification of #5
Allows for passing through the logger while still using default Info
methods. InfoContext remains to override the context with another value.
This changes the stored context value to store the underlying
slog.Logger instead of the wrapped logger so we're not storing a context
within a context.
This adds `clog.Fatal{Context}{f}`, and
`clog.FromContext(ctx).Fatal{Context}{f}`
`Fatal` logs at `LevelError` then calls `os.Exit(1)`, like stdlib
`log.Fatal`:
https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/log/log.go;l=413
---------
Signed-off-by: Jason Hall <jason@chainguard.dev>
Co-authored-by: Billy Lynch <1844673+wlynch@users.noreply.github.com>
I don't like any of the names here, and we might want it to be in a
separate subpackage. This lets you say `--log-level=DEBUG` to set the
level. The default is still INFO.
---------
Signed-off-by: Jason Hall <jason@chainguard.dev>
* rename to clog
Signed-off-by: Jason Hall <jason@chainguard.dev>
* fix example in README
Signed-off-by: Jason Hall <jason@chainguard.dev>
---------
Signed-off-by: Jason Hall <jason@chainguard.dev>