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

Add TraceFlags support to logs exporter #690

Merged
merged 1 commit into from
Jul 28, 2023

Conversation

damemi
Copy link
Contributor

@damemi damemi commented Jul 28, 2023

Fixes #685
Adds support for TraceFlags to parse traceID sampling (alongside the existing gcp.trace_sampled attribute)

Right now, if either flag is set then TraceSampled will be true. We might want to shift to one taking precedence, but for backward compatibility this is the least breaking way to introduce the feature.

@damemi damemi requested a review from a team as a code owner July 28, 2023 15:54
if traceSampled, ok := attrsMap[TraceSampledAttributeKey]; ok {
entry.TraceSampled = traceSampled.Bool()
// parse TraceSampled boolean from OTel attribute or IsSampled OTLP flag
if traceSampled, ok := attrsMap[TraceSampledAttributeKey]; ok || logRecord.Flags().IsSampled() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why did we have a "special" attribute in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the spec we map all GCP LogEntry fields to a matching gcp.* attribute. LogEntry has a field traceSampled, so we get gcp.trace_sampled as the matching attribute.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we update the spec to say that we should use the log record sampled flag instead of this attribute? We can keep it in the exporter for backwards-compatibility, but sampled isn't something I expect to get from attributes generally speaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup good point, either way if we're adding support for log Flags we should update that spec doc to show it. I'll open a PR for that too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exporter/collector/logs.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #690 (918e52c) into main (54a8992) will decrease coverage by 0.09%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #690      +/-   ##
==========================================
- Coverage   69.31%   69.22%   -0.09%     
==========================================
  Files          36       36              
  Lines        4728     4728              
==========================================
- Hits         3277     3273       -4     
- Misses       1297     1301       +4     
  Partials      154      154              
Files Changed Coverage Δ
exporter/collector/logs.go 41.02% <100.00%> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@damemi damemi merged commit f1c273d into GoogleCloudPlatform:main Jul 28, 2023
24 of 25 checks passed
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.

Support TraceFlags in logging exporter
2 participants