Skip to content

Commit 19253b0

Browse files
Merge branch 'main' into renovate/golangci-golangci-lint-action-9.x
2 parents eb36a5e + 307bc85 commit 19253b0

8 files changed

Lines changed: 39 additions & 6 deletions

File tree

.github/workflows/lint_golang.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: Lint with GolangCI
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v5
18+
- uses: actions/checkout@v6
1919
- uses: actions/setup-go@v6
2020
id: go
2121
with:

.github/workflows/regen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
timeout-minutes: 30
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v5
15+
- uses: actions/checkout@v6
1616
- uses: actions/setup-go@v6
1717
id: go
1818
with:

.github/workflows/unittest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
os: [ubuntu-latest, macos-latest, windows-latest]
2121
steps:
2222
- name: Check out code into the Go module directory
23-
uses: actions/checkout@v5
23+
uses: actions/checkout@v6
2424
- name: Set up Go 1.x
2525
uses: actions/setup-go@v6
2626
with:

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.26.27"
2+
".": "1.27.0"
33
}

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## [1.27.0](https://github.com/cloudquery/plugin-pb-go/compare/v1.26.27...v1.27.0) (2025-12-01)
4+
5+
6+
### Features
7+
8+
* Support logging of tenant ID ([#580](https://github.com/cloudquery/plugin-pb-go/issues/580)) ([4634b49](https://github.com/cloudquery/plugin-pb-go/commit/4634b49256cba6ebe9e39c5aacc4092263b86102))
9+
10+
11+
### Bug Fixes
12+
13+
* **deps:** Update module github.com/docker/docker to v28.5.2+incompatible ([#576](https://github.com/cloudquery/plugin-pb-go/issues/576)) ([2794c32](https://github.com/cloudquery/plugin-pb-go/commit/2794c326338db4776ead3950aa116358e02daf44))
14+
* **deps:** Update module google.golang.org/grpc to v1.77.0 ([#575](https://github.com/cloudquery/plugin-pb-go/issues/575)) ([bdbb9be](https://github.com/cloudquery/plugin-pb-go/commit/bdbb9be94979705b89e30a27022a8cfcdfbd9109))
15+
* Generate Go Code from `plugin-pb` ([#573](https://github.com/cloudquery/plugin-pb-go/issues/573)) ([1ac0dfc](https://github.com/cloudquery/plugin-pb-go/commit/1ac0dfc2caeb12e9a4f89a0bd87a44bd67bd6f34))
16+
317
## [1.26.27](https://github.com/cloudquery/plugin-pb-go/compare/v1.26.26...v1.26.27) (2025-11-18)
418

519

internal/env/env.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package env
2+
3+
import "os"
4+
5+
func TenantID() string {
6+
return os.Getenv("_CQ_TENANT_ID")
7+
}

managedplugin/logging.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ package managedplugin
22

33
import "github.com/rs/zerolog"
44

5-
func (c *Client) jsonToLog(l zerolog.Logger, msg map[string]any) {
5+
func (c *Client) jsonToLog(l zerolog.Logger, msg map[string]any, protectedFields []string) {
66
level := msg["level"]
77
// The log level is part of the log message received from the plugin, so we need to remove it before logging
88
delete(msg, "level")
9+
10+
// Remove protected fields from log message to avoid duplication
11+
for _, field := range protectedFields {
12+
delete(msg, field)
13+
}
914
switch level {
1015
case "trace":
1116
l.Trace().Fields(msg).Msg("")

managedplugin/plugin.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"time"
1818

1919
"github.com/avast/retry-go/v4"
20+
"github.com/cloudquery/plugin-pb-go/internal/env"
2021
pbBase "github.com/cloudquery/plugin-pb-go/pb/base/v0"
2122
pbDiscovery "github.com/cloudquery/plugin-pb-go/pb/discovery/v0"
2223
pbDiscoveryV1 "github.com/cloudquery/plugin-pb-go/pb/discovery/v1"
@@ -557,6 +558,12 @@ func (c *Client) readLogLines(reader io.ReadCloser) {
557558
lr := NewLogReader(reader)
558559
// reset the context to avoid duplicate fields in the logs when streaming logs from plugins
559560
pluginsLogger := c.logger.With().Reset().Timestamp().Logger()
561+
protectedFields := make([]string, 0)
562+
tenantID := env.TenantID()
563+
if tenantID != "" {
564+
pluginsLogger = pluginsLogger.With().Str("tenant_id", tenantID).Logger()
565+
protectedFields = append(protectedFields, "tenant_id")
566+
}
560567
for {
561568
line, err := lr.NextLine()
562569
if errors.Is(err, io.EOF) {
@@ -574,7 +581,7 @@ func (c *Client) readLogLines(reader io.ReadCloser) {
574581
if err := json.Unmarshal(line, &structuredLogLine); err != nil {
575582
c.logger.Info().Str("level", "unknown").Msg(string(line))
576583
} else {
577-
c.jsonToLog(pluginsLogger, structuredLogLine)
584+
c.jsonToLog(pluginsLogger, structuredLogLine, protectedFields)
578585
}
579586
}
580587
}

0 commit comments

Comments
 (0)