-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
not done yet. moving to new sia-mac :D
- Loading branch information
Showing
6 changed files
with
148 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package settings | ||
|
||
func (s Settings) RegisterFlagPointers() |
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,30 @@ | ||
package settings | ||
|
||
import "github.com/ilyakaznacheev/cleanenv" | ||
|
||
type Settings struct { | ||
AuthServerAddress string `yaml:"bindAddress" env:"BIND_ADDRESS" env-default:":8082" env-description:"The address the authorization service binds to."` | ||
MetricsAddress string `yaml:"metricsBindAddress" env:"METRICS_BIND_ADDRESS" env-default:":8080" env-description:"The address the metric endpoint binds to."` | ||
ProbeAddress string `yaml:"healthProbeBindAddress" env:"PROBE_BIND_ADDRESS" env-default:":8081" env-description:"The address the probe endpoint binds to."` | ||
|
||
TLS struct { | ||
CertPath string `yaml:"certPath" env:"AUTH_SERVER_TLS_CERT_PATH" env-default:"" env-description:"grpc Authentication server TLS certificate file path"` | ||
KeyPath string `yaml:"keyPath" env:"AUTH_SERVER_TLS_KEY_PATH" env-default:"" env-description:"grpc Authentication server TLS Key file path"` | ||
CaPath string `yaml:"caPath" env:"AUTH_SERVER_TLS_CA_PATH" env-default:"" env-description:"grpc Authentication server TLS CA file path"` | ||
} `yaml:"tls"` | ||
|
||
LeaderElection struct { | ||
Enabled bool `yaml:"enabled" env:"LEADER_ELECTION_ENABLED" env-default:"false" env-description:"Enable leader election for controller manager."` | ||
ID string `yaml:"id" env:"LEADER_ELECTION_ID" env-default:"f5d1781e.snappcloud.io" env-description:"ID determines the name of the resource that leader election will use for holding the leader lock."` | ||
} `yaml:"leaderElection"` | ||
|
||
Tracing struct { | ||
Enabled bool `yaml:"enabled" env:"ENABLE_TRACING" env-default:"false" env-description:"Enable OpenTelemetry tracing."` | ||
Provider string `yaml:"provider" env:"TRACING_PROVIDER" env-default:"jaeger" env-description:"only jaeger is available now"` | ||
} `yaml:"tracing"` | ||
} | ||
|
||
func GetSettings() (st Settings, err error) { | ||
cleanenv.ReadEnv(&st) | ||
return | ||
} |
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,53 @@ | ||
package tracing | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/exporters/jaeger" | ||
"go.opentelemetry.io/otel/sdk/resource" | ||
tracesdk "go.opentelemetry.io/otel/sdk/trace" | ||
semconv "go.opentelemetry.io/otel/semconv/v1.4.0" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
const ( | ||
CerberusTracerName = "cerberus" | ||
JaegerTracing = "jaeger" | ||
) | ||
|
||
var cerberusTracer trace.Tracer | ||
|
||
func init() { | ||
cerberusTracer = otel.Tracer(CerberusTracerName) | ||
} | ||
|
||
func SetTracingProvider(provider string) error { | ||
if provider == JaegerTracing { | ||
exporter, err := jaeger.New(jaeger.WithAgentEndpoint()) | ||
if err != nil { | ||
return nil, err | ||
Check failure on line 30 in pkg/tracing/tracing.go GitHub Actions / lint
|
||
} | ||
tp := tracesdk.NewTracerProvider( | ||
tracesdk.WithBatcher(exporter), | ||
tracesdk.WithSampler(tracesdk.ParentBased(tracesdk.TraceIDRatioBased(samplerRatio))), | ||
Check failure on line 34 in pkg/tracing/tracing.go GitHub Actions / lint
|
||
// Record information about this application in a Resource. | ||
tracesdk.WithResource(resource.NewWithAttributes( | ||
semconv.SchemaURL, | ||
semconv.ServiceNameKey.String(serviceName), | ||
Check failure on line 38 in pkg/tracing/tracing.go GitHub Actions / lint
|
||
)), | ||
) | ||
return tp, nil | ||
Check failure on line 41 in pkg/tracing/tracing.go GitHub Actions / lint
|
||
|
||
} | ||
return fmt.Errorf("invalid-tracing-provider") | ||
} | ||
|
||
func StartSpan(ctx context.Context, spanName string) (context.Context, trace.Span) { | ||
return cerberusTracer.Start(ctx, spanName) | ||
} | ||
|
||
func Tracer() *trace.Tracer { | ||
return &cerberusTracer | ||
} |