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

feat(logging): implement auto-population of the calling source location #6043

Merged
merged 6 commits into from
May 20, 2022

Conversation

minherz
Copy link
Contributor

@minherz minherz commented May 17, 2022

auto-populate the ingest log entry with the source location of the calling code including file name, function name and code line number.
provide designated logger option: SourceLocationPopulation to control source population logic. The option can be initiated with the following values:

  • SourceLocationPopulation(DoNotPopulateSourceLocation) - continue with existing behavior when the source location field of the log entry is not populated automatically (default)
  • SourceLocationPopulation(PopulateSourceLocationForDebugEntries) - the source location is auto-populated for log entries with Debug severity
  • SourceLocationPopulation(DoNotPopulateSourceLocation) - the source location is auto-populated for all log entries

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label May 17, 2022
@minherz minherz marked this pull request as ready for review May 17, 2022 03:03
@minherz minherz requested review from a team as code owners May 17, 2022 03:03
@minherz minherz requested a review from codyoss May 17, 2022 03:06
@minherz
Copy link
Contributor Author

minherz commented May 17, 2022

@codyoss can you have a look into the test implementation? maybe you will have a good idea how i can test it without patching the wanted result

add implicit source location population for ingested log entries that
have severity level DEBUG
add unit testing for source location
add function name to the published source info
add logger option to control source location population
@minherz minherz changed the title feat(logging) implement auto-population of the calling source location feat(logging): implement auto-population of the calling source location May 20, 2022
@minherz minherz merged commit 50d43f2 into structured_logging May 20, 2022
@minherz minherz deleted the minherz/source-location branch May 20, 2022 04:25
minherz added a commit that referenced this pull request May 20, 2022
…on (#6043)

add source location population for ingested log entries.
provide designated logger option: `SourceLocationPopulation` to control source population logic. The option can be initiated with the following values:

* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - continue with existing behavior when the source location field of the log entry is not populated automatically (default)
* `SourceLocationPopulation(PopulateSourceLocationForDebugEntries)` - the source location is auto-populated for log entries with Debug severity
* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - the source location is auto-populated for all log entries
minherz added a commit that referenced this pull request May 24, 2022
…on (#6043)

add source location population for ingested log entries.
provide designated logger option: `SourceLocationPopulation` to control source population logic. The option can be initiated with the following values:

* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - continue with existing behavior when the source location field of the log entry is not populated automatically (default)
* `SourceLocationPopulation(PopulateSourceLocationForDebugEntries)` - the source location is auto-populated for log entries with Debug severity
* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - the source location is auto-populated for all log entries
minherz added a commit that referenced this pull request May 25, 2022
…on (#6043)

add source location population for ingested log entries.
provide designated logger option: `SourceLocationPopulation` to control source population logic. The option can be initiated with the following values:

* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - continue with existing behavior when the source location field of the log entry is not populated automatically (default)
* `SourceLocationPopulation(PopulateSourceLocationForDebugEntries)` - the source location is auto-populated for log entries with Debug severity
* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - the source location is auto-populated for all log entries
minherz added a commit that referenced this pull request May 28, 2022
…on (#6043)

add source location population for ingested log entries.
provide designated logger option: `SourceLocationPopulation` to control source population logic. The option can be initiated with the following values:

* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - continue with existing behavior when the source location field of the log entry is not populated automatically (default)
* `SourceLocationPopulation(PopulateSourceLocationForDebugEntries)` - the source location is auto-populated for log entries with Debug severity
* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - the source location is auto-populated for all log entries
minherz added a commit that referenced this pull request Jun 10, 2022
…on (#6043)

add source location population for ingested log entries.
provide designated logger option: `SourceLocationPopulation` to control source population logic. The option can be initiated with the following values:

* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - continue with existing behavior when the source location field of the log entry is not populated automatically (default)
* `SourceLocationPopulation(PopulateSourceLocationForDebugEntries)` - the source location is auto-populated for log entries with Debug severity
* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - the source location is auto-populated for all log entries
minherz added a commit that referenced this pull request Jun 23, 2022
…on (#6043)

add source location population for ingested log entries.
provide designated logger option: `SourceLocationPopulation` to control source population logic. The option can be initiated with the following values:

* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - continue with existing behavior when the source location field of the log entry is not populated automatically (default)
* `SourceLocationPopulation(PopulateSourceLocationForDebugEntries)` - the source location is auto-populated for log entries with Debug severity
* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - the source location is auto-populated for all log entries
minherz added a commit that referenced this pull request Jun 25, 2022
…on (#6043)

add source location population for ingested log entries.
provide designated logger option: `SourceLocationPopulation` to control source population logic. The option can be initiated with the following values:

* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - continue with existing behavior when the source location field of the log entry is not populated automatically (default)
* `SourceLocationPopulation(PopulateSourceLocationForDebugEntries)` - the source location is auto-populated for log entries with Debug severity
* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - the source location is auto-populated for all log entries
minherz added a commit that referenced this pull request Jun 25, 2022
* fix(logging): revise automatic resource detection for ingested logs (#6022)

align resource detection with heuristics in logging libraries for other languages:
- use /sys/class/dmi/id/product_name to read a product name of the resource on Linux
- change resource detection heuristics in a way that the order of validation is not important
- reduce timeout and retrying logic when querying metadata server
- demand active metadata server for detecting GCP resources (for GCE, GAE, GKE, CR and CF)
- add test to validate resource detection heuristics

* feat(logging): implement auto-population of the calling source location (#6043)

add source location population for ingested log entries.
provide designated logger option: `SourceLocationPopulation` to control source population logic. The option can be initiated with the following values:

* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - continue with existing behavior when the source location field of the log entry is not populated automatically (default)
* `SourceLocationPopulation(PopulateSourceLocationForDebugEntries)` - the source location is auto-populated for log entries with Debug severity
* `SourceLocationPopulation(DoNotPopulateSourceLocation)` - the source location is auto-populated for all log entries

Add a benchmark test to measure execution time for detectResource() to help with addressing issues like #5855.

```bash
go test -run=XXX -bench=BenchmarkDetectResource -benchtime 8s
goos: linux
goarch: amd64
pkg: cloud.google.com/go/logging
cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
BenchmarkDetectResource-8       1000000000               2.291 ns/op
PASS
ok      cloud.google.com/go/logging     9.955s
```

When the  cloud.google.com/go/compute/metadata package will be modified to allow customizable retrying mechanism, this logic will be altered to minimize the number of retries for the initial call.

* feat(logging): support partialSuccess flag for batched ingestions (#6092)

Add PartialSuccess option to set partialSuccess flag in WriteLogEntries calls to true

* feat(logging): retrieve trace info from traceparent (#6101)

Add support for W3C trace context header: traceparent

* feat(logging): enable redirecting log ingestion to stdout/stderr (#6130)

Implement writing log entries to io.writer instead of ingesting them to Logging service.
the written log entries are Jsonified into one line strings following structured logging format.
Support protobuf payloads when passing the payload as protobuf.Any.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant