Skip to content

Commit

Permalink
Set CSA pub key on Otel resource
Browse files Browse the repository at this point in the history
  • Loading branch information
4of9 committed Oct 29, 2024
1 parent eacec32 commit 67152b5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/beholder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package beholder
import (
"context"
"errors"
"fmt"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc"
Expand Down Expand Up @@ -232,6 +233,21 @@ func newOtelResource(cfg Config) (resource *sdkresource.Resource, err error) {
if err != nil {
return nil, err
}

// Add csa public key resource attribute
csaPublicKeyHex := "not-configured"
if len(cfg.AuthenticatorPublicKey) > 0 {
csaPublicKeyHex = fmt.Sprintf("%x", cfg.AuthenticatorPublicKey)
}
csaPublicKeyAttr := attribute.String("csa_public_key", csaPublicKeyHex)
resource, err = sdkresource.Merge(
sdkresource.NewSchemaless(csaPublicKeyAttr),
resource,
)
if err != nil {
return nil, err
}

// Add custom resource attributes
resource, err = sdkresource.Merge(
sdkresource.NewSchemaless(cfg.ResourceAttributes...),
Expand Down

0 comments on commit 67152b5

Please sign in to comment.