-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exporter/loki
: handle multi-tenant use-cases (#12415)
* `exporter/loki`: handle multi-tenant use-cases Fixes #3121 Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de> * Add changelog entry Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de> * linter suggestions Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de> * Fail when both TenantID and Tenant are specified Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
- Loading branch information
1 parent
b380b99
commit 16ac192
Showing
13 changed files
with
518 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package tenant // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/lokiexporter/internal/tenant" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/pdata/plog" | ||
) | ||
|
||
var _ Source = (*AttributeTenantSource)(nil) | ||
|
||
type AttributeTenantSource struct { | ||
Value string | ||
} | ||
|
||
func (ts *AttributeTenantSource) GetTenant(_ context.Context, logs plog.Logs) (string, error) { | ||
for i := 0; i < logs.ResourceLogs().Len(); i++ { | ||
rl := logs.ResourceLogs().At(i) | ||
if v, found := rl.Resource().Attributes().Get(ts.Value); found { | ||
return v.StringVal(), nil | ||
} | ||
} | ||
return "", nil | ||
} |
Oops, something went wrong.