-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) return a default topic when tenant_id is not present (#304)
* (feat) return a default topic when tenant_id is not present * (refactor) rename the function to getKafkaTopicPrefixFromClientMetadata making it consistent with what the function is doing
- Loading branch information
1 parent
0dc0b50
commit 539b6be
Showing
3 changed files
with
17 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
package signozkafkaexporter | ||
|
||
import ( | ||
"fmt" | ||
|
||
"go.opentelemetry.io/collector/client" | ||
) | ||
|
||
const ( | ||
DefaultKafkaTopicPrefix = "default" | ||
) | ||
|
||
// getKafkaTopicFromClientMetadata returns the kafka topic from client metadata | ||
func getKafkaTopicFromClientMetadata(md client.Metadata) (string, error) { | ||
func getKafkaTopicPrefixFromClientMetadata(md client.Metadata) string { | ||
// return default topic if no tenant id is found in client metadata | ||
signozTenantId := md.Get("signoz_tenant_id") | ||
if len(signozTenantId) == 0 { | ||
return "", fmt.Errorf("signoz_tenant_id not found in client metadata") | ||
if len(signozTenantId) != 0 { | ||
return signozTenantId[0] | ||
} | ||
return signozTenantId[0], nil | ||
|
||
return DefaultKafkaTopicPrefix | ||
} |